Rendering pages to the same size as the size of pages in a source document

When viewing PDF documents in JPG and PNG formats by default GroupDocs.Viewer calculates output image size for better viewing quality. In case you want to make output JPG and PNG images to be the same size in pixels as the size of pages in a source PDF document GroupDocs.Viewer for Java provides a new option called setRenderOriginalPageSize(…) of the PdfOptions class. 

The following code snippet shows how to convert pages to the same size as the size of pages in a source document.

    try (Viewer viewer = new Viewer("sample.pdf")) {
        PngViewOptions viewOptions = new PngViewOptions();
        viewOptions.getPdfOptions().setRenderOriginalPageSize(true);
                       
        viewer.view(viewOptions);
    }

More resources

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 view Word, PDF, Excel, PowerPoint documents with free to use online GroupDocs Viewer App.