I know this question is old, but I had this issue recently and eventually came out with a way to do this.
This can be accomplished by using Osgeo's gdal
, which happens to have a PDF driver included. Basically you can do something like:
from osgeo import gdal
#Open your Unreferenced PDF
src = gdal.Open("originalFile.pdf")
Then obtain or calculate somehow the desired Projection System and Geotransform you want to add to the PDF. For example, we can extract those from a GeoTiff by doing:
#Open the Tiff to obtain its data from
geoTiff = gdal.Open("someMap.tif")
#Obtain its Projection system and its Geotransform
coords = geoTiff.GetProjection()
gt = geoTiff.GetGeoTransform()
Finally, set the projection and geotransform to your PDF and then create a copy with the PDF Driver:
src.SetProjection(coords)
src.SetGeoTransform(gt)
#Instantiate a PDF driver and save your Referenced copy
pdf_driver = gdal.GetDriverByName("PDF")
dst = pdf_driver.CreateCopy("referencedFile.pdf", src, 1)
The result is a PDF that is georeferenced to have its upper-left corner placed at location gt
using the Projection System coords
. This can be verified by opening the PDF on QGis or ArcGis, or well by using the gdalinfo
command on your referenced PDF.