HTML to PDF converter for Java and .NET

<< back

PDF dynamic format change

PD4ML page format output basics explained here

There are situations, when the initial page format conversion parameters need to be changed to reflect content specifics. For example a wide table among "normal" document text. An adjusting of htmlWidth to match the table width is a solution, but (1) it scales down the entire document content and (2) makes text lines longer if they are not limited by a block element box. Both negatively impact a document readability.

A better solution would be to change pageFormat or htmlWidth for particular pages only.

1. A wide portion of document is slightly wider than the main content.

In the case probably a dynamic change from portrait to landscape page orientation is a solution. The benefit of the approach is that it does not impact the actual HTML-to-PDF scale factor.

It can be achieved by a parameterized page break tag:

... main content ...
<pd4ml:page.break pageFormat="rotate">
... wide data ...
<pd4ml:page.break pageFormat="reset">
... main content (continued) ...


2. Wide content portion is slightly wider the main document content, but page orientation change still gives not enough horizontal space. In the case probably an additional slight scaling down of the content helps.

It can be achieved by a temporal impact to the actual htmlWidth value. Making it a bit greater scales the content down correspondingly.

... main content, htmlWidth is 600 ...
<pd4ml:page.break pageFormat="rotate" htmlWidth="700">
... wide data ...
<pd4ml:page.break pageFormat="reset" htmlWidth="reset">
... main content (continued) ...

This time there is enough space for 6 columns, however the content is scaled down.


3. Wide content portion significantly wider the main document layout.

The best solution would be to re-think the document layout and the way the data organized. If it is not possible, probably a solution would be to change page format to a greater one: for instance from A4 to A3 or to an arbitrary dimensions (WxH in typographical points), hoping the target printer is clever enough to print the oversized formats as stitchable segments

<pd4ml:page.break pageFormat="A3">
<pd4ml:page.break pageFormat="2000x1000">
Hopefully a playing with pageFormat and htmlWidth attributes will help you to produce an acceptable document layout yet readable in printed form.


Copyright ©2004-17 zefer|org. All rights reserved. Bookmark and Share