Skip to content

Commit

Permalink
Hardcode a DPI of 72 into GDAL GeoPDF composition file instead of
Browse files Browse the repository at this point in the history
original layout DPI

This fixes the incorrect page size reported by Acrobat reader for
generated GeoPDF files.

Unfortunately it comes with a side-effect of limiting the resolution
at which GDAL will read the GeoPDF files as a raster layer, but of
the two issues the page size issue is more critical.

Fixes #33465
  • Loading branch information
nyalldawson committed Oct 22, 2020
1 parent f5c8739 commit 460bf8e
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/core/qgsabstractgeopdfexporter.cpp
Expand Up @@ -408,9 +408,10 @@ QString QgsAbstractGeoPdfExporter::createCompositionXml( const QList<ComponentLa
// pages
QDomElement page = doc.createElement( QStringLiteral( "Page" ) );
QDomElement dpi = doc.createElement( QStringLiteral( "DPI" ) );
dpi.appendChild( doc.createTextNode( qgsDoubleToString( details.dpi ) ) );
// hardcode DPI of 72 to get correct page sizes in outputs -- refs discussion in https://github.com/OSGeo/gdal/pull/2961
dpi.appendChild( doc.createTextNode( qgsDoubleToString( 72 ) ) );
page.appendChild( dpi );
// assumes DPI of 72, which is an assumption on GDALs/PDF side. It's only related to the PDF coordinate space and doesn't affect the actual output DPI!
// assumes DPI of 72, as noted above.
QDomElement width = doc.createElement( QStringLiteral( "Width" ) );
const double pageWidthPdfUnits = std::ceil( details.pageSizeMm.width() / 25.4 * 72 );
width.appendChild( doc.createTextNode( qgsDoubleToString( pageWidthPdfUnits ) ) );
Expand Down

0 comments on commit 460bf8e

Please sign in to comment.