My code is as follows:

from osgeo import ogr  
from osgeo import gdal

dso = ogr.Open('myfile.pdf')
print dso

dsg = gdal.Open('myfile.pdf')
print dsg

driverGeoPDFogr = ogr.GetDriverByName('PDF')
dso2 = driverGeoPDFogr.Open('myfile.pdf')
print dso2

This results in:

ERROR 4: `myfile.pdf' not recognised as a supported file format.


I know the file is a valid file, and when running gdalinfo from command line, the result for driver is:

Driver: PDF/Geospatial PDF

My question is, is PDF the incorrect driver name here for Geospatial PDF, or is this file format incompatible here? I'm running Python 2.6 and GDAL 1.11.2. Note, this is a Geospatial PDF, NOT a GeoPDF.

  • Just a guess, but perhaps you should try to open PDF with a raster driver. – user30184 Apr 17 '15 at 21:11
  • The PDF is vector so I do not believe that a raster driver will work – js1983 Apr 18 '15 at 22:15
  • Well, it is somewhere in the middle and when creating pdf files GDAL used to use a raster driver and ogr driver somehow together. But drivers may be unified now. – user30184 Apr 19 '15 at 6:33
  • You wrote yourself that you checked the driver with gdalinfo. What does ogrinfo report? – user30184 Apr 19 '15 at 6:36
  • ogrinfo results in: Had to open data source read-only. INFO: Open of 'myfile.pdf' using driver 'PDF' successful. – js1983 Apr 20 '15 at 15:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.