We’re evaluating using PD4ML to go from HTML to PDF for a thermal receipt printer application. Everything seems to be working fine except that we’d like the page height to be automatically set based on the content/body in the source HTML. If we force a longer page break (eg. java -Xmx512m -Djava.awt.headless=true -cp ./pd4ml_demo.jar Pd4Cmd ‘file:./testprintutf8.html’ 200 200×750 -ttf . -insets 0,0,0,0,pt -out testprintutf8.rtf) we get a whole bunch of wasted paper feed at the end of each “page”. How can we get the page height to be set automatically based on the source HTML content?
In order to predict a document height for particular conversion conditions, you may perform a fake conversion run and collect the conversion statistics: http://pd4ml.com/cookbook/pd4ml_conversion_status.htm
You are interested in PD4Constants.PD4ML_DOCUMENT_HEIGHT_PX value. After the HTML doc height is known, you may adjust PDF page height proportionally.
Also it is important to distinguish document dimensions in typographic points (“200×750” in your command line) and HTML document height and width, measured in screen pixels.