Using Python I have a program that makes a GeoTiff map by joining several maps and converting with rgb2pct.

This works perfect and when imported in QGIS georeferencing is OK. However, I want also GeoPDF (small size en sending to non experts). I use:

src_ds = gdal.Open(src)
driver = gdal.GetDriverByName("PDF")
dst_ds = driver.CreateCopy(dst, src_ds, 1)

This gives a GeoPDF also OK in QGis. The maps are 4000x5200 px. and should when printed at 20px/mm (508 dpi) print as exactly 1:25000 fitting on A4. I have tried a lot of options e.g.:

gdal.SetConfigOption("DPI", "4080")
gdal.SetConfigOption("WRITE_USERUNIT", "NO")

But to no avail.

How do I specify the correct dpi for the pdf. (pdfjam works perfect but geo info is lost)?

  • I have had the same problem too, a few years ago. I decided that Adobe Acrobat was broken :) I tried all sorts of options and tags in the PDF to force a size and resolution, but if insisted on scaling and printing what it wanted. I finally have up and printed from Acrobat by forcing to print to a specific size in the print dialog box. This was the only path I knew to finally get my maps to print at 1:12000
    – TimB
    May 3 '18 at 3:46

[-outsize xsize[%]|0 ysize[%]|0] I do -outsize 60% 0 for scaling to a certain percentage of the original size. Outsize is in pixels and lines unless '%' is attached in which case it is as a fraction of the input image size. Starting with GDAL 2.0, if one of the 2 values is set to 0, its value will be determined from the other one, while maintaining the aspect ratio of the source dataset.

  • Unfortunately -outsize resizes the embedded image in the sense that my 2000x2600 image becomes with 50% 1000x1300 and I wanted to retain the image resolution.
    – jwevd
    Feb 10 '17 at 9:17
  • 2
    Whereas gdal.SetConfigOption("DPI", "254") did not work I found that driver.CreateCopy(dst, src, 1, ['DPI=508]) does work as shown by pdfinfo output. A second issue is that it apears that Adobe reader seems to ignore the dpi setting. Evince, however, works fine, printing EXACTLY to the intended scale.
    – jwevd
    Feb 10 '17 at 9:23

Your Answer

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

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