We're sorry GroupDocs doesn't work properply without JavaScript enabled.

Free Support Forum - groupdocs.com

Why no ViewInfoOptions.forPdfView() method?

I am converting documents to PDF and implementing pagination to reduce the response time in a client server application.
I couldn’t find any API to get total number of pages of the output document as available from ViewInfoOptions.forHtmlView() method. Without knowing total number of pages I can’t implement pagination. Is there any way to get the document info for PDF output?


We have considered rendering to PDF as a feature for printing a document. In case you’re using PDF to display it we can add ViewInfoOptions.forPdfView() in the future versions of GroupDocs.Viewer. As a temporary workaround you can use the following code to get page count in the output PDF document

 PngViewOptions viewOptions = new PngViewOptions();
 ViewInfoOptions viewInfoOptions = ViewInfoOptions.fromPngViewOptions(viewOptions);
 Viewer viewer = new Viewer(filename);
 ViewInfo viewInfo = viewer.getViewInfo(viewInfoOptions);
 System.out.println("Pages count in PDF: " + viewInfo.getPages().size());

when you set viewOptions.setExtractText(true); the document is rendered to PDF, so the number of pages is actually a number of pages in a PDF document.

We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.

Issue ID(s): VIEWERJAVA-3078

You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.

Thank you for quick response, it worked.


You’re welcome!