如果您有纸质表格,您可以扫描它,然后使用像 CutePDF 这样的程序将其转换为 PDF 表格。接下来,创建您希望能够填写的字段(通过拖动矩形),命名它们,然后保存表单。iTextSharp 是一个 C# 库,可让您以编程方式填写表单字段。
例子:
//Replace with path to the form
var pdfFormLocation = "C:\\pdfForm.pdf";
//Adjust below path to a temp location
var pdfPath = String.Format("C:\\temp\\{0}", Guid.NewGuid().ToString());
File.Copy(pdfFormLocation, pdfPath, true);
var reader = new PdfReader(pdfPath);
var output = new FileStream();
var stamper = new PdfStamper(reader, output);
//the form field names can be a little hairy
stamper.AcroFields.SetField("topmostSubform[0].Page1[0].f1_01_0_[0]", "Your Name");
//make the form no longer editable
stamper.FormFlattening = true;
stamper.Close();
reader.Close();
//now you can go print this file from pdfPath
链接:
iTextSharp
CutePDF