On this page
PreviewOptions class is used to manage preview generation process - specify desired page numbers, image format etc.
The following are the steps to generate document preview with GroupDocs.Comparison API:
- Create new instance of Comparer class and pass source document path as a constructor parameter.
- Add target document(s) to comparison using add method.
- Source and Targets properties of Comparer object allows to access source and target documents and provides generatePreview method.
- Instantiate the PreviewOptions object with:
- callback for each page stream creation (see event handler CreatePageStream);
- image preview format - PNG / JPG / BMP,
- page numbers to process;
- custom size of preview images (if needed).
Here a PreviewOptions class main properties:
- CreatePageStream - Callback which defines method to create output page preview stream;
- ReleasePageStream - Callback which defines method to remove output page preview stream. This is can be used when need advanced control for resources handling.
- Width - Preview image width. This property used when need customize output image width;
- Height - Preview image height. This property used when need customize output image height;
- PageNumbers - Page numbers that will be previewed;
- PreviewFormat - Gets or sets the preview image format which provides 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.
In some cases it may be useful to set specific image size during document pages preview generation. For example, to generate document pages thumbnails - small images that is a compressed preview image of the original image that is used as a placeholder. The main advantage of such thumbnail images is their reduced file size compared to the original page image.
The following code snippet demonstrates how to set specific size for preview images.
NoteNOTE: This feature is not supported for WordProcessing documents yet.
By default, after generating and rendering document page preview image stream will be immediately disposed. However, there is an ability to implement custom method for handling this operation.
You may easily run the code above and see the feature in action in our GitHub examples:
- GroupDocs.Comparison for Java examples, plugins, and showcase
- GroupDocs.Comparison for .NET examples, plugins, and showcase
- Document Comparison for Java App Dropwizard UI Modern Example
- Document Comparison for Java Spring UI Example
- Document Comparison for .NET MVC UI Example
- Document Comparison for .NET App WebForms UI Modern Example
Along with full-featured Java library we provide simple, but powerful free Apps. You are welcome to compare your DOC or DOCX, XLS or XLSX, PPT or PPTX, PDF, EML, EMLX, MSGand other documents with free to use online GroupDocs Comparison App.
Was this page helpful?
Any additional feedback you'd like to share with us?
Please tell us how we can improve this page.
Thank you for your feedback!
We value your opinion. Your feedback will help us improve our documentation.