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

Option to choose PDF output dpi #32

Open
Amosar opened this issue Nov 16, 2018 · 4 comments
Open

Option to choose PDF output dpi #32

Amosar opened this issue Nov 16, 2018 · 4 comments

Comments

@Amosar
Copy link

Amosar commented Nov 16, 2018

Hi,
With the default setting I found the PDF output ugly on my TV so I have modify it from 72 to 96 to improve that but this is reset every update.
Can you please add an option to set a new value ?
https://github.com/mennolui/wp-foyer/blob/master/includes/class-foyer-image-editor-imagick.php#L72

Regards

@mennolui
Copy link
Owner

Hi @Amosar, thanks for reporting!

This is probably caused by the PDF not being wide enough or included images not being high-res enough.

I did some testing and gathered some data..

When I create a 16:9 presentation in Keynote, then export it as PDF with 'Image Quality' set to 'best', then upload it to a Foyer PDF slide, the output image on the slide is exactly 1920x1080 pixels (= HD TV resolution). So that's perfect.

When inspecting that PDF it has a page size of 67,74 × 38,1 cm.
Of course not all PDFs out there are created that way, some are sized for printing on A4 paper (21,0 × 29,7 cm) or Letter. Those will result in a much smaller image on Foyer PDF slides.

To display a Letter (8,5 x 11 inch) sized PDF crisp contained in a 1080x1920 (portrait) display you would need to render it at 128dpi. This is actually what WordPress is doing for PDFs: https://make.wordpress.org/core/2016/11/15/enhanced-pdf-support-4-7/

Increasing the DPI would work for those 'paper' PDFs, upscaling them, but would result in pretty heavy (3413px wide!) images for PDFs created for screen presentations. So that's not a very tempting solution.

Maybe if it would be possible to check the size of the input PDF.. then I could calculate the DPI needed for an image that is exactly contained within 1920x1920. Not sure how though.

Any ideas on this?

@Amosar
Copy link
Author

Amosar commented Nov 19, 2018

I have verified with my pdf and the output resolution is 960 x 540 with 72dpi so this is the problem.
This resolution is the default setting when I export the presentation with powerpoint and I don't know how to change it.
The result is more clean with 96dpi because the size of the generate pictures are now 1280 x 720

And I don't know if it's possible with wordpress but I have found something for converting all pdfs to a resolution close to 1920 x 1080.
I do identify -format "%[pdf:HiResBoundingBox]" pdf.pdf to found the resolution of the pdf (960 x 540 for example)
After I do 960/72 = 13.33 to have the ratio between resolution and dpi and then I do 1920/13.33=144 to find the closest dpi to generate 1920 x 1080 picture

@mennolui
Copy link
Owner

Thanks for all the troubleshooting! So Powerpoint exports PDFs for printing, not for screen usage clearly.

Something like indentify could help. Unfortunately, I just checked, the way PDF conversion is build in WordPress sets the dpi before knowing what file will be processed.

I don't see a solution to this problem at the moment. Apart from coding my own PDF conversion mechanism, or just arbitrary doubling the dpi (resulting in huge files and maybe even errors for those uploading PDFs that are correctly sized for screen usage)...

@IDisposable
Copy link

IDisposable commented Oct 28, 2019

Could you just let the PDF render client-side using the https://wp-pdf.com/ plugin?

I used that on several wordpress installs like: https://bereaacademystl.org/staff/teachers/teachers-handbook/teacher-handbook-2019-2020/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants