Forum How do I...?

Specifying output PDF size

redherring917
Hi there. New to Prince...

When calling Prince via the Java interface to convert SVG to PDF, how do I specify the desired size of the output file? Is that done via CSS?

Thanks!
mikeday
The paper size is specified in CSS with @page rules:
@page  {
    size: A4
}

redherring917
Thanks Mike.

This does indeed set the paper size, but the contents appear to be rendered @ 96ppi. How can I convert an SVG spec'd @ 72ppi pixel dimensions and have it fill the specified paper size?

So the question becomes, I think, how can I tell Prince (via the Java interface) the ppi resolution of my SVG input file?

Thanks.
mikeday
You can specify an absolute width/height on the SVG. If the width and height are only specified on pixels, and never mapped to absolute heights, Prince will interpret it as 96ppi.

There is a new undocumented command-line option --css-dpi=72 that will change the way Prince interprets pixel units. There is no method for this in the Java wrapper yet, but it would not be difficult to add one.
redherring917
Do you have plans then to add this as a Java wrapper feature, or are you saying that this is something that I could do myself in my Java call to Prince (if I knew what I was doing, which really I don't).

Thanks.
redherring917
Thoughts? Thanks.
mikeday
Sorry for the delay. We have updated the Prince Java interface (r8) to include a new setOptions() method which can be used to specify any Prince command-line options that we have not yet created methods for. So if you use the new interface, you can call prince.setOptions("--css-dpi=72") before conversion.
redherring917
Thanks Mike.