将 PDF 与 PDFSharp 丢失表单字段相结合

sǝɯ*_*ɯɐſ 5 .net merge pdfsharp

我正在尝试使用 PDFSharp 和此代码(我在此处找到)将两个创建的 PDF 文件连接到一个新的 PDF :

        // 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);
Run Code Online (Sandbox Code Playgroud)

第二个 PDF 有我填写的表单字段,也使用 PDFSharp。我遇到的问题是,当合并到一个新的 PDF 中时,表单字段显示为空白。

在创建并保存第二个 PDF 后,我打开了它,表单字段显示的文本很好。

我是否遗漏了什么,或者 PDFSharp 在这个问题上是否有某种错误?在我看来,如果我可以很好地打开和查看 PDF,那么合并它们应该没有任何问题。

在此先感谢您的帮助!

Je *_*not 1

PDFsharp 不完全支持表单字段。我没有检查这一点,但将 PDF 文件与填写的表单字段组合时可能会出现错误。我们将继续维护和改进 PDFsharp,但没有计划改进表单字段的处理。

如果您尝试不同的方式,也许它会起作用:打开第二个 PDF 进行修改,打开第一个进行导入,然后将第一个文件的页面添加到第二个文件的开头(如果两个文件都包含填充的内容,则这可能不起作用)表单字段)。
如果必须保留原始文件,请在执行此操作之前创建第二个文件的副本。