Hi Thomas, Jeremias, Jonathan and Chris,

First of all, thanks for all the support!

See comments below.

From: thomas.dewe...@kodak.com [mailto:thomas.dewe...@kodak.com]
Sent: Sunday, 13 February 2011 10:28 a.m.
To: batik-users@xmlgraphics.apache.org
Cc: batik-users@xmlgraphics.apache.org
Subject: Re: Units in SVG - PDF

Hi Tim,

Tim Heuer <heu...@landcareresearch.co.nz> wrote on 02/10/2011 06:17:06 PM:

> The units seem to be wrong or I am doing a mistake.
[...]

>                               UserAgent userAgent = new UserAgentAdapter();

        Since the correct relationship between 'px' and real world units
is dependent on the rendering context the UserAgent has a method that
allows you do specify this relationship, this is the default in the
UserAgentAdapter we provide.

    /**
     * Returns the size of a px CSS unit in millimeters.
     */
    public float getPixelUnitToMillimeter() {
        return 0.26458333333333333333333333333333f; // 96dpi
    }

This seems to do the trick! However, I found that this works as well and seems 
slightly cleaner to me:

float svgFactor = (float) Toolkit.getDefaultToolkit().getScreenResolution() / 
72f; // Might need to get 72 from somewhere else?

> I looked up the SVG specifications and found that pt is 1.25 pixels.
> However, this renders wrongly on the PDF. The image becomes too big
> and is cut off. When I enter 1.5f instead of 1.25f above, it seems
> more correct but still a bit out.

        So given that we use the above figure 1.333 would be correct.
But I suggest you use the above method to work out the relationship
between pt and px.

> I don’t want to hack together a number that will just happen to look
> right, because it is the wrong approach. Is there some kind of
> trickiness with the units between SVG and PDF (using iText)?

        I'll just second Jeremias' suggestion that FOP/Batik already
includes a PDF renderer that has code so it generates better output
from Batik (as mentioned "simple: SVG text will stay text in the output
and Gradients generally do not get rasterized).

> Help is much appreciated. I am working on the legends’ rendering in
> SVG in the MapFish print module and will submit the source back to
> the project, so I think they would appreciate your input too.

        Hope that helps.

Thomas DeWeese | CDG Advanced Development |
Eastman Kodak Company | 343 State Street | Rochester, NY 14650-0128 |
thomas.dewe...@kodak.com<mailto:thomas.dewe...@kodak.com> | 585 724-0294 |
www.kodak.com<http://www.kodak.com/>

________________________________
Please consider the environment before printing this email
Warning: This electronic message together with any attachments is confidential. 
If you receive it in error: (i) you must not read, use, disclose, copy or 
retain it; (ii) please contact the sender immediately by reply email and then 
delete the emails.
The views expressed in this email may not be those of Landcare Research New 
Zealand Limited. http://www.landcareresearch.co.nz

Reply via email to