Skip to content
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

The text overlaps #183

Open
jgrDev opened this issue Nov 27, 2018 · 1 comment
Open

The text overlaps #183

jgrDev opened this issue Nov 27, 2018 · 1 comment

Comments

@jgrDev
Copy link

jgrDev commented Nov 27, 2018

Hi,
The code I use for exporting is:

html2pdf().from( document.getElementById('previewbox') ).set({
	            margin: 1,
	            filename: fileName+'.pdf',
	            image: { type: "jpeg", quality: 1},
	            jsPDF: {orientation: 'portrait', unit: 'in', format: 'letter', compressPDF: false},
	            pagebreak: {mode: ['avoid-all']} 
	 
            }).save().then(function () {
            	console.log("PDF is donwloaded!");
            });

The properties margin and format may be related.
Thanks!
https://jsfiddle.net/jgrDev/u6o6ne41/4350/
web.pdf

@eKoopmans
Copy link
Owner

Hi @jgrDev, sorry for the delay! I've investigated and this is an issue within html2canvas. Here's a fork of your fiddle to demonstrate: https://jsfiddle.net/eKoopmans/0qzy8ac4/

In that fiddle, I made these changes:

  1. Added html2canvas dependency.
  2. Changed the element width to 21.0cm (this is the width of A4, the standard PDF size).
  3. Used html2canvas to make a canvas and append to the document.

You will see that the same text overlap is occurring. I'd recommend checking the issue tracker on html2canvas - I know he's done a lot of work recently to support Unicode. Specifically, check the Unicode issue tracker and niklasvh/html2canvas#226. One recommendation is to use the html2canvas option {letterRendering: true}.

If you don't find an answer or similar issue there, open a new issue on html2canvas, and give an example (like the one I made) that doesn't involve html2pdf at all. Good luck!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants