Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PDF Export Size / Resolution Inconsistency #33465

Closed
Saijin-Naib opened this issue Dec 18, 2019 · 11 comments · Fixed by #39547
Closed

PDF Export Size / Resolution Inconsistency #33465

Saijin-Naib opened this issue Dec 18, 2019 · 11 comments · Fixed by #39547
Labels
Bug Either a bug report, or a bug fix. Let's hope for the latter! Print Layouts Related to QGIS Print Layouts, Atlas or Reporting frameworks

Comments

@Saijin-Naib
Copy link

Saijin-Naib commented Dec 18, 2019

Describe the bug
GeoPDF export products (both ISO3200 and OGC styles) export at a page size that is scaled by a factor above the determined Page Size set in the Layout Manager.

For instance:
Project settings: GeoPDF ISO3200 - ANSI D (34 x 22 inches)

Export @ 150dpi: 70.83 x 45.83 inches
image
- 2.08 scale factor

Export @ 300dpi: 141.67 x 91.67 inches
image
- 4.16 scale factor

Project Settings: Legacy PDF - ANSI D (34 x 22 inches)
Export @ 300dpi: 34 x 22 inches
image
- 1.00 scale factor

How to Reproduce

  1. Set a known page size and export resolution (ANSI D @ 150/300dpi for this example)
  2. Export PDF using GeoPDF variant (ISO3200 or OGC)
  3. Inpsect document properties in PDF viewer
  4. Note that actual page dimensions are scaled above what export was set to
  5. Re-export same document using "Legacy" PDF
  6. Inspect document properties in PDF viewer
  7. Note that actual page dimensions match export settings

QGIS and OS versions

QGIS version 3.10.1-A Coruña QGIS code revision ef24c52
Compiled against Qt 5.11.2 Running against Qt 5.11.2
Compiled against GDAL/OGR 3.0.2 Running against GDAL/OGR 3.0.2
Compiled against GEOS 3.8.0-CAPI-1.13.1 Running against GEOS 3.8.0-CAPI-1.13.1
Compiled against SQLite 3.29.0 Running against SQLite 3.29.0
PostgreSQL Client Version 11.5 SpatiaLite Version 4.3.0
QWT Version 6.1.3 QScintilla2 Version 2.10.8
Compiled against PROJ 6.2.1 Running against PROJ Rel. 6.2.1, November 1st, 2019
OS Version Windows 10 (10.0)
Active python plugins CalculateGeometry; DataPlotly; joinmultiplelines; latlontools; MemoryLayerSaver; networks; openlayers_plugin; PluginLoadTimes; processing_gnm; qconsolidate; QGISSortAndNumber-master; realcentroid; refFunctions; SelectWithin; SplitPolygonShowingAreas; SpreadsheetLayers; statist; db_manager; processing

Additional context
Seems to be the same issue as Issue #32931

Attachment
This attachment contains a sample QGIS project, as well as sample export PDFs, and screenshots for the settings used to generate each set of export PDFs.
PDF_TEST.7z.zip

@Saijin-Naib Saijin-Naib added the Bug Either a bug report, or a bug fix. Let's hope for the latter! label Dec 18, 2019
@gioman gioman added the Print Layouts Related to QGIS Print Layouts, Atlas or Reporting frameworks label Dec 18, 2019
@nyalldawson
Copy link
Collaborator

I can't reproduce this -- using the attached project the generated PDFs are all correctly sized...

@nyalldawson nyalldawson added the Feedback Waiting on the submitter for answers label Jun 5, 2020
@Saijin-Naib
Copy link
Author

Saijin-Naib commented Jun 5, 2020

Still happening with the test project:
image
image

Is this a limitation of the outdated GDAL/QT shipped against the Windows build compared to what some can run on Linux?

QGIS version 3.12.3-București QGIS code revision 8234261
Compiled against Qt 5.11.2 Running against Qt 5.11.2
Compiled against GDAL/OGR 3.0.4 Running against GDAL/OGR 3.0.4
Compiled against GEOS 3.8.1-CAPI-1.13.3 Running against GEOS 3.8.1-CAPI-1.13.3
Compiled against SQLite 3.29.0 Running against SQLite 3.29.0
PostgreSQL Client Version 11.5 SpatiaLite Version 4.3.0
QWT Version 6.1.3 QScintilla2 Version 2.10.8
Compiled against PROJ 6.3.2 Running against PROJ Rel. 6.3.2, May 1st, 2020
OS Version Windows 10 (10.0)
Active python plugins CalculateGeometry; ImageServerConnector; MemoryLayerSaver; openlayers_plugin; slyr; SpreadsheetLayers; vector_tiles_reader; zoom_level; db_manager; processing

