Chart js renders with bad quality in html-pdf

244 Views Asked by At

I use html-pdf to generate PDF from my HTML file with script for a chart I use html-pdf without any options:

return new Promise((resolve, reject) => {
      const html = pug.renderFile(`${this.basePath}/${dirName}/${templateName}.pug`, data);
      pdf.create(html).toBuffer((err, buffer) => {
        if (err) {
          reject(err);
        }
        resolve(buffer);
      });
    });

My html looks like:

<div style="width:547px;margin: 0 auto">
 <canvas id="myChart"> <canvas/>
<div/>
<script>
    var ctx = document.getElementById('myChart').getContext('2d');
     var myChart = new Chart(ctx, { ...} )
</script>

When i open my HTML it renders chart well but PDF chart is poor quality. How to solve it?

0

There are 0 best solutions below