gpt4 book ai didi

java - 使用或不使用 Itext 的 PdfCopy 类连接 2 个不同的 pdf

转载 作者:行者123 更新时间:2023-12-02 09:51:09 25 4
gpt4 key购买 nike

我正在尝试在 java 项目中连接两个不同的 PDF 文件。

我在其他帖子中读到,最好的方法是使用 Itext 类“PdfCopy”,但奇怪的是,尽管我在 pom 中有 7.0.6 的 Itext 并且商业许可证。

是否有解释或其他方法可以在不使用 Itext 或其他外部库的情况下解决此任务?谢谢

最佳答案

I've read in others posts that the best way is to use Itext class "PdfCopy"

该建议适用于最高版本 5.x 的 iText。 iText 7.x 是对整个 iText api 的重大重新设计。特别是 Pdf*Copy* 类的功能已被移动。请尝试使用 PdfDocument.copyPagesTo

即如果您已将源文档加载到 PdfDocument 实例 doc1doc2 中,并且还有另一个可写的 PdfDocument 实例dest 您想要将这些源文档复制到其中,只需执行以下操作:

doc1.copyPagesTo(1, doc1.getNumberOfPages(), dest);
doc2.copyPagesTo(1, doc2.getNumberOfPages(), dest);

关于java - 使用或不使用 Itext 的 PdfCopy 类连接 2 个不同的 pdf,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56316201/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com