PyFPDF

The pure Python PyFPDF library is a lightweight way to create PDFs including maps. Because the PDF format is a widely used standard, PDFs are commonly used to distribute maps. You can install it via PyPI as fpdf. The official name of the software is PyFPDF because it is a part of the PHP language module called fpdf. This module uses a concept called a cell to layout items at specific locations on a page. As a quick example, we'll import our hancock.png image created from the PIL example into a PDF called map.pdf to create a simple PDF map. The map will have the header text at the top that says Hancock County Boundary, followed by the map image:

>>> import fpdf >>> # PDF constructor: >>> # Portrait, millimeter units, A4 page size >>> pdf=fpdf.FPDF("P", ...

Get Learning Geospatial Analysis with Python - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.