是否有使用Excel数据源填写PDF表单字段? (认为1000 pdf)
对于Excel中的每一行,请从模板“ myForm.pdf”创建一个新的空白pdf,并将Excel中各列的匹配值填写到“ myForm.pdf”中的字段,然后将其另存为“ myForm(i)。 pdf“
最后将所有pdf合并为一个PDF文档。
VBA或Adobe的Javascript很好,只要这个概念成立即可。如果不多的话,一些手动零件也可以。
显然没有太多的教程,所以我真的很感谢这里的任何专业知识。
谢谢!
如所承诺的:)
已尝试和测试
// Add reference to iTextSharp.dll. Freely available on the web. Free to use for non commercial applications.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.IO;
using System.Windows.Forms;
using iTextSharp;
using iTextSharp.text;
using iTextSharp.text.pdf;
using iTextSharp.text.xml;
namespace WindowsFormsApplication3
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
// Original Pdf
string PDFFile = "C:\\MyOriginalPDF.pdf";
// New Pdf
string newPDFFile = "C:\\NewPDFFILE.pdf";
PdfReader pdfReader = new PdfReader(PDFFile);
PdfStamper pdfStamper = new PdfStamper(pdfReader, new FileStream(newPDFFile, FileMode.Create));
AcroFields pdfFFields = pdfStamper.AcroFields;
// Fill PDF Form Fields
pdfFFields.SetField("FieldName1", "Value1");
pdfFFields.SetField("FieldName2", "Value2");
//
// And So on
// Use this to remove editting options by setting it to false
// To keep editing option leave it as TRUE
pdfStamper.FormFlattening = true;
// close the pdf
pdfStamper.Close();
}
}
}
编辑:要与C#中的Excel进行交互,建议您访问下面提到的链接。
主题:VB.NET和Excel
要将VB.Net代码转换为C#,请使用下面的链接:)
主题:将C#代码转换为VB.Net,反之亦然
链接:http://www.developerfusion.com/tools
让我知道您是否仍然被卡住,我们将从那里拿走...:)
更多编辑!!
受您的帖子的启发,我最终在博客上写了一篇文章。现在,您要做的就是复制整个代码并将其转换为C#并进行相应的更改以满足您的需求:)
主题:使用VB.Net从Excel文件从PDF表单字段填充/检索数据