Forum How do I...?

How to scale a complete document

silviobierman
Hello all,

I am evaluating Prince and am very close to buying a license. There are some questions a need answered before that, however.

I want to convert dynamiically generated HTML reports to PDF. If they have been configured to be generated at a width of about 750px then an A4 portrait PDF document looks quite good. If however, the document was defined at a width of, say, 950px a part of it is clipped (or wrapped to the next page, I am not sure). What I would like is to apply a global scale factor (or preferably have Prince compute one itself) so that the document fits nicely onto the desired output format.
Is this possible?

Thanks in advance.

Kind regards,
Silvio Bierman
mikeday
Hi Silvio,

Dynamically scaling HTML documents to fit the width of a sheet of paper is a feature on our development roadmap (see "Shrink wide web pages down to fit the paper width"). It is not yet possible to do this in a general way for all HTML content, although it can be done for SVG.

Best regards,

Michael
kmmv
Alternatively, you can set up the paging to render landscape instead of portrait, which gives you another 87mm width-wise to work with:

@page {
  size: A4 landscape;
}


If possible, I've found other report types render better if you use percentages instead of pixel values.

You may also be able to set your own @page { size: ... } and let your PDF reader scale to fit the page. Adobe's reader can do this on the Print screen under the "Page Scaling" option set to "Fit to Printable Area".
silviobierman
My problem is that my company supplies a product where users can define their own HTML reports and they are given the option of generating them as PDF. The curent solution we use does not satisfy our users and I have concluded that Prince meets most of the criteria.

Changing already defined reports is not an option sice they also contain fixed-size images (graphs) etc.

Can you give any (non-official) indication you can give on a time-table?

Kind regards,

Silvio Bierman
mikeday
We hope to develop a prototype implementation of page scaling within the next two to three months.
silviobierman
That sounds promising. I might be able to hold this off somewhat longer.

Dynamic scaling would abviously be the optimum but I my problem would already be solved for the most part if I could scale with an explicit factor. Does that make things easier?

Regards,

Silvio Bierman
mikeday
A little, but it doesn't really shorten the time required to implement the feature I'm afraid.
silviobierman
That is what I expected but it was worth the try.

Thanks for the replies. I think I will be able to sit this out and wait for that release.

Regards,

Silvio Bierman
whittaker007
Hi,

Please excuse me for coming at this from a position of near total ignorance (I have only just discovered Prince), but could you not link your reports to a print media stylesheet that overrides your html container width to a specific print size?

Regards,

Scott
mikeday
Note that this may also require using the image-resolution property or specifying a width/height on images to make them fit neatly.
silviobierman
I just checked version 6. The ability to call Prince with a HTTP URL directly is exactly what I need it for. All I need now is the scaling ability. Will that be in 6.1?

In response to other sugestions: tweaking the HTML docs is not an option. They are generated by our software based on user-defined report definitions that are both used for generating reports in HTML format as well as PDF (via an alternative mechanism, currently).
The users create the reports based on what they see coming out as HTML using dimensions they like visually.
Generating PDF needs to be done completely transparantly.

Kind regards,

Silvio Bierman
Jambo software
whittaker007
Hi Silvio, are you aware that you can pass a CSS stylesheet to Prince on the command line along with the url of the web page you want to process? That means you can create your print stylesheet and use it to override any stylesheet on the web page without having to attach it directly to the web page in the header.

Of course that will only be of use to you if the existing web page already has element IDs and CSS classes to use as hooks, not inline styles or HTML attributes.
silviobierman
I know that is possible but in my case that does not help. The documents are defined by the users in terms of report elements (graphs, cross-tables, dynamic text etc) in combination with HTML layout markup. The use stuff like <div> etc to achieve the look on the screen they desire.
The HTML is generated dynamically during report processing. Only if CSS would allow me to apply a global scale factor to the entire document would it be of any use.

Note, users will even complain when the PDF document breaks text lines differently then the HTML version did.

Kind regards,

Silvio Bierman
silviobierman
There was something like 'style="width:900px"' inside the div element in there but somehow that got stripped.
silviobierman
To clarify things: The URL that I provide on the prince command line triggers the report generation process and dynamically returns the HTML document. There is no static HTML involved.

Kind regards,

Silvio Bierman
mikeday
Prince 6.0 rev 2 now includes a shrink to fit feature that can be enabled like this:
@page {
    prince-shrink-to-fit: auto
}

This should result in content with large specified widths being scaled down to fit on the paper. You may also wish to reduce the page margins when using this property to make the most of the available space.
silviobierman
That is excellent news. I will download it and give it a go with some of my customers reports.

Thanks a lot.