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

style markup issues in combination with <table> #46

Closed
mvaDevelop opened this issue Oct 28, 2022 · 5 comments
Closed

style markup issues in combination with <table> #46

mvaDevelop opened this issue Oct 28, 2022 · 5 comments

Comments

@mvaDevelop
Copy link

mvaDevelop commented Oct 28, 2022

Noticed some issues with table in htlm2pdf documents which I can't seem to fix. These are the issues I get:

  • borders seem to disappear at random locations. If i view the page as html i have a nicely formatted table without border breaks. If i then convert the html to pdf, i get strange line breaks:
    as html:
    afbeelding
    as pdf:
    afbeelding
    note: in my pdf the user can set the amount of copies, which will duplicate the table x amount of times. In the duplicates i have no issue with border breaks so it seems to happen randomly

  • div below the table sometimes overflows into the table footer. This also seems to happen randomly, and when i view the document as html i see no issues.
    afbeelding

Any ideas what the issue could be here? Are there known bugs in combining html2pdf with table html? I did notice that these bugs occur when the table spans over multiple pages

Thanks in advance for any help you can provide!

@spiritix
Copy link
Owner

Can you please try to print (CTRL+P) your page in Chrome web browser and save it to PDF? Are there any differences to the PDF generated by this library?

@mvaDevelop
Copy link
Author

mvaDevelop commented Oct 28, 2022

The border break seems to happen at the exact same coordinate (this is on a different tr in standard pdf as it doesn't calculate the same margins). This seems to happen at the first page break only, seemingly below the header area of the page
afbeelding

The collapsing into the table footer doesn't seem to happen in standard pdf. However, the margin between the div and the tfoot is a lot bigger than in html2pdf

@spiritix
Copy link
Owner

Can you try to set the mediaType option to screen or null? Very often, Chrome renders elements differently if media type is set to print, which it is by default. But other than that, there are some general differences in rendering compared to the web version, which are caused by Chrome. The only way to fix them is to apply custom CSS that's only applied to the print version (then you would have to revert to mediaType print).

@mvaDevelop
Copy link
Author

This results in the exact same border breaks

@spiritix
Copy link
Owner

Please create a new issue for the Puppeteer repository. Such issues are caused by their PDF rendering engine, there's not much I can do about it, unfortunately.

https://github.com/puppeteer/puppeteer/issues

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