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

ADDED - scale parameter to options #127

Closed
wants to merge 1 commit into from

Conversation

glesperance
Copy link

Hey there,

I needed to make an image out of an element in my webapp and had to output an image that had a scaling factor applied to it.

I couldn't get any success with the width and height properties so I added a scale parameter that can be passed as an option.

Scale can either be a number, or an object of the form { x : scaleX, y : scaleY }. The resulting image should also be of good quality as the scaling factor is applied before the drawing.

Cheers,

Gabriel

@niklasvh
Copy link
Owner

I think it would be better to apply this through css transform:scale() (it isn't supported at the moment), and perhaps instead add an option to apply custom CSS to the render, which may not be available on the page.

@grvpanchal
Copy link

Hi,
I tried both gabriel's method and niklasvh css transform method, the canvas is scaled but there isn't anything in it. Will it be possible in future release of html2canvas to SCALE the canvas.

Thanks

@mudcube
Copy link

mudcube commented Sep 22, 2013

I'm probably not understanding exactly how HTML2Canvas works, but... would it be possible to add the scale to an element above the foreignObject on the export? So that the exported data has vector scaling (instead of bitmap based):

http://jsfiddle.net/nugWf/5/

@niklasvh
Copy link
Owner

html2canvas doesn't use foreignObject to render the content.

@naz
Copy link

naz commented Mar 18, 2014

Hi.

Could anybody review this pull request? It has been a while and this feature is quite important for any retina device.

Thx.
Nazar

@nouknouk
Copy link

Same as Gargol: on my side, the rendered text looks blurry compared to the rendering of the HTML done by the browser. Also when the browser's zoom set to a value higher than 100% that's even worst.

In this scope, having a option's parameter to define the rendering resolution, would be great. But having CSS scaling to render images with an higher resolution, could also be a good workaround.

html2canvas-rendering

@ricricucit
Copy link

quoting @gargol +1

@ricricucit
Copy link

@glesperance here: https://github.com/glesperance/html2canvas your "Makefile" file doesn't work. can you please commit the "build" folder in the repo or tell me where can i get your "htmltocanvas.min.js". Thanks.

@glesperance
Copy link
Author

@ricricucit If you install ant via brew and then do make the build should work on OS X.

The PR is actually 2 years old and so I don't know if it still works ; anyway, here's a gist with the built files.

https://gist.github.com/glesperance/68627ad5e4da6c99763b

Cheers.

Gabriel

@ricricucit
Copy link

thanks.

@stefanello
Copy link

@niklasvh
any news for adding support for css transform:scale() ?
Thx!

@haoqi0818
Copy link

in the most cases, the body's style is "overflow:hidden", so just set "transform:scale(2)" to aim element is not work as expected

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

Successfully merging this pull request may close these issues.

10 participants