HTML to PDF / DOCX / RTF Java converter library › Forums › PD4ML v3 Archived Forums (Read Only) › PD4ML Tips & Tricks › How to get Number of pages in a pdf file › Re: Re: How to get Number of pages in a pdf file
If you know a number of pages of the existent PDF, you may add it as a correction to the final $[total] value with header.setInitialPageNumber():
[language=java:84n7vipe]PD4PageMark header = new PD4PageMark();
header.setInitialPageNumber(10);
header.setAreaHeight( -1 ); // autocompute
header.setHtmlTemplate( “$[total]
” );
pd4ml.setPageHeader( header );[/language:84n7vipe]
If a number of pages is not known for a particular case, you would need to count it with a third-party tool. Currently PD4ML Web implements the needed PDF page count functionality ( http://pd4ml.com/pd4ml_web.htm ), but the API is not exposed and documented yet.
We plan to include the new PDF manipulation module (PDF analyze, merge etc) to the main branch of PD4ML with a forthcoming release.