You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@pdfbox.apache.org by John Liston <li...@asconline.com> on 2016/10/25 19:39:08 UTC
How to remove buttons from a PDF
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?
Thanks,
John Liston
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: users-help@pdfbox.apache.org
Re: How to remove buttons from a PDF
Posted by Tilman Hausherr <TH...@t-online.de>.
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: users-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: users-help@pdfbox.apache.org