# Remove annotations This topic describes how to remove annotations from PDF file using the GroupDocs.Viewer Java API. If the output PDF file contains annotations, you can remove them to reduce the file size. To remove annotations, set the [setRemoveAnnotations](https://reference.groupdocs.com/viewer/java/com.groupdocs.viewer.options/pdfoptimizationoptions/#setRemoveAnnotations-boolean-) to `true`. The following code snippet shows how to remove annotations from the file: {{< tabs "Example1">}} {{< tab "Java" >}} ```java try (Viewer viewer = new Viewer("sample.docx")) { PdfViewOptions viewOptions = new PdfViewOptions(); viewOptions.setPdfOptimizationOptions(new PdfOptimizationOptions()); viewOptions.getPdfOptimizationOptions().setRemoveAnnotations(true); viewer.view(viewOptions); } ``` {{}} {{}} The following image demonstrates the result: ![Remove annotations](https://docs.groupdocs.com/viewer/java/images/pdf-rendering/optimization/optimization-pdf-remove-annotations.png)