Don't create PDFs with size > 200.0 inches #23

Closed
opened 2021-04-25 19:57:43 +00:00 by josch · 0 comments
Owner

By jbarlow83 on 2015-03-25T23:46:30.341Z

For historical reasons the maximum paper size of a PDF is 200x200 inches or 14400x14400 pts.

If DPI is wrong (as if often the case) img2pdf may generate a PDF longer than 200 inches.

For example if image is 28800 pixels wide and DPI is set to 72, img2pdf will calculate a width of 400 inches and create an illegal PDF with these dimensions. Some PDF viewers will display it but compliant ones (Acrobat) will not.

In PDF 1.6 you can set /UserUnit on the /Page object to adjust the size of 1 pt. In my example if /UserUnit is 400/200=2.0 then the page dimensions will display correctly.

Or the quick and dirty approach is to manipulate the DPI. If page width > 200, force DPI = pixel width / 200.

See page 148 for /UserUnit.
https://www.adobe.com/content/dam/Adobe/en/devnet/acrobat/pdfs/pdf_reference_1-7.pdf


By josch on 2016-02-10T06:23:59.033Z


Hrm... I think the right way to fix this is to just disallow pages larger than 200 inches in either dimension. I don't see a situation in which allowing larger sizes would be useful.

Thanks for your bugreport!


By jbarlow83 on 2016-02-10T08:00:04.637Z


While I do have map rolls physically larger than 200", my uses are not typical, and most of the time I run into this problem it's a large file with the wrong DPI set. Chances are good that 200 inches is an error condition and aborting is reasonable.


By josch on 2016-02-10T08:44:21.914Z


thanks, fixed!


By josch on 2016-02-10T08:44:21.989Z


Status changed to closed

*By jbarlow83 on 2015-03-25T23:46:30.341Z* For historical reasons the maximum paper size of a PDF is 200x200 inches or 14400x14400 pts. If DPI is wrong (as if often the case) img2pdf may generate a PDF longer than 200 inches. For example if image is 28800 pixels wide and DPI is set to 72, img2pdf will calculate a width of 400 inches and create an illegal PDF with these dimensions. Some PDF viewers will display it but compliant ones (Acrobat) will not. In PDF 1.6 you can set /UserUnit on the /Page object to adjust the size of 1 pt. In my example if /UserUnit is 400/200=2.0 then the page dimensions will display correctly. Or the quick and dirty approach is to manipulate the DPI. If page width > 200, force DPI = pixel width / 200. See page 148 for /UserUnit. https://www.adobe.com/content/dam/Adobe/en/devnet/acrobat/pdfs/pdf_reference_1-7.pdf --- *By josch on 2016-02-10T06:23:59.033Z* --- Hrm... I think the right way to fix this is to just disallow pages larger than 200 inches in either dimension. I don't see a situation in which allowing larger sizes would be useful. Thanks for your bugreport! --- *By jbarlow83 on 2016-02-10T08:00:04.637Z* --- While I do have map rolls physically larger than 200", my uses are not typical, and most of the time I run into this problem it's a large file with the wrong DPI set. Chances are good that 200 inches is an error condition and aborting is reasonable. --- *By josch on 2016-02-10T08:44:21.914Z* --- thanks, fixed! --- *By josch on 2016-02-10T08:44:21.989Z* --- Status changed to closed
josch closed this issue 2021-04-25 19:57:43 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: josch/img2pdf#23
No description provided.