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();
viewOptions.setExtractText(true);
ViewInfoOptions viewInfoOptions = ViewInfoOptions.fromPngViewOptions(viewOptions);
Viewer viewer = new Viewer(filename);
ViewInfo viewInfo = viewer.getViewInfo(viewInfoOptions);
viewer.close();
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.
@shiva.k
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.