Creating a PDF from tiles

Hi!

I’m not really sure, this is the best place to ask, but currently I didn’t found a better one…

So, my problem: I rendered the Europe’s map using an own style and it works perfectly, so I can display the map with Leaflet in a Browser.
With the same library I can display the airports and airspaces and have a map in the browser window like the ICAO-maps.

Now, I need to export part of these maps (in the highest zoom) as PDF.
And I really don’t have any idea how to do it…

I had the idea to do that on server side, for example using PHP, but I really don’t know how to get the right tile starting from the coordinates. Maybe there is already a PHP-library to do this work?
Or there is a better way to solve my problem?

Thanks a lot for your answer
Luca

There was someone working on a PHP binding for the Mapnik render library at some point, but that did not really get of the ground as far as I remember.

The Mapnik library can be used to not only render bitmap tiles, but can also produce vector formats like SVG and PDF, and can be used to render larger areas than just a single tile.

I’m using the Python Mapnik bindings for this on my print service, actually mostly using a fork of the original MapOSMatic sites code.

Remembering that you asked about osm2pgsql imports earlier, and assuming that your style is either using MapnikXML stylesheets directly, or Carto CSS, would you be willing to share your style with me so that I can either add it to the public service at print.get-map.org, or provide you with setup instructions to run your own MapOSMatic instance locally?

Hi Hartmut,

thank you for your answer.
Currently I’m trying to understand how to get the right tile and place it on an PDF, using PHP. Maybe I’ll get it…
Another solution could be to export the map using Javascript. It seems there is at least one library to take screenshot from Leaflet.

About the style: I use CartCSS, some special queries, some special tables I created in order to speed up the render, and some SVG for the ICAO-Elements.
Not really simple and portable.
Anyway, without the airspace data (that come from OpenAIP and OpenFlightMaps and are updated every two weeks) the map are not really useful.

Regards
Luca

Ok, so you “only” want to stitch together tiles into a bitmap PDF?

Using your style and mapnik to directly generate PDF would give you much better rendering quality though.

I know, but I don’t need a PDF of whole Europe, but just a part of it.
The idea is to export the part of the map I need for the flight together with the airspace.
Huge definition is not needed in this case.

Thanks
Luca