I have a huge pdf containing >1000 pages, need to edit existing text, offcourse it is added by me using pdfbox addtext to each page example ... the text font size was very big text runs out of page.. now i want to decrease the size of font so that it will be within page limits... or i can clear the existing text and replace a the same text with new font...
1 Answers
1
votes
credits to Tilman Hausherr for answer
If you used the code you linked to, then you will find the "added message" in the content stream array, as the second last item. PDPage.getCosObject().getItem(COSName.Contents) and save the file.
public void removeStamp(File src) throws IOException {
PDDocument doc = PDDocument.load(src);
PDPageTree pages = doc.getPages();
for (PDPage page : pages) {
COSArray array = ((COSArray) page.getCOSObject().getItem(COSName.CONTENTS));
array.remove(array.size() - 1);
}
doc.save(src);
}
PDPage.getCosObject().getItem(COSName.Contents)) and save the file. Please link to such a file (maybe create one that is representative - have a look at it with PDFDebugger too). - Tilman Hausherr