-
Notifications
You must be signed in to change notification settings - Fork 4.7k
JsPdf is saving a pdf but takes too long time to show it in google chrome #3137
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
Comments
Please attach the PDF document. |
I have edited my post and included the pdf document, this is the code rendered in the pdf document:
|
The performance issue seems to be that each letter is written as a single chunk of text. Why that is, I don't know, yet. |
I tried to transform the document to an Image before saving it and it worked but the text inside the pdf can't be copied, |
Seems like if there is onclone: async (d: HTMLDocument) => {
const styleSheet = `
* {
letter-spacing: initial !important;
}
`;
const style = document.createElement('style');
style.innerText = styleSheet;
d.head.appendChild(style);
} |
Any return? have the same issue |
In addition to I created this PR in |
I have the same problem. The pdf generated from html is loaded very slow by chrome and edge and scrolling is choppy. |
Hi, @KurtGokhan I've tried the mentioned solution of removing the letter-spacing but it made no difference. The PDF is still extremely choppy on chromium browsers (e.g. Edge is a chromium browser). |
One workaround I found is to render the text to an image, and print that into PDF. But text will not be selectable in the PDF if you do that. |
@KurtGokhan Yeah unfortunately that wouldn't be ideal. However if I did that, since my HTML converts into multiple pages the image would have to be split (still haven't figured out how to do that) and I would have to calculate how many pages would be needed. |
Hi dear authors any update? |
Hi, just FYI. I noticed if a single table cell contains too much text will cause the performance issue. Hope it helps. |
This issue is stale because it has been open 90 days with no activity. It will be closed soon. Please comment/reopen if this issue is still relevant. |
Also having the same issue, Any Suggestions guys?? |
At the end the best solution was using Puppeeter with my nodejs backend |
Thanks For Suggestion!! |
trying @KurtGokhan css hack does improve the rendering speed a little but when there's Word Starting With Upper Case it will sometimes join 2 word together --> WordWord. Is there any other workaround ? |
In my case generated PDF was loading fine in Ubuntu Document Viewer, but not in Chrome PDF viewer. Rendering was slow for some pages, visible especially on scrolling (but also on load if I put problematic element on first page). I could narrow down the issue to border-radius style on my table element. If text was short then there was no issue, but for long texts it was loading very long (forever). I set border-radius to 0 on my table container class and problem disappeared. I do not know why is that. Html:
Css:
JS:
|
@adamturski Thank you for the update. I just tested and I reproduce that removing the border radius in my generated pdf make them way faster in chrome. |
I'm using JsPDF to download an html styled element, but when it is downloaded, it takes too long to be showed in google chrome as pdf (shows just an empty pdf document at first and charge it after long time),
the size of the file is only 300KB, I don't know why I have this problem however it's showed correctly in mozilla firefox browser
Please do you know how could I solve this problem.
this is my code
generatePDF = () => {
var doc = new jsPDF('p','pt',"a4");
const inp = document.getElementById("cv");
doc.html( inp , {
html2canvas: {
scale: 0.75,
},
callback: function (doc) {
var pageCount = doc.internal.getNumberOfPages();
doc.deletePage(pageCount)
doc.save("download.pdf");
}
});
}
this is the pdf file:
downloaded.pdf
The text was updated successfully, but these errors were encountered: