question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Special char not recognized and text illegible in a PDF generated with jspdf and html2canvas

See original GitHub issue

Hi,

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: image

Furthermore, since I’m using the file dist/jspdf.umd.js the text is illegible: the letters overlap: text_issue

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:closed
  • Created 3 years ago
  • Comments:15

github_iconTop GitHub Comments

2reactions
HackbrettXXXcommented, Jan 15, 2021

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 the text function. As a consequence, the defaults were wrong. I created a PR, which should fix the issue with the next release.

1reaction
SwissMaWicommented, Jan 12, 2021

I have the same issue with jsPDF 2.2.0 and a number formatted to locale with thousand separator: image renders in PDF to image Can I use an older version of jsPDF to avoid the problem?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Special char not recognized and text illegible in a PDF ...
Hi,. 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 ...
Read more >
How to enable UTF-8 in jsPDF library - Stack Overflow
As of 2015, jsPDF doesn't support UTF-8 properly, workaround is to use html2canvas to render jpg or png and to add it to...
Read more >
jspdf-html2canvas - npm
A combine usage with jsPDF and html2canvas, which translating html content to PDF file.. Latest version: 1.4.9, last published: 2 years ago.
Read more >
html2pdf.js | Client-side HTML-to-PDF rendering using pure JS.
html2pdf.js converts any webpage or element into a printable PDF entirely client-side using html2canvas and jsPDF. :warning: There have been several issues ...
Read more >
jsPdf not working in Visualforce page for large documents
Task: To convert a document[visualforce generated one] into pdf. ... Problem Faced : RenderAs pdf method is not working as expected in all...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found