|
域名 |
类名 |
| 文本域 | PdfTextBoxField |
| 签名域 | PdfSignatureField |
| 复选框 | PdfCheckBoxField |
| 组合框 | PdfComboBoxField |
| 列表框 | PdfListBoxField |
| 按钮 | PdfRadioButtonListField(单选按钮) PdfButtonField (普通按钮) |
//创建PDF文档
PdfDocument pdf = new PdfDocument();
//添加一个新页面
PdfPageBase page = pdf.Pages.Add(PdfPageSize.A4, new PdfMargins());
//添加文本到页面
PdfTrueTypeFont font = new PdfTrueTypeFont(new Font("Arial Unicode MS", 10f), true);
page.Canvas.DrawString("年龄:", font, PdfBrushes.DeepSkyBlue, 10, 50);
//创建文本域并指定文本域的名称
PdfTextBoxField textbox = new PdfTextBoxField(page, "Age");
//设置文本域的大小、位置、字体
textbox.Bounds = new RectangleF(40, 50, 50, 12);
textbox.Font = font;
//添加文本域到文档
pdf.Form.Fields.Add(textbox);
//保存文档
pdf.SaveToFile("Fields.pdf");
[img]http://files.jb51.net/file_images/article/201703/2017031710463436.png[/img]
//设置边框 textbox.BorderWidth = 0.75f; textbox.BorderStyle = PdfBorderStyle.Solid; textbox.BorderColor = Color.Black; //设置背景色 textbox.BackColor = Color.Yellow; //设置字体颜色 textbox.ForeColor = Color.Red; //设置字体排列方式 textbox.TextAlignment = PdfTextAlignment.Center;
|
描述 |
示例 | JavaScript | 方法 |
| Date | 01/31/2008 | AFDate_FormatEx("mm/dd/yyyy"); AFDate_KeystrokeEx("mm/dd/yyyy"); | GetDateFormatString("mm/dd/yyyy"); GetDateKeystrokeString("mm/dd/yyyy"); |
| Date | 1/31/2008 | AFDate_FormatEx("m/d/yyyy"); AFDate_KeystrokeEx("m/d/yyyy"); | GetDateFormatString("m/d/yyyy"); GetDateKeystrokeString("m/d/yyyy"); |
| Zip code | 12345 | AFSpecial_Format(0); AFSpecial_Keystroke(0); | GetSpecialFormatString(0); GetSpecialKeystrokeString(0); |
| Zip+4 | 12345-1234 | AFSpecial_Format(1); AFSpecial_Keystroke(1); | GetSpecialFormatString(1); GetSpecialKeystrokeString(1); |
| Phone number | (123) 456-7890 | AFSpecial_Format(2); AFSpecial_Keystroke(2); | GetSpecialFormatString(2); GetSpecialKeystrokeString(2); |
| Money | $12,345.00 -$12,345.00 | AFNumber_Format(2, 0, 0, 0, "$", true); AFNumber_Keystroke(2, 0, 0, 0, "$", true); | GetNumberFormatString(2, 0, 0, 0, "$", true); GetNumberKeystrokeString(2, 0, 0, 0, "$", true); |
| Validate | 1≤input value≤10 | AFRange_Validate(true,1,true,10) | GetRangeValidateString(true, 1, true, 10); |
//指定输入数据在1-100之间 string js = PdfJavaScript.GetRangeValidateString(true, 1, true, 100); PdfJavaScriptAction jsAction = new PdfJavaScriptAction(js); textbox.Actions.Validate = jsAction;
//创建签名域并指定域名 PdfSignatureField signaturefield = new PdfSignatureField(page, "Signature"); //设置域的边框 signaturefield.BorderWidth = 1.0f; signaturefield.BorderStyle = PdfBorderStyle.Solid; signaturefield.BorderColor = new PdfRGBColor(System.Drawing.Color.Black); //设置高亮模式 signaturefield.HighlightMode = PdfHighlightMode.Outline; //设置大小与位置 signaturefield.Bounds = new RectangleF(40, 150, 200, 100); //将签名域添加到页面 pdf.Form.Fields.Add(signaturefield);
//加载PDF文档
PdfDocument pdf = new PdfDocument();
pdf.LoadFromFile("Fields.pdf");
//获取第一页
PdfPageBase page = pdf.Pages[0];
//获取文档的所有域
PdfFormWidget form = pdf.Form as PdfFormWidget;
//填充第一个文本域
PdfTextBoxFieldWidget textboxField = form.FieldsWidget[0] as PdfTextBoxFieldWidget;
textboxField.Text = "25";
//填充第二个签名域
PdfSignatureFieldWidget signatureField = form.FieldsWidget[1] as PdfSignatureFieldWidget;
String pfxPath = @"gary.pfx";
PdfCertificate digi = new PdfCertificate(pfxPath, "123456");
PdfSignature signature = new PdfSignature(pdf, page, digi, "demo", signatureField);
signature.IsTag = true;
signature.DigitalSigner = "Gary";
signature.ConfigGraphicType = ConfiguerGraphicType.TextSignInformation;
//保存文档
pdf.SaveToFile("Fill.pdf");
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有