Skip to content
This repository has been archived by the owner on Nov 29, 2023. It is now read-only.

Fix: works around issue with canvas not printing in puppeteer's PDF g… #513

Merged
merged 2 commits into from
Feb 1, 2023

Conversation

MartijnR
Copy link
Member

@MartijnR MartijnR commented Jan 11, 2023

…eneration, closes enketo/enketo#969

I have verified this PR works with

  • Online form submission
  • Offline form submission
  • Saving offline drafts
  • Loading offline drafts
  • Editing submissions
  • Form preview
  • None of the above

What else has been done to verify that this works as intended?

The code is only used for PDF generation. Therefore, I've only tested the PDF API endpoints.

Why is this the best possible solution? Were any other approaches considered?

I concluded that the issue is a bug in puppeteer in the printToPDF implementation of a '2d' canvas. Therefore, it seemed best to work around it. In the PDF view, there is no need for a real canvas, so converting canvases to images seemed an acceptable solution.

How does this change affect users? Describe intentional changes to behavior and behavior that could have accidentally been affected by code changes. In other words, what are the regression risks?

Regression risks are styling changes in the drawing widget or general images that unintentionally affect drawings in the PDF view.

Do we need any specific form for testing your changes?

See the linked issue for API calls to reproduce the issue and test the fix.

* (though not WebGL-related as some of the commenters suggest)
*/
await page.evaluate(() => {
/* eslint-env browser */
Copy link
Member Author

@MartijnR MartijnR Jan 11, 2023

Choose a reason for hiding this comment

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

It's unclear what the scope of this eslint-env override is. Setting it to eslint-env: node after this page.evaluate function doesn't actually seem to switch it back.

@MartijnR MartijnR marked this pull request as ready for review January 11, 2023 20:47
@eyelidlessness eyelidlessness merged commit 906a32b into master Feb 1, 2023
@MartijnR
Copy link
Member Author

MartijnR commented Feb 1, 2023

thanks!

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

Successfully merging this pull request may close these issues.

PDFs show empty canvas for loaded drawings, signatures and annotated images
2 participants