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

Layout Shift When Converting HTML to PDF #666

Open
therealtgd opened this issue Sep 18, 2023 · 1 comment
Open

Layout Shift When Converting HTML to PDF #666

therealtgd opened this issue Sep 18, 2023 · 1 comment

Comments

@therealtgd
Copy link

therealtgd commented Sep 18, 2023

Description:
I am experiencing a layout shift issue when using the html2pdf.js library to convert HTML to PDF in a React application. The layout shift occurs when I trigger the conversion process.

Environment:

  • React version: 18.2.0
  • html2pdf.js version: 0.10.1

Steps to Reproduce:

  1. Include the html2pdf.js library in a React project.
  2. Trigger the HTML to PDF conversion process using the library.

Expected Behavior:
The HTML should be converted to PDF without causing any layout shifts or disturbances in the original layout.

Actual Behavior:
The conversion process causes a layout shift in the original HTML layout, which is not the expected behavior.

@itsic7
Copy link

itsic7 commented Oct 11, 2023

I can confirm similar misbehaviour.

When converting a relatively complex HTML element, an unexpected spacing shift occurs. What makes troubleshooting more difficult, however, is the fact that the shifts do not occur with every conversion. For example, out of 6 conversions, 3 PDFs are generated with the correct spacing; on the 3 other PDFs, the spacing of the individual components of the affected HTML element is incorrect. On top, the incorrect distances are never the same, but always different.

Does anyone have any idea what could be causing this sporadic error during conversion and whether there is a solution for it?

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

No branches or pull requests

2 participants