[gdal-dev] Read PDF with OGR

Andreas Oxenstierna ao at t-kartor.se
Wed Oct 19 09:36:19 PDT 2016


Thanks, gdal_edit.py worked as you described, exactly what I needed for 
these orienteering maps.

Yes, I wondered how OGR actually should interpret unstructured PDF 
vectors...
I unsuccesfully tested with vector PDFs created by several softwares - 
which softwares can actually create ogr-readable PDFs?


> Le mercredi 19 octobre 2016 17:09:03, Andreas Oxenstierna a écrit :
>> Hi list
>>
>> I want to attach georeferencing to existing vector PDF files that lacks
>> georef info.
>>
>> This works without any issues using gdal:
>> gdal_translate -of PDF -a_srs EPSG:3006 -a_ullr 718500 6359200 726500
>> 6369100  <infile> <outfile> --config GDAL_PDF_DPI 300
> gdal_translate will not attach georeferencing to existing PDF file, but it will
> create a new one, re-rasterizing its content.
>
> Use rather gdal_edit.py : http://gdal.org/gdal_edit.html
> That will just add the geospatial metadata and not change the rest of the PDF
> content.
> This will also work for "vector" PDF files (although your example is already
> georeferenced)
>
>> but all attempts with ogr fails, even if the PDF driver is listed:
>> Unable to open datasource `k.pdf' with the following drivers.
>>     -> PDF
>>
>> I tested with https://www.nps.gov/hfc/carto/PDF/ANTImap1.pdf with the
>> same result, i.e. GDAL can read the vector PDF file but not OGR
>> ogrinfo --format pdf returns all available options etc.
>>
> The OGR PDF driver only recognize by default very specific formulations of
> vector PDF that use the StructTreeRoot objects of the PDF specification, which
> is not the case for this sample.
>
> There was a feature actually not yet documented. Done now :
> """
> If there is no such logical structure, the driver will not try to interpret
> the vector content of the PDF, unless you defined the
> OGR_PDF_READ_NON_STRUCTURED configuration option to YES."""
>
> So try:
>
> ogrinfo ANTImap1.pdf --config OGR_PDF_READ_NON_STRUCTURED YES
>
> Note that the conversion from PDF vectors to OGR geometries can be rough for
> some PDF objects.
>
>> I would like to use ogr2ogr so vector geospatial PDF's can be created.
>> Is this possible?
> Yes.
> And you can combine raster + vector as explained in the tutorial at
> http://latuviitta.org/documents/Geospatial_PDF_maps_from_OSM_with_GDAL.pdf
> (last link of the PDF driver documentation page)
>
>> The two sample links in the bottom of http://www.gdal.org/frmt_pdf.html
>> are broken.
> I've removed/updated them
>
> Even
>


-- 
Best regards

Andreas Oxenstierna
T-Kartor Geospatial AB
mobile: +46 733 206831
mailto: ao at t-kartor.se
http://www.t-kartor.com



More information about the gdal-dev mailing list