1

使用canvg解析器将SVG转换为画布后显示为PDF时,为什么缺少Amchart的轴标签?

var image1 = $('div.amcharts-chart-div').get(0);
var svg = image1.innerHTML;
if (svg) {
  svg = svg.replace(/\r?\n|\r/g, '').trim();
}

var canvas = document.createElement('canvas');
canvg(canvas, svg, {
  ignoreMouse: true,
  ignoreAnimation: true
});

var ctx = canvas.getContext('2d');
ctx.globalCompositeOperation = 'destination-over'
// set the color
ctx.fillStyle = '#FFFFFF';
// draw the background
ctx.fillRect(0, 0, canvas.width, canvas.height);

var imgData = canvas.toDataURL('image/jpeg', 1.0);

pdf.addImage(imgData, 'JPEG', 15, 115, 180, 100, undefined, 'none');
4

0 回答 0