zoukankan      html  css  js  c++  java
  • 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

  • 相关阅读:
    阿里云下Linux MySQL的安装
    protocol buffer相关
    Unity NGUI UIPanel下对粒子的剪裁
    NGUI中UILabel用省略号替换超出显示区域的内容
    Go交叉编译
    Unity3d使用未破解的TexturePacker
    编程之美 找出符合条件的整数
    算法导论~
    hadoop资料汇总(网上)
    SOE 中调用第三方dll
  • 原文地址:https://www.cnblogs.com/mqingqing123/p/14235143.html
Copyright © 2011-2022 走看看