Skip to content

Commit 460bf8e

Browse files
committedOct 22, 2020
Hardcode a DPI of 72 into GDAL GeoPDF composition file instead of
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
1 parent f5c8739 commit 460bf8e

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed
 

‎src/core/qgsabstractgeopdfexporter.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -408,9 +408,10 @@ QString QgsAbstractGeoPdfExporter::createCompositionXml( const QList<ComponentLa
408408
// pages
409409
QDomElement page = doc.createElement( QStringLiteral( "Page" ) );
410410
QDomElement dpi = doc.createElement( QStringLiteral( "DPI" ) );
411-
dpi.appendChild( doc.createTextNode( qgsDoubleToString( details.dpi ) ) );
411+
// hardcode DPI of 72 to get correct page sizes in outputs -- refs discussion in https://github.com/OSGeo/gdal/pull/2961
412+
dpi.appendChild( doc.createTextNode( qgsDoubleToString( 72 ) ) );
412413
page.appendChild( dpi );
413-
// 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!
414+
// assumes DPI of 72, as noted above.
414415
QDomElement width = doc.createElement( QStringLiteral( "Width" ) );
415416
const double pageWidthPdfUnits = std::ceil( details.pageSizeMm.width() / 25.4 * 72 );
416417
width.appendChild( doc.createTextNode( qgsDoubleToString( pageWidthPdfUnits ) ) );

0 commit comments

Comments
 (0)
Please sign in to comment.