[mapserver-dev] MapServer png vs pdf output

Tamas Szekeres szekerest at gmail.com
Tue Nov 4 13:11:49 PST 2014


Hi Devs,

We may experience a difference regarding to the (visual) image size when
saving the map to pdf vs png. The problem is already described in the
following issue:
Cairo SVG and PDF output larger than PNG
<https://github.com/mapserver/mapserver/issues/4487> which is related to
the pdf/svg canvas where the size is specified in points and not in pixels.
That means: each point has a fixed size of 1/72 inches regardless of the
device used.

Our problem here is that we pass the image size directly to
cairo_pdf_surface_create
<http://cairographics.org/manual/cairo-PDF-Surfaces.html#cairo-pdf-surface-create>
or cairo_svg_surface_create
<http://cairographics.org/manual/cairo-SVG-Surfaces.html#cairo-svg-surface-create>
which
is incorrect. We should rather pass
72.0 / map->resolution * map->width and 72.0 / map->resolution *
map->height respectively. And we should also set map->resolution to 72
before the image is drawn to let the symbols scale with the image size
correctly.

My question is what would be the correct handling for this in MapServer?

1. Don't do anything in MapServer let the client programs (like mapscript
applications) to change the image size and scale.
2. Apply these corrections at the beginning of msDrawMap (for the pdf/svg
renderers specifically) and restore the original values at the end of the
drawing operation.
3. Apply these corrections at driver level (createImageCairo etc.)

For me #2 seems to be the most reasonable approach (with just a few lines
of code).
#1 would not help for the existing apps (mapserv, shp2img) which should be
fixed separately. And I cannot really see how #3 would work, since the
image size and resolution is not wired directly into the drivers
(createImage doesn't get the resolution for example).

Any ideas or alternatives?

Thanks,

Tamas
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/mapserver-dev/attachments/20141104/828d33b9/attachment.html>


More information about the mapserver-dev mailing list