【问题标题】:Itext PDF remove footer from existing pdf and create new pdfItext PDF 从现有 pdf 中删除页脚并创建新 pdf
【发布时间】:2021-01-21 09:13:27
【问题描述】:

我有一个现有的 PDF,我需要从每个页面的 PDF 中删除页脚。

我从 PDF 中获取所有页面,但无法从 PDF 中删除页脚。

我使用的是 iText 5.5.0 版。

Document document = null;
PdfCopy writer = null;
PdfReader reader = new PdfReader("input.pdf");
int n = reader.getNumberOfPages();
outFile = "output.pdf";
document = new Document();
writer = new PdfCopy(document, new FileOutputStream(outFile));
document.open();

for (int j = 0; j < n; j++) {                               
    
    PdfImportedPage page = writer.getImportedPage(reader, j);
    writer.addPage(page);
}

document.close();
writer.close();

如何从这个 input.pdf 文件中删除页脚并创建一个新的 output.pdf 文件?

【问题讨论】:

    标签: java pdf itext


    【解决方案1】:

    您可以使用 pdfSweep 删除文本。看例子 https://kb.itextpdf.com/home/it7kb/examples/removing-content-with-pdfsweep

    或检查已经给出的解决方案

    How to remove headers and footers from PDF file using iText in Java

    Issue in Removing Header and Footer in PDF using iText PDF

    Remove Footer from PDF using IText5.0

    我的建议是首先避免创建页脚,这样您就可以避免仅仅为了删除页脚而重新创建 pdf

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-01-28
      • 1970-01-01
      • 1970-01-01
      • 2017-04-13
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多