pdfbox-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Tilman Hausherr <THaush...@t-online.de>
Subject Re: How to remove buttons from a PDF
Date Wed, 26 Oct 2016 18:32:54 GMT
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))
         doc.save(new File("PAMV1A-new.pdf"));

To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: users-help@pdfbox.apache.org

View raw message