[gdal-dev] Confusion regarding GeoPDF composition.xml units
andreaerdna at libero.it
Tue Sep 22 00:09:39 PDT 2020
Nyall Dawson wrote
> On Tue, 22 Sep 2020 at 16:36, Andrea Giudiceandrea
> > wrote:
> So then my question would be why the PDFs attached to
> https://github.com/qgis/QGIS/issues/33465 are showing incorrect page
> sizes in Acrobat Reader, when it appears as though GDAL is correctly
> generating them!
>From the analysis of those PDFs I've wrote in a comment of the issue report
, it seems to me the problem is that for the two ISO3200_*.PDF (which
have a wrong size) a UserUnit value is present, while it is not present in
the two Legacy_*.PDF (which have a correct size).
The UserUnit key act as a scale factor.
I don't know why, but in GDAL the UserUnit is calculated as DPI / 72.0 and
added by default (for GeoPDFs).
If a UserUnit value is present, the actual PDF page size (defined in the
MediaBox key) will be "scaled up" by the UserUnit value.
So, currently only for GeoPDF generated at 72 DPI the page size is correctly
retained: UserUnit = DPI / 72.0 = 72 / 72 = 1, then no scaling will occur.
I guess the issue could be solved avoiding to record the UserUnit value in
the generated GeoPDF by simply setting the WRITE_USERUNIT creation option
 to NO, but the description it's not so clear to me...
"WRITE_USERUNIT=YES/NO: (GDAL >= 2.2) Whether the UserUnit setting computed
from the DPI (UserUnit = DPI / 72.0) should be recorded in the file. When
UserUnit is recorded, the raster size in pixels recognized by GDAL on
reading remains identical to the source raster. When UserUnit is not
recorded, the printed size will depends on the DPI value. If this parameter
is not set, but DPI is specified, then it will default to NO (so that the
printed size depends on the DPI value). If this parameter is not set and DPI
is not specified, then UserUnit will be recorded (so that the raster size in
pixels recognized by GDAL on reading remain identical to the source
 https://gdal.org/drivers/raster/pdf.html#creation-options and
Sent from: http://osgeo-org.1560.x6.nabble.com/GDAL-Dev-f3742093.html
More information about the gdal-dev