Am 25.10.2016 um 21:39 schrieb John Liston:
How do I use PDFBox to remove the "About" etc. buttons from the top edge of
this PDF, so that I may then view it without them?
https://www.dropbox.com/s/781cgwn4m2grose/PAMV1A.pdf?dl=0
I tried PDDocument.getDocumentCatalog().getAcroForm().flatten() without
success. How can I get rid of the buttons?
This removes the cmdAbout button only. You'd need to modify the code so
that it deletes all that starts with "cmd".
public class RemoveAnnot
{
public static void main(String[] args) throws IOException
{
PDDocument doc = PDDocument.load(new File("PAMV1A.pdf"));
List<PDAnnotation> annotations = doc.getPage(0).getAnnotations();
for (int i = 0; i < annotations.size(); ++i)
{
PDAnnotation ann = annotations.get(i);
String s = ann.getCOSObject().getString(COSName.T);
if ("cmdAbout".equals(s))
{
annotations.remove(ann);
break;
}
}
doc.save(new File("PAMV1A-new.pdf"));
doc.close();
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]