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

DPI/Scale in html2canvas #85

Open
fuleinist opened this issue Mar 1, 2018 · 3 comments
Open

DPI/Scale in html2canvas #85

fuleinist opened this issue Mar 1, 2018 · 3 comments

Comments

@fuleinist
Copy link

fuleinist commented Mar 1, 2018

Hi @eKoopmans ,

Just wonder if dpi/scale feature are embeded in your new api branch as per your commit in niklasvh/html2canvas#1087.

I played around with it and find out there is no difference on generated pdf. All images and text are just very blurry.

Here is my settings and pdf screenshot

				html2canvas: {
					backgroundColor :'#000',
					scale: 2,
					dpi: 600,
					imageTimeout: 0,
					letterRendering: true,
				},
				jsPDF: {
					format: 'a4',
					pagesplit: true,
				}	

image

@eKoopmans
Copy link
Owner

Hi @fuleinist, sorry for the long delay!

Yes, DPI/scale are implemented, though it depends on which version of html2canvas you're using. If you use html2pdf.bundle.js, the bundled-in version of html2canvas should be scaling correctly!

Also, starting with html2pdf v0.9.0 I am returning to using the official version of html2canvas, rather than my own fork. It now supports scale (though not dpi) natively.

@retrospectacus
Copy link

retrospectacus commented Jul 4, 2018

I am using html2pdf.js 0.9.0 in angular2. It works great (thanks!!) but I am not able to scale the output PDF as I want.
When I set the scale option to a larger number like 5, it gives the output PDF a larger file size with sharper content, but I cannot e.g. make more text appear on a line (smaller text; like I've zoomed out).
The dpi option does not seem to have any effect.
Can you show how to do this? Thanks again.

@retrospectacus
Copy link

I was able to work around by applying the following CSS class to the printed element.

.zoom-out { 
  /* CSS zoom property not supported by html2canvas */
  transform: scale(0.8);
  transform-origin: 0 0;
  margin: 0 -25% 0 0;
}

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

No branches or pull requests

3 participants