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

feat: improve pdf export quality #31349

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft

Conversation

tahvane1
Copy link
Contributor

@tahvane1 tahvane1 commented Dec 9, 2024

This PR uses img2pdf to export charts to pdf. Current solutions uses compression in such way that pdf is grainy.
Using img2pdf removes this issue mostly.

SUMMARY

Current pdf quality is poor and this improves it significantly

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

TESTING INSTRUCTIONS

img2pdf needs to be added to docker images.

ADDITIONAL INFORMATION

@dosubot dosubot bot added the viz:charts:export Related to exporting charts label Dec 9, 2024
Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Congrats on making your first PR and thank you for contributing to Superset! 🎉 ❤️

We hope to see you in our Slack community too! Not signed up? Use our Slack App to self-register.

@tahvane1 tahvane1 changed the title improve pdf export quality feat: improve pdf export quality Dec 9, 2024
@rusackas rusackas requested a review from fisjac December 9, 2024 17:19
Copy link
Member

@villebro villebro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR apparently adds a new requirement. I don't oppose this change, but I would propose the following:

  • Add img2pdf to one of the .in files in requirements/. Based on this change it would need to go into base.in. Also do check that the license is Apache 2.0 compliant.
  • Add before/after screenshots to show how quality changes.
  • Add info about how the pdf file size changed before/after. Lossless compression is great, but can bloat the attachment size.

@rusackas rusackas requested review from eschutho and removed request for eschutho December 9, 2024 17:19
@tahvane1
Copy link
Contributor Author

tahvane1 commented Dec 9, 2024

img2pdf is using GNU Lesser General Public License v3 and it seems that it is not accepted in ASF projects. So need to look for alternative approach then.

@villebro
Copy link
Member

villebro commented Dec 9, 2024

img2pdf is using GNU Lesser General Public License v3 and it seems that it is not accepted in ASF projects. So need to look for alternative approach then.

Dang, that's a real shame! 🙁

@rusackas
Copy link
Member

rusackas commented Dec 9, 2024

Do we know if the low resolution is caused by the capture method (Image.open(BytesIO(snap))) or by the output method (images[0].save(...))? Apparently if it's the latter, you can add a resolution=300.0 parameter.

@tahvane1
Copy link
Contributor Author

tahvane1 commented Dec 9, 2024

Resolution does not fix issue. I can get similar quality by setting quality=100 but this results to a pdf that has double the size what img2pdf produces. I will continue my testings...

@villebro villebro marked this pull request as draft December 11, 2024 17:53
@villebro
Copy link
Member

FYI I converted this to draft. @tahvane1 please feel free to change it back to non-draft if you find a new ASF-compliant way to fix this issue.

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

Successfully merging this pull request may close these issues.

4 participants