@nyalldawson
Copy link
Collaborator

I suspect the difference here is in how Adobe Reader interprets the page size vs the PDF reader I'm using...

@Saijin-Naib
Copy link
Author

Saijin-Naib commented Jun 15, 2020

I suspect the difference here is in how Adobe Reader interprets the page size vs the PDF reader I'm using...

Hm, locally these files show the same (wrong) size in GSView, Foxit, and Adobe. And by locally I mean on my work and personal computers, both.

@agiudiceandrea
Copy link
Contributor

agiudiceandrea commented Jun 16, 2020

If it can help, inspecting the provided pdf files you will find:
Legacy_150DPI.pdf
<< /Annots 14 0 R /Contents 11 0 R /MediaBox [ 0 0 2448 1584 ] /Parent 3 0 R /Resources 13 0 R /Type /Page /VP [ 27 0 R ] >>

Legacy_300DPI.pdf
<< /Annots 14 0 R /Contents 11 0 R /MediaBox [ 0 0 2448 1584 ] /Parent 3 0 R /Resources 13 0 R /Type /Page /VP [ 27 0 R ] >>

ISO3200_150DPI.pdf
<< /Contents 3213 0 R /Group << /CS /DeviceRGB /S /Transparency /Type /Group >> /MediaBox [ 0 0 2448 1584 ] /Parent 1 0 R /Resources 3214 0 R /StructParents 0 /Type /Page /UserUnit 2.083333333333333 /VP [ 12 0 R 15 0 R ] >>

ISO3200_300DPI.pdf
<< /Contents 3213 0 R /Group << /CS /DeviceRGB /S /Transparency /Type /Group >> /MediaBox [ 0 0 2448 1584 ] /Parent 1 0 R /Resources 3214 0 R /StructParents 0 /Type /Page /UserUnit 4.1666666666666661 /VP [ 12 0 R 15 0 R ] >>

As you can see, the MediaBox values (in default user space units) are the same (2448 1584), but for ISO3200_150DPI.pdf and ISO3200_300DPI.pdf a UserUnit value is also present.
This value (A positive number that shall give the size of default user space units, in multiples of 1⁄72 inch Default value: 1.0, user space unit is 1⁄72 inch ) represents a scale factor for the real page size: 2.0833 for ISO3200_150DPI.pdf and 4.1667 for ISO3200_300DPI.pdf.

So, the page size for
Legacy_150DPI.pdf and Legacy_300DPI.pdf is 34 x 22 inches (2448*1/72=34 x 1584*1/72=22),
while for
ISO3200_150DPI.pdf is 70.83 x 45.83 inches (2448*2.0833/72=70.83 x 1584*2.0833/72=45.83)
and for
ISO3200_300DPI.pdf is 141.67 x 91.67 inches (2448*4.1667/72=141.67 x 1584*4.1667/72=91.67)

@agiudiceandrea
Copy link
Contributor

Moreover, I cannot see any geospatial information for the provided pdf (OGC or ISO3200 ones) using the Geospatial Location Tool in Adobe Reader XI.

@agiudiceandrea
Copy link
Contributor

@Saijin-Naib
Copy link
Author

Is the over-scale output expected and part of the GeoPDF spec?

@agiudiceandrea
Copy link
Contributor

I don't think so. For example, ArcMap 9.3.1 exports a correct size GeoPDF for whatever resolution the user wants.

@nyalldawson
Copy link
Collaborator

I've attempted to fix this, but am blocked by https://lists.osgeo.org/pipermail/gdal-dev/2020-September/052681.html -- it's possible there's an underlying GDAL bug at play here. Will report back any updates...

@Saijin-Naib
Copy link
Author

Thanks for looking into this!

nyalldawson added a commit to nyalldawson/gdal that referenced this issue Sep 23, 2020
…file

Doing so causes incorrect page sizes for the generated PDF file.

Refs qgis/QGIS#33465
nyalldawson added a commit to nyalldawson/QGIS that referenced this issue Oct 22, 2020
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 qgis#33465
nyalldawson added a commit that referenced this issue Oct 22, 2020
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Either a bug report, or a bug fix. Let's hope for the latter! Print Layouts Related to QGIS Print Layouts, Atlas or Reporting frameworks
Projects
None yet
4 participants