Forum How do I...?

Preview before create PDF

MiroMichail
Hello, do Prince have any decision to show preview before PDF will generated?
mikeday
Prince 11 can convert the document to one or more image files, eg.
prince --raster-output=first.jpg --raster-pages=1 doc.html
MiroMichail
But if i need to know how many pages will be in pdf ?
mikeday
You can render all pages like this:
prince --raster-output=page%d.jpg --raster-pages=all doc.html

This will create page1.jpg, page2.jpg, etc.
Or you can specify page%03d.jpg to get page001.jpg, page002.jpg, etc.
MiroMichail
And how i can get count of pages before render?
mikeday
You can capture it with this JavaScript:
Prince.addEventListener("complete", function() {
    Log.data("total-page-count", Prince.pageCount);
}, false);

Which you can apply with --script=pages.js.
quiredan
Sorry to hijack someone else's thread, but are you saying that the raster output feature can be used to create a "preview" of the PDF output?
mikeday
Yes, of any individual page or all of the pages.