parallax/jsPDF

fromHTML() cuts off line at new page

Closed this issue · 17 comments

Adtiv commented

I have to build a pdf based on dynamic text. I am using an HTML page to load in stored content from the forms that the user will fill out. When the data exceeds the pagesize a new page is created but a line always gets cut out inbetween the two pages. I have no way of knowing exactly where in the html this will occur because it will always be different based on what you've filled out and can range from 1-20+ pages. So far I've tried css page breaks, 'pagesplit:true', and slightly modifying the fromHTML.js functions to try and change the starting y value(which didnt work). messing with the maxLineHeight variable in the renderTextFragment function showed me the missing line but in an arbitrary position on the page. for example, maxLineHeight = Math.max(maxLineHeight, style["line-height"], style["font-size"])-x; //for x=random number 1-50. seemed to work, but again i would not know where to put this before hand. Any idea how to fix this? Same problem when you exceed two pages(line got cut out between pages 2-3)

Adtiv commented

This is a screenshot of the pdf I am generating. Question 8 gets cut out because it is in the space between page 1-2. Everything that sais "test" can be more than a line long so i cant hard code the page breaks. Any help would be appreciated.

img_1773

Too late to comment but still... I am facing the same issue .. were you able to fix it ?

I have same issue too. Did you find any fix for this issue please?

same issue here!

Same issue, no workaround found yet 😢

Open the jspdf.js file and modify this: this.pdf.internal.getVerticalCoordinateString(this.y), style.color, "Td");

Erasing "style.color" and save as: this.pdf.internal.getVerticalCoordinateString(this.y), "Td");

And then it runs correctly on firefox and chrome

am also facing same problem i tried this.pdf.internal.getVerticalCoordinateString(this.y), "Td"); also but its not working pls help me it would be very grate help to me becoz i tried one week

Fixed in #1492

ogbdn commented

We are in 2021 and I think this is still an issue. Unfortunately, I can´t work inside jspdf.js since I have to use the CDN file and can´t use the file locally to upload it to the server. Any solution for that? Thanks

ogbdn commented

@SebastianKut What line is that? I don´t find this line in jspdf.js

ogbdn commented

I think this post shouldn´t have been closed @Uzlopak. In your example, you have used the same phare on each line. What happens if you do :
This is my paragraph 1
This is my paragraph 2
This is my paragraph 3
This is my paragraph 4
This is my paragraph 5
This is my paragraph 6
This is my paragraph 7
This is my paragraph 8
This is my paragraph 9
This is my paragraph 10
.
.
.

Thanks

ogbdn commented

@Uzlopak e @SebastianKut I just noticed I was using an old CDN version. I have changed for "https://cdnjs.cloudflare.com/ajax/libs/jspdf/1.5.3/jspdf.min.js" and it worked.

Im still having this problem and im at latest version :S

I also have the problem with the latest version. I habe a little bit different scenarion than the example above. I'm currently rendering the html from a big paragraph.

@Maadtin #2977 should fix this, but there hasn't been any progress recently...

I updated jspdf to version 2.4.0

, it has "autoPaging"
options in the html() method of jspdf, anyone knows what is it for?
I tried using it , but didnt see anything particualr in the generated pdf

if anyone still facing the issue, you can just add autoPaging:'text' for the solution, it worked for me.
I hope this also work for anyone who faced this problem

Thankss