我正在尝试使用 PDFSharp 和此代码将两个创建的 PDF 文件连接到一个新的 PDF(我发现here):
// Open the output document
PdfDocument outputDocument = new PdfDocument();
// Iterate files
foreach (string file in files)
{
// Open the document to import pages from it.
PdfDocument inputDocument = PdfReader.Open(file, PdfDocumentOpenMode.Import);
// Iterate pages
int count = inputDocument.PageCount;
for (int idx = 0; idx < count; idx++)
{
// Get the page from the external document...
PdfPage page = inputDocument.Pages[idx];
// ...and add it to the output document.
outputDocument.AddPage(page);
}
}
// Save the document...
string filename = Path.Combine(this.tempFolder, "MyPDF.pdf");
outputDocument.Save(filename);
第二个 PDF 包含我填写的表单字段,也使用 PDFSharp。我遇到的问题是,当合并到新的 PDF 中时,表单字段显示为空白。
创建并保存第二个 PDF 后,我打开了它,表单字段与文本一起显示得很好。
我是否遗漏了什么,或者 PDFSharp 在这个问题上是否有某种错误?在我看来,如果我可以很好地打开和查看 PDF,那么合并它们应该不会有任何问题。
在此先感谢您的帮助!
PDFsharp 不完全支持表单字段。我没有检查这一点,但将 PDF 文件与填写的表单字段组合时可能会出现错误。我们将继续维护和改进 PDFsharp,但没有计划改进表单字段的处理。
如果您尝试不同的方式,也许它会起作用:打开第二个 PDF 进行修改,打开第一个进行导入,然后在第二个文件的开头添加第一个文件的页面(如果两个文件都包含填充的内容,这可能不起作用)表单字段)。
如果必须保留原始文件,请在执行此操作之前创建第二个文件的副本。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)