HTML String to PDF not working properly - Page width
See original GitHub issueHello all,
I’m currently trying to run a HTML String code to PDF using the latest version. No success so far, the HTML is rendered in PDF with only 20% cover of the page, and not the entire page width.
Here’s how it is being generated:
My code:
window.html2canvas = html2canvas;
window.jsPDF = window.jspdf.jsPDF;
const HTML_STRING = "<h1>This is a title</h1> <p>long lorem ipsum text here...</p>";
var pdf = new jsPDF({
orientation: "portrait",
unit: "pt",
format: 'letter'
});
pdf.html(HTML_STRING, {
callback: function (doc) {
doc.save('generated_pdf.pdf')
},
x: 10,
y: 10
});
Tried with different formats and combinations so far (the orientation needs to be portrait), and also tried to set up the margin options array, but no difference was seen. :(
Currently script order usage:
- purify.min.js * 2.2.2
- jspdf.umd.min.js * (latest version)
- html2canvas.min.js * 1.0.0-rc.7
I appreciate any answer, help or discussion here. Thanks.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:2
- Comments:5
Top Results From Across the Web
HTML String to PDF not working properly - Page width #3113
Hello all,. I'm currently trying to run a HTML String code to PDF using the latest version. No success so far, the HTML...
Read more >Solving formatting issues when converting HTML to PDF
The Muhimbi PDF Converter comes with the ability to convert HTML to PDF. ... HTML that improves the formatting, e.g. a different page...
Read more >Define PageSize when converting from HTML to PDF
My problem is that the resulting pdf has a page size of 215,9 x 279,4mm (instead of 210 x 297mm) and the margin...
Read more >Resizing Content During Conversion with Select.Pdf Html to ...
The page width is only an indication of the minimum page width recommended for conversion. If the content does not fit this width,...
Read more >Troubleshooting - EVO PDF
A possible solutions is to set the HTML viewer width to about 800 pixels or to set the PdfDocumentOptions. FitWidth property to false....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
This should be fixed with the new
width
andwindowWidth
options in 2.4.0This 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.