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

Missing several line of text when using html() with autopaging: text #3393

Open
aholake opened this issue Mar 18, 2022 · 7 comments
Open

Missing several line of text when using html() with autopaging: text #3393

aholake opened this issue Mar 18, 2022 · 7 comments

Comments

@aholake
Copy link

aholake commented Mar 18, 2022

I'm facing an issue when using html() function to print out a html element.

This is my code:

await doc.html(contentRef.current, {
  margin: [MARGIN_TOP, 0, MARGIN_BOTTOM, 0],
  autoPaging: 'text', // I think this property is the cause
  y: 30, // distance metadata to header (84pt) - margin top (54pt)
  html2canvas: {
    scale: 1.0,
    ignoreElements: element => element.id === autoTableConfig?.elementId,
  },
})

/// pdf save....

This is content displaying the my DOM
MY TREES, AND BUT A FEW STRAY GLEAMS STEAL INTO THE INNER SANCTUARY, I THROW MYSELF DOWN

When I set autoPaging = text
The output pdf will be:
image
As you see, we miss the text line EU PEDE MOLLIS PRETIUM. INTEGER TINCIDUNT. CRAS DAPIBUS. VIVAMUS ELEMENTUM SEMPER NISI.

Then I tried switching to slice mode, now the text line is rendered, but it's sliced and put on 2 different pages. This is not our expectation :(
image

I'm wondering if it is a problem when calculating the possition to render the next line of Context2D when a text line is cut off.
I don't have any idea to fix it so far.

Hope to see your help soon

@PLP-Casey
Copy link

I'm having a similar issue printing html to pdf. Not only does it appear to be removing lines, it also appears to change CSS Styling and positioning of elements passed the page break

@PLP-Casey
Copy link

From what have figured out, it appears to be an issue between autopagin text and margin bottom. For me, its seems to have fixed by removing setting margin-bottom 0px and removing autopaging. Although my margins were previously all set to 10.

@HackbrettXXX
Copy link
Collaborator

Thanks for the bug report. A pull request fixing this is very welcome.

@valueerrorx
Copy link

the issue i just created is probably related to this ?
#3403

@valueerrorx
Copy link

in my case all of the formatting problems start when autopaging is set to true and i have more than 2 pages ... the more pages i have the bigger are the formatting errors..

@ChamkhiAnas
Copy link

@aholake @valueerrorx have u found any solution for this problem plz ?

@valueerrorx
Copy link

unfortunately not.
i am now creating the pdf's on the electron side of my code using printToPDF(options)
it gives me much more control over the process and produces perfect pdfs.

this way i am able to set some basic options (like printBackground, pageSize, etc) and via CSS @media print {} condition i am able to change a lot of inpage styles before printing to pdf (making some elements invisible for example)

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

5 participants