Special char not recognized and text illegible in a PDF generated with jspdf and html2canvas
See original GitHub issueHi,
I have a problem with the file dist/jspdf.umd.js. Following the advice given for solving the issue #2766, I’m using the file dist/jspdf.umd.js in replacement of jspdf.js.
But I obtain problems with special characters. They are not recognized even if the meta data type is correctly defined in my page. I don’t have this problem before when I used the file jspdf.js from the src folder.
For instance: in my html page “≥
” for “greater than or equal to”: the character should be “≥50%” and appears like that:
Furthermore, since I’m using the file dist/jspdf.umd.js the text is illegible: the letters overlap:
Here my code: `
<!DOCTYPE html> <html><head>
<meta charset="utf-8">
<title>Template 01</title>
<link id="BootstrapCSS" rel="stylesheet" type="text/css" href="bootstrap.min.css">
</head>
<body id="toPDF">
<div id="result">
<div id="target">
<div class="container-fluid">
<p id="generateButton" style="display: none;"><button type="button" class="btn btn-primary btn-lg" onclick="download()">Generate PDF</button></p>
<div id="content">
<table id="table01" class="table table-bordered table_border">
...
</table>
<table id="table02" class="table table-bordered table_border">
...
</table>
...
</div>
</div>
</div>
</div>
</body>
<script src="jspdf.umd.js"></script>
<script src="jquery-2.1.4.min.js"></script>
<script src="html2canvas.min.js"></script>
<script>
function download() {
let pdf = new jspdf.jsPDF('p', 'pt', 'a4')
let srcwidth = document.getElementById('toPDF').scrollWidth;
pdf.html(document.getElementById('toPDF'), {
html2canvas: {
scale: 595.26 / srcwidth, //595.26 is the width of A4
scrollY: 0
},
filename: 'jspdf',
x: 0,
y: 0,
callback: function () {
window.open(pdf.output('bloburl'));
}
});
}
</script>
</html>
`
Could you please help me please to solve this issue ? I don’t know if I should use another version of the jspdf version for solving this error and the error (and in the same time the error #2766).
Kind Regards,
Issue Analytics
- State:
- Created 3 years ago
- Comments:15
Top GitHub Comments
I finally found out that this is indeed a regression to 1.5.3 and is due to the
options.flags
parameter being ignored by thetext
function. As a consequence, the defaults were wrong. I created a PR, which should fix the issue with the next release.I have the same issue with jsPDF 2.2.0 and a number formatted to locale with thousand separator: renders in PDF to Can I use an older version of jsPDF to avoid the problem?