3

Isn't it possible to store Metadata directly in GeoPDF files using GDAL command line tools (gdal_translate, gdal_edit) or GDAL Python?

Something like: gdal_edit -mo "CUTLINE=POLYGON(...)" orig.pdf

Unfortunately, all I can achieve is the creation of an additional *.aux.xml file that includes the Metadata entry (GDAL 2.2.2 Windows 64bit).

Using PyPDF2 to store the Metadata didn't help either, because gdalinfo couldn't read the data.

Do I miss something here?

2
  • Looks like it depends on the Metadata variable: gdal_edit -mo "PRODUCER=POLYGON((...))" orig.pdf ... works
    – christoph
    Oct 16, 2017 at 16:32
  • Ok, not the best idea to use "PRODUCER" for storing custom data. Maybe someone could explain how to use "xml:XMP" for storing custom Metadata?
    – christoph
    Oct 16, 2017 at 17:07

1 Answer 1

1

Yes it is possible. Also, here is a great resource Geospatial PDF

These are two examples of creating metadata as provided in the resource:

Examples

Create a PDF from 2 rasters (main_raster and another_raster), such that main_raster is initially displayed, and they are exclusively displayed :

gdal_translate -of PDF main_raster.tif my.pdf -co LAYER_NAME=main_raster
           -co EXTRA_RASTERS=another_raster.tif -co 
EXTRA_RASTERS_LAYER_NAME=another_raster
           -co OFF_LAYERS=another_raster -co 
EXCLUSIVE_LAYERS=main_raster,another_raster

Create of PDF with some JavaScript :

gdal_translate -of PDF my.tif my.pdf -co JAVASCRIPT_FILE=script.js
where script.js is :
button = app.alert({cMsg: 'This file was generated by GDAL. Do you want to 
visit its website ?', cTitle: 'Question', nIcon:2, nType:2});
1
  • Nope, this was not my Intention. I tried something like: gdal_edit -mo "MYDATA=VALUE" orig.pdf
    – christoph
    Oct 16, 2017 at 14:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.