I am trying to embed a google map in a landscape PDF, but somehow wkhtmltopdf always cuts the map into two parts, although the map will easily fit on one page.
I think the problem is that the map is built using slabs. The tiles are larger than the map and are cropped, but wkhtmltopdf seems to ignore this and think that the cut tiles should also fit into the page ...
Here is a sample code to play:
<html> <head> <script src="https://maps.google.com/maps/api/js?sensor=false"></script> <script> window.onload = function(){ var fenway = new google.maps.LatLng(47.188563,8.480487); var gmap = new google.maps.Map(document.getElementById("map"),{ center: fenway, zoom: 14, mapTypeId: google.maps.MapTypeId.ROADMAP, disableDefaultUI: true }); var marker = new google.maps.Marker({ position: fenway, map:gmap }); google.maps.event.addListener(gmap,"tilesloaded",function(){ window.status = "ready"; }); } </script> </head> <body> <div id="map" style="width:1500px;height:800px"></div> </body> </html>
And the command to convert to PDF:
wkhtmltopdf --window-status ready --orientation landscape map.html map.pdf
I am using the latest version of wkhtmltopdf, by the way ...
Is it possible to make the map fill the page without a cut?
wkhtmltopdf
Van coding
source share