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
html2canvas Option onclone
Not Working as Expected with jsPDF
#2987
Comments
The |
Thanks - not sure I understand what the difference is? The In lieu of improving the situation, is there some way we can improve the documentation maybe? Not entirely sure what we'd say, but hoping to figure it out :) |
Ah sorry, I wrote "html2canvas option" instead of "html2canvas module". The typings suggest that you can pass html2canvas options to html2canvas, but that's unfortunately not true/not implemented. I'm willing to accept a PR that will improve this situation. Passing options to html2canvas should really be possible. For backwards compatibility, we should probably check if the argument is the html2canvas function or the options object and treat it respectively. |
Try use it like this,
|
This issue is stale because it has been open 90 days with no activity. It will be closed soon. Please comment/reopen if this issue is still relevant. |
there is any update about that? i have a similar problem, my changes in the onclone function are reflected in the cloned document but only few are showed when the premises is solved |
It seems that the issue is due to the fact that the styles of the clone element used by jsPDF keep the same properties as the source html element. It would be necessary to be able to apply to them the same modifications made in the onclone option for that to work. |
html2canvas onclone is necessary in order to intercept and modify elements in the finished document before final output. The current workaround is to chain it by directly installing and using html2canvas and using the final canvas object to create the jsPDF. |
Has this changed? @HackbrettXXX stated previously:
However, the current docs show the |
@HackbrettXXX Apparently on my rendered canvas, l have noticed that some css properties such as left are not maintained and as such the rendered image is out of the actually required viewport. I have tried the onclone option to add the style back to my document, but its not being fulfilled unfortunately. I have also noticed that as a matter of fact, the required section had already been turned a canvas regardless of the callback function implement. Simple console.logging has ascertained this. Is there a fix or get-around to the onclone method. Please assist, its a bit important...thanks |
Hi there,
I also created a fiddle to test https://jsfiddle.net/renatobl/emzjufr2/ |
When passing a function to the html2canvas option
onclone
via jsPDF, via the html module'shtml2canvas
property, the generated PDF does not reflect the changes in the cloned document.Some self-contained html is below to copy+paste, which demonstrates what seems to be happening. From what I can tell, jsPDF is using an overlay and container for its document source, while html2canvas creates its own container for its cloned document, which jsPDF never seems to reference.
I didn't see any existing issues around this, so not sure if I'm missing something, using incompatible versions of something, etc. Thanks for any help!
The text was updated successfully, but these errors were encountered: