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():
PD4PageMark header = new PD4PageMark();
header.setAreaHeight( -1 ); // autocompute
header.setHtmlTemplate( "$[total]<hr>" );
pd4ml.setPageHeader( header );
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.