#28587

[language=java:3d8jgyrb]pd4ml.fitPageVertically();
pd4ml.adjustHtmlWidth();[/language:3d8jgyrb]

Both API calls are intended to automatically compute htmlWidth value, which fulfills specific requirements. The first call increases htmlWidth (in other words scales down the document layout) until the document content fits a single page.

The second call cares, that top right content edge of the page is not cut.

If you call both methods the results are not predictable.

If I understand you correctly you would like to fill a single page horizontally and vertically with the document content. Please correct if I am wrong. PD4ML does not support the mode. However there is a relatively simple (but resource consuming) method to achieve that.

You need to increase htmlWidth in small amounts and render the document into a ByteArrayOutputStream. After each iteration control a relation between resulting document width and height (until the aspect ratio is the same as of PD4Constants.LEDGER). You may request the document height and width (in pixels) with the calls:

[language=java:3d8jgyrb]pd4ml.render(url, byteArrayOutputStream);
System.out.println(“height: ” + (Long)pd4ml.getLastRenderInfo(PD4Constants.PD4ML_DOCUMENT_HEIGHT_PX));
System.out.println(“right edge: ” + (Long)pd4ml.getLastRenderInfo(PD4Constants.PD4ML_RIGHT_EDGE_PX));[/language:3d8jgyrb]