将PDF与PDFSharp合并会丢失表单字段 [英] Combining PDFs with PDFSharp losing form fields

查看:294
本文介绍了将PDF与PDFSharp合并会丢失表单字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用PDFSharp和此代码(我发现此处):

I am attempting to concatenate two created PDF files to a new PDF using PDFSharp and this code (which I found 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时,表单字段显示为空白.

The second PDF has form fields which I fill out, also using PDFSharp. The issue I am running into is that when combined into a new PDF, the form fields show up blank.

在创建并保存第二个PDF之后,我已经打开了它,并且表单字段显示的文字也很好.

I have opened up the second PDF after it is created and saved, and the form fields show up with the text just fine.

我是否丢失了某些东西,或者PDFSharp在此问题上是否存在某种错误?在我看来,如果我可以很好地打开和查看PDF,则将它们组合起来应该没有任何问题.

Am I missing something, or does PDFSharp have some sort of bug in regards to this issue? It seems to me that if I can open and view the PDF just fine, there shouldn't be any problems with combining them.

提前感谢您的帮助!

推荐答案

PDFsharp不完全支持表单字段.我没有对此进行检查,但是将PDF文件与填充的表单字段组合在一起时可能会出现错误.我们将继续维护和改进PDFsharp,但没有改善表单域处理的计划.

PDFsharp does not fully support form fields. I didn't examine this, but there could be a bug when combining PDF files with filled form fields. We continue to maintain and improve PDFsharp, but there are no plans to improve the handling of form fields.

如果您以其他方式尝试它可能会起作用:打开第二个PDF进行修改,打开第一个PDF进行导入,然后在第二个文件的开头添加第一个文件的页面(如果两个文件包含填写的表单字段).
如果必须保留原始文件,请先创建第二个文件的副本.

Maybe it'll work if you try it a different way: open the second PDF for modification, open the first for import and add the pages of the first file at the beginning of the second file (this may not work if both files contain filled form fields).
Create a copy of the second file before you do that if you have to keep the original file.

这篇关于将PDF与PDFSharp合并会丢失表单字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