You can easily add google maps in your HTML to PDF exports by using Google Static Maps API and create rich and beautiful reports.

Google Static Maps API

Google Static Maps works without javascript and it will generate an image for a given URL. You can embed this image by simply using <img> tag in your HTML file which you wich to convert to PDF.

There are also various options in Google Static Maps API which you can customize, for example:

  • add markers
  • draw paths and polygons
  • map zoom
  • image size
  • scaling of the image
  • image format
  • map type
  • center map on given coordinates

You can find full documentation in the following url:
https://developers.google.com/maps/documentation/staticmaps/

Google Static Maps API terms of service:

"If a Static Maps API image is used outside of a web-based application (such as a browser) then a link must be included pointing to the displayed location in a web browser or native Google Maps application."

Export Google Map to PDF in 3 simple steps

1. Create a Google static map URL:

https://maps.google.com/maps/api/staticmap?center=51.502312,-0.122608&zoom=11&size=640x300

Following tools will help you create a Google Static Map URL:

2. Prepare HTML for conversion to PDF

<!DOCTYPE html>
<html>
<head>
  <title>Export Google Map to PDF with HTML PDF API</title>
</head>
<body>
  <img src="https://maps.google.com/maps/api/staticmap?center=51.502312,-0.122608&amp;zoom=11&amp;size=640x300" />

  <!-- Link for Google terms of service -->
  <div>
    <small>
      <a href="https://maps.google.com/maps/api/staticmap?center=51.502312,-0.122608&amp;zoom=11&amp;size=640x300">
        https://maps.google.com/maps/api/staticmap?center=51.502312,-0.122608&amp;zoom=11&amp;size=640x300
      </a>
    </small>
  </div>
  <!-- Link for Google terms of service -->
</body>
</html>

3. Send file to HTML PDF API service. 

You can learn how to send HTML file to our API in usage and documentation section.

HTML to PDF ready example

Here is a more complex example of using Google Maps with HTML PDF API.

Download  (ZIP)
Compressed (zipped) folder containing:
index.html

Download (PDF)
Generated PDF from HTML/CSS

Preview (HTML)