简体   繁体   中英

Itext PDF remove footer from existing pdf and create new pdf

I have an existing PDF and I need to remove the footer from the PDF on every page.

I fetch all pages from PDF but I am not able to remove the footer from the PDF.

I am using iText version 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();

How can I remove the footer from this input.pdf file and create a new output.pdf file?

You can use pdfSweep to delete text. See the example https://kb.itextpdf.com/home/it7kb/examples/removing-content-with-pdfsweep

OR Check already given solutions

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

My suggestion is to avoid creating a footer in the first place so that you can avoid recreating the pdf just for removing the footer

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM