Giter Site home page Giter Site logo

Javascript is not working about dinktopdf HOT 5 OPEN

rdvojmoc avatar rdvojmoc commented on May 15, 2024 3
Javascript is not working

from dinktopdf.

Comments (5)

ArDotWeb avatar ArDotWeb commented on May 15, 2024

I have the same problem

from dinktopdf.

PiotrFirst avatar PiotrFirst commented on May 15, 2024

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

from dinktopdf.

MostafaRamadan1 avatar MostafaRamadan1 commented on May 15, 2024

Any updates!

from dinktopdf.

PiotrFirst avatar PiotrFirst commented on May 15, 2024

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

from dinktopdf.

csharpforevermore avatar csharpforevermore commented on May 15, 2024

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

from dinktopdf.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.