The PDF file format is very complex and contains many features to boost interactivity. One such feature is the ability for PDF files to contain annotations which allow you to draw over, highlight, label, and comment on documents without modifying the existing content.
While this is a useful feature, you may want to remove annotations from documents, for example to remove text highlighting that has been done with annotations.
Our PDF toolkit JPedal allows you to remove annotations from PDF files with only a few lines of code!
To do this you need to download a JPedal jar, then run the following code:
final PdfManipulator pdf = new PdfManipulator();
pdf.loadDocument(new File("inputFile.pdf"));
pdf.removeAnnotations();
pdf.apply();
pdf.writeDocument(new File("outputFile.pdf"));
pdf.closeDocument();
You may also want to consider other sanitization options to clean your documents.
Resources
You can download a trial jar from our website.
Learn more about the PDF Manipulator API.
We can help you better understand the PDF format as developers who have been working with the format for more than 2 decades!