DinkToPdf icon indicating copy to clipboard operation
DinkToPdf copied to clipboard

Javascript is not working

Open dineshguntha opened this issue 5 years ago • 5 comments

With the below code javascript is not enable? could pleae advice on it? sb.AppendFormat(@"

dineshguntha avatar Sep 09 '18 13:09 dineshguntha

I have the same problem

ArDotWeb avatar Apr 01 '19 13:04 ArDotWeb

This post is little old, but Is there solution for rendering jsChart with DinkToPdf?

PiotrFirst avatar Jan 09 '20 10:01 PiotrFirst

Any updates!

MostafaRamadan1 avatar May 25 '20 07:05 MostafaRamadan1

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);

PiotrFirst avatar May 27 '20 21:05 PiotrFirst

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);

csharpforevermore avatar Sep 11 '20 11:09 csharpforevermore