Chartjs-C# How to print html Convas element in PDF document

0👍

on the client, you can use jsPDF

  var canvas = document.getElementById('canvas_barchart');
  var doc = new jsPDF();
  doc.addImage(ctx.toDataURL('image/png'), 0, 0);
  doc.save('chart.pdf');

or you can use ajax to send the image back to the server and save it there…

$.ajax({
  data: {
    image: ctx.toDataURL('image/png')
  },
  type: 'POST',
  url: 'server/saveImage'
});

Leave a comment