Render specific pages
Leave feedback
You can render part of the document pages only. You can specify a list of the document pages in the following ways:
To specify pages as the View.view() method parameters, follow these steps:
- Instantiate the Viewer object.
- Instantiate the HtmlViewOptions (or the JpgViewOptions, or the PngViewOptions, or the PdfViewOptions) object.
- Call the View.view() method. Specify the page numbers as the last parameters.
The following code snippet shows how to render the first and third pages of a document:
import com.groupdocs.viewer.Viewer;
import com.groupdocs.viewer.options.HtmlViewOptions;
// ...
try (Viewer viewer = new Viewer("sample.docx")) {
HtmlViewOptions viewOptions = HtmlViewOptions.forEmbeddedResources();
viewer.view(viewOptions, 1, 3);
}
To specify pages by using an array, follow these steps:
- Instantiate the Viewer object;
- Instantiate the HtmlViewOptions (or the JpgViewOptions, or the PngViewOptions, or the PdfViewOptions) object;
- Call the View.view() method. Specify the page numbers array as the second parameter.
The following code snippet shows how to render the 1st, 2nd, and 4th pages of a document:
import com.groupdocs.viewer.Viewer;
import com.groupdocs.viewer.options.HtmlViewOptions;
// ...
int[] pageNumbers = new int[] { 1, 2, 4 };
try (Viewer viewer = new Viewer("sample.docx")) {
HtmlViewOptions viewOptions = HtmlViewOptions.forEmbeddedResources();
viewer.view(viewOptions, pageNumbers);
}
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.