我正在尝试使用Angular 5将包含highchart.js图表的HTML页面导出为PDF。
我尝试了这种方法,但出现错误
var data = document.getElementById('contentToConvert');
html2canvas(data).then(canvas => {
var svg = document.getElementById('svg-container').innerHTML;
if (svg)
svg = svg.replace(/\r?\n|\r/g, '').trim();
var createCanvas = document.createElement('canvas');
var context = createCanvas.getContext('2d');
console.log(createCanvas);
context.clearRect(0, 0, createCanvas.width, createCanvas.height);
canvas(canvas, svg);
var imgData = createCanvas.toDataURL('image/png');
// Generate PDF
var doc = new jspdf('p', 'pt', 'a4');
doc.addImage(imgData, 'PNG', 40, 40, 75, 75);
doc.save('test.pdf');
这是错误:
addImage does not support files of type 'UNKNOWN', please ensure that a plugin for 'UNKNOWN' support is added
。