• PDF添加水印


    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using iTextSharp;
    using iTextSharp.text.pdf;
    using System.IO;
    using System.Drawing;
    using iTextSharp.testutils;
    
    
    
    public partial class pdf : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
    
        }
        protected void Button1_Click(object sender, EventArgs e)
        {
            PdfReader PDFReader = new PdfReader(Server.MapPath("c.pdf"));
    
            FileStream Stream = new FileStream(Server.MapPath("d.pdf"), FileMode.Create, FileAccess.Write);
    
            PdfStamper PDFStamper = new PdfStamper(PDFReader, Stream);
    
            for (int iCount = 0; iCount < PDFStamper.Reader.NumberOfPages; iCount++)
            {
                PdfContentByte PDFData = PDFStamper.GetOverContent(iCount + 1);
                BaseFont baseFont = BaseFont.CreateFont(BaseFont.HELVETICA, BaseFont.WINANSI, BaseFont.EMBEDDED);
                PDFData.BeginText();
                PDFData.SetColorFill(CMYKColor.LIGHT_GRAY);
                PDFData.SetFontAndSize(baseFont, 80);
                 PDFData.ShowTextAligned(PdfContentByte.ALIGN_CENTER, "Sample", 300, 400, 45);
                PDFData.EndText();
            }
    
          
            PDFStamper.Close();
            PDFReader.Close();
            Stream.Close();
        }
    
    
       
    }

    https://files.cnblogs.com/files/mqingqing123/pdf.rar

  • 相关阅读:
    模块之间的消息传递优势与问题
    cp命令
    gimp的python控制台生成UI代码
    three.js(六) 地形法向量生成
    mysql 主从复制配置
    Three.js(九)perlin 2d噪音的生成
    three.js(五) 地形纹理混合
    mongodb 复制
    pycparse python的c语法分析器
    ajax出现 所需的数据还不可用
  • 原文地址:https://www.cnblogs.com/mqingqing123/p/14235143.html
Copyright © 2020-2023  润新知