DinkToPdf
DinkToPdf copied to clipboard
Javascript is not working
With the below code javascript is not enable? could pleae advice on it? sb.AppendFormat(@"
I have the same problem
This post is little old, but Is there solution for rendering jsChart with DinkToPdf?
Any updates!
I render page in browser and send rendered HTML to controller for generating PDF. To render js chart I wrote simple workaround which work, but the resolution of the chart is not in high quality (in PDF looks enough). The main things is to render chart in canvas after page loading. And the second is to hide div with canvas and copy picture to image component by url_base64 encoding. Please try this example.
HTML part:
<image id = 'abcUrl />
<div id = 'abc' style = 'width: 800px; height: 400px;'>
<canvas id = 'abcChart' width = '800' height = '400'> </canvas>
</div>
and JS part after rendering page:
var url_base64jp = document.getElementById ("abcChart"). toDataURL ('image/png', 1.0);
console.log ("img:", url_base64jp);
document.getElementById ('abcUrl").src = url_base64jp;
$ ("#abc"). attr ("hidden", true);
This doesn't fix it for me. I get an empty image rendered.
var url_base64jp = document.getElementById("abcChart").toDataURL('image/png', 1.0); console.log("img:", url_base64jp); document.getElementById("abcUrl").src = url_base64jp; $("#abc").attr("hidden", true);