PdfReader reader = new PdfReader(@"C:\WorkSpace\1.pdf"); int count = reader.NumberOfPages;
TextField fieldDate = new TextField(stamp.Writer, new iTextSharp.text.Rectangle(105, 100, 240, 125), "date"); fieldDate.BackgroundColor= BaseColor.WHITE;fieldDate.BorderWidth= 1; fieldDate.BorderColor= BaseColor.BLACK;fieldDate.BorderStyle= 4; fieldDate.FontSize = 11f;
Chunk cname = new Chunk("Date:", FontFactory.GetFont("Futura", 16f,new BaseColor(170,64,0)));
Phrase pname = new Phrase(cname);
PdfContentByte over = stamp.GetOverContent(count);
ColumnText.ShowTextAligned(over, Element.ALIGN_CENTER, pname, 400, 420, 0);
public static void AddTextField()
{
PdfReader reader = new PdfReader(@"C:\WorkSpace\1.pdf");
FileStream out1 = new FileStream(@"C:\WorkSpace\2.pdf", FileMode.Create, FileAccess.Write);
PdfStamper stamp = new PdfStamper(reader, out1);
//获得pdf总页数
int count = reader.NumberOfPages;
TextField fieldDate = new TextField(stamp.Writer, new iTextSharp.text.Rectangle(105, 100, 240, 125), "date");
fieldDate.BackgroundColor = BaseColor.WHITE;
fieldDate.BorderWidth = 1;
fieldDate.BorderColor = BaseColor.BLACK;
fieldDate.BorderStyle = 4;
fieldDate.FontSize = 11f;
TextField fieldSign = new TextField(stamp.Writer, new iTextSharp.text.Rectangle(430, 100, 530, 125), "sign");
fieldSign.BackgroundColor = BaseColor.WHITE;
fieldSign.BorderWidth = 1;
fieldSign.BorderColor = BaseColor.BLACK;
fieldSign.BorderStyle = 4;
fieldSign.FontSize = 11f;
Chunk cname = new Chunk("Date:", FontFactory.GetFont("Futura", 16f,new BaseColor(170,64,0)));
Chunk ctitle = new Chunk("User Sign:", FontFactory.GetFont("Futura", 16f, new BaseColor(0, 128, 128)));
Phrase pname = new Phrase(cname);
Phrase ptitle = new Phrase(ctitle);
//PdfContentBye类,用来设置图像和文本的绝对位置
PdfContentByte over = stamp.GetOverContent(count);
ColumnText.ShowTextAligned(over, Element.ALIGN_CENTER, pname, 400, 420, 0);
ColumnText.ShowTextAligned(over, Element.ALIGN_CENTER, ptitle, 400, 350, 0);
stamp.AddAnnotation(fieldDate.GetTextField(), count);
stamp.AddAnnotation(fieldSign.GetTextField(), count);
stamp.FormFlattening = true;
stamp.Close();
}
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有