Generate document pages preview

GroupDocs.Annotation allows to generate document page previews using generatePreview method of a Document class.
PreviewOptions class is used to manage preview generation process - specify desired page numbers, image format etc.

Here are the steps to generate document preview with GroupDocs.Annotation API:

GroupDocs.Annotation provides an ability to choose between image quality and size. BMP format should be used for the best image quality. JPG format will be useful in case of strict requirements to image size - it produces smallest image size (and faster loading image previews), but with lower quality than BMP. By default PNG format is selected - which is a golden mean between image quality and size.

The following code snippet demonstrates how to generate document previews.

Get document page previews 

Annotator annotator = new Annotator("input.pdf");
PreviewOptions previewOptions = new PreviewOptions("C://Output//GenerateDocumentPagesPreview_{0}.png");
previewOptions.setPreviewFormat(PreviewFormats.PNG);
previewOptions.setPageNumbers(new int[]{1, 2});
annotator.getDocument().generatePreview(previewOptions);
annotator.dispose();

More resources

Advanced Usage Topics

To learn more about document annotating features, please refer to the advanced usage section.

GitHub Examples

You may easily run the code above and see the feature in action in our GitHub examples:

Free Online App

Along with full-featured Java library we provide simple, but powerful free Apps.
You are welcome to annotate your PDF, DOC or DOCX, XLS or XLSX, PPT or PPTX, PNG and other documents with free to use online GroupDocs Annotation App.