jsPDF icon indicating copy to clipboard operation
jsPDF copied to clipboard

addHtml function of a div does not render the div completely

Open ppasi07 opened this issue 11 years ago • 12 comments

Hi

I am trying to convert a html div content, which is in a modal dialog. I am using addHtml and the page does not render completely in the pdf document. Instead, I can see only partial content which I can see on the screen. The remaining content which is scrollable is not seen.

Any help how to display the entire div. Thanks in advance

ppasi07 avatar Sep 11 '15 17:09 ppasi07

Any help appreciated.

ppasi07 avatar Sep 14 '15 20:09 ppasi07

I don't know if we have the same problem but it does that to my d3 generated graph

ggxt avatar Oct 05 '15 13:10 ggxt

I'm having the same issue, page with scrollbars does not rendered completely.

gmav avatar Oct 08 '15 08:10 gmav

+1

patrickml avatar Feb 11 '16 21:02 patrickml

Even I have the same issue and I am using html2canvas 0.5.0-alpha2. In the html2canvas, the following code seems to have the issue. Here, "node.ownerDocument.defaultView.innerHeight" seems to consider only the height of the node's viewport. So when there is a scrollable div, only the visible portion gets printed in the pdf.

return renderDocument(node.ownerDocument, options, node.ownerDocument.defaultView.innerWidth, node.ownerDocument.defaultView.innerHeight, index).then(function(canvas) { if (typeof(options.onrendered) === "function") { log("options.onrendered is deprecated, html2canvas returns a Promise containing the canvas"); options.onrendered(canvas); } return canvas; });

swathisprasad avatar Feb 19 '16 11:02 swathisprasad

Same for me, Only the part of the div visible in the current scroll view is being rendered into the pdf file. A few days ago though, i didn't run into this problem, which is a bit weird. I am serving my jspdf.js right from this repository http://mrrio.github.io/jsPDF/dist/jspdf.debug.js, so I was wondering, could this be some change that happened in the past few days?

ilanle avatar Feb 22 '16 20:02 ilanle

OK, just realized something important that might be of use to anyone encountering this problem. I have a div that's larger in height than the screen height, this means that not all of it can be visible at a time. Now I realized that the problem is somehow related to the current scroll position on the page. Basically I found out that if the current scroll position is lower than the div, then you will have this rendering issue, but if it is higher up than the div, it renders perfectly. I am not sure I got this correct, this is just something I found a couple minutes ago, but it works for me now

ilanle avatar Feb 22 '16 21:02 ilanle

@ilanle,

That sounds interesting. I think I have similar problem too..

swathisprasad avatar Feb 22 '16 21:02 swathisprasad

Can some one post an example??? I still have the issue. Tried to implement this.

https://github.com/niklasvh/html2canvas/issues/461

ppasi07 avatar Feb 23 '16 19:02 ppasi07

has this fix been addressed?

mthor avatar Sep 01 '16 03:09 mthor

Hi there,

There's now a html2pdf example which much better supports generating documents from HTML.

Get the latest master and try:

npm install
npm start

Then visit localhost:8000/examples/html2pdf/showcase.html

Hope this works well for you :)

Many thanks, James

MrRio avatar Sep 28 '16 20:09 MrRio

localhost:8000/examples/html2pdf/showcase.html how can I open this it is local url

anupmondal50 avatar Dec 23 '17 05:12 anupmondal50