pdfScale icon indicating copy to clipboard operation
pdfScale copied to clipboard

Export-Import PDF Metadata - Geospatial data not written to output

Open twestley opened this issue 1 year ago • 5 comments

I tried scaling a CalTopo PDF map with geospatial data. The scaling works; I like it.

But the output file was missing the geospatial data.

twestley avatar Apr 01 '23 20:04 twestley

Any examples? Maybe changing the mode could help. We depend on Ghostscript. If it is possible in GS, we can do it...

tavinus avatar Apr 07 '23 19:04 tavinus

Thanks for responding. The attached script, scale.txt, generates a PDF file but fails to reproduce the spatial data in it. What am I doing wrong? (I'm using Avenza Maps on iPhone to determine whether I've got spatial data or not.)

scale.txt -i AmherstPeanut.pdf -o AmherstPeanut-scaled.pdf -s 0.9

AmherstPeanut.pdf scale.txt

twestley avatar Apr 25 '23 03:04 twestley

From this post, it seems like Ghostscript will never preserve metadata. https://unix.stackexchange.com/questions/50475/how-to-make-ghostscript-not-wipe-pdf-metadata

However, you can use exiftool or pdftk to copy the metadata from one pdf to another (needs to be tested). You will probably need to install them in your system though. There are examples on the link above. You could replace the whole gs call in the pdftk example with the pdfscale call if you want.

Maybe this could be added as an optional feature to pdfscale.

tavinus avatar May 23 '23 09:05 tavinus

Thanks for looking at this. After trying qpdf, pdftk, pdfunite, and pdfjam, I discovered that qpdf works to overlay a legend pdf on a map pdf:

qpdf --overlay legend.pdf --repeat=1 -- map.pdf combined.pdf

The geospatial data is retained in combined.pdf above so problem solved.

twestley avatar May 23 '23 14:05 twestley

Pretty interesting. I may have a look into this when I have some time. Maybe we can automate this process within pdfScale (external tool install will be needed though).

tavinus avatar May 29 '23 21:05 tavinus