- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在研究使用 iText 5.4.5 合并一些输入 PDF 文档的任务。输入文档可能包含也可能不包含 AcroForms,我也想合并表单。
我正在使用找到的示例 pdf 文件 here这是代码示例:
public class TestForms {
@Test
public void testNoForms() throws DocumentException, IOException {
test("pdf/hello.pdf", "pdf/hello_memory.pdf");
}
@Test
public void testForms() throws DocumentException, IOException {
test("pdf/subscribe.pdf", "pdf/filled_form_1.pdf");
}
private void test(String first, String second) throws DocumentException, IOException {
OutputStream out = new FileOutputStream("/tmp/out.pdf");
InputStream stream = getClass().getClassLoader().getResourceAsStream(first);
PdfReader reader = new PdfReader(new RandomAccessFileOrArray(
new RandomAccessSourceFactory().createSource(stream)), null);
InputStream stream2 = getClass().getClassLoader().getResourceAsStream(second);
PdfReader reader2 = new PdfReader(new RandomAccessFileOrArray(
new RandomAccessSourceFactory().createSource(stream2)), null);
Document pdfDocument = new Document(reader.getPageSizeWithRotation(1));
PdfCopy pdfCopy = new PdfCopy(pdfDocument, out);
pdfCopy.setFullCompression();
pdfCopy.setCompressionLevel(PdfStream.BEST_COMPRESSION);
pdfCopy.setMergeFields();
pdfDocument.open();
pdfCopy.addDocument(reader);
pdfCopy.addDocument(reader2);
pdfCopy.close();
reader.close();
reader2.close();
}
}
NullPointerException
。PdfCopyFields
执行此操作,但现在已弃用它,转而使用 PdfCopy
中的 boolean 标志 mergeFields
,这是正确的吗?该标志上没有 javadoc,而且我找不到有关它的文档。最佳答案
我们正在使用 PdfCopy 合并不同的文件,某些文件可能有字段。我们使用版本5.5.3.0。代码很简单,看起来工作正常,但有时结果文件无法打印!我们的代码:
Public Shared Function MergeFiles(ByVal sourceFiles As List(Of Byte())) As Byte()
Dim document As New Document()
Dim output As New MemoryStream()
Dim copy As iTextSharp.text.pdf.PdfCopy = Nothing
Dim readers As New List(Of iTextSharp.text.pdf.PdfReader)
Try
copy = New iTextSharp.text.pdf.PdfCopy(document, output)
copy.SetMergeFields()
document.Open()
For fileCounter As Integer = 0 To sourceFiles.Count - 1
Dim reader As New PdfReader(sourceFiles(fileCounter))
reader.MakeRemoteNamedDestinationsLocal()
readers.Add(reader)
copy.AddDocument(reader)
Next
Catch exception As Exception
Throw exception
Finally
If copy IsNot Nothing Then copy.Close()
document.Close()
For Each reader As PdfReader In readers
reader.Close()
Next
End Try
Return output.GetBuffer()
End Function
关于java - PdfCopy 中的 iText mergeFields 创建无效的 pdf,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21189981/
我目前正在尝试迭代现有的 PDF 并使用 OnPageEnd 事件在每个页面上标记一些页脚文本,如 iText 文档中所述,Chapter 5: Table, cell, and page event
我正在尝试使用 ItextSharp 中的 PdfSmartCopy,但我在 C# 中找不到任何相关示例。 我的想法是我有一个包含表单字段的 pdf,并且这些字段将 700kb 添加到 pdf 文档的
我正在使用 iText(特别是 iTextSharp 4.1.6),我想通过组合现有 PDF 中的页面来创建 PDF,同时插入从图像创建的新页面。 我分别使用 PdfCopy 和 PdfWriter
当我使用 pdfcopy 创建 pdf 时,返回到客户端的 pdf 为空或只有 1 行,但是当我在资源管理器上打开它时,它包含我合并的所有数据,我使用 itextsharp 5 这是我进行合并的地方:
我有一个在 Spring Boot 应用程序中使用的模板 pdf 文件。我需要根据每个请求的用户输入更新此模板中的值。另外,在请求中,我将获得多个 pdf 文件,我需要将这些文件与更新的文件(最终 p
我需要将多个 pdf(每个单页)添加到我的主 pdf。这些需要添加到特定页码之后,而不是附加到末尾。 我该怎么办 1:在特定页码处合并pdf 2:pdfCopy.AddDocument 不可用。我已经
我正在研究使用 iText 5.4.5 合并一些输入 PDF 文档的任务。输入文档可能包含也可能不包含 AcroForms,我也想合并表单。 我正在使用找到的示例 pdf 文件 here这是代码示例:
iText 实际操作的第 6 章介绍了如何使用 PdfSmartCopy/PdfCopy 复制页面: public void addDataSheets(PdfCopy copy) t
我想合并两个 PDF 文件(仅选定的页面)并向它们添加自定义页眉和页脚。 因此我不使用 PdfCopy 只是复制页面而不改变它。我使用 PdfWriter。 问题是我不知道如何使用 PdfWriter
我正在使用 iText 一遍又一遍地标记 PDF 表单,并尝试将生成的单页 pdf 编译成一个 pdf,在 RAM 中有许多页面,并在 http 响应中返回它。无论我做什么,都会出现无效的 PDF。如
这个问题已经有答案了: Is it possible to merge several pdfs using iText7 (7 个回答) 已关闭 4 年前。 我正在尝试在 java 项目中连接两个不
在 iText 5.4.4 的发行说明中,它说: From now on you can now merge forms and preserve the tagged PDF structure w
我是一名优秀的程序员,十分优秀!