Cómo convertir archivos SVG a PDF en JSPDF usando javascript
Luché por convertir archivos SVG a PDF usando JSPDF. Aquí trabajé en el siguiente código.
var doc = new jsPDF();
var test = $.get('amChart.svg', function(svgText){
// console.log(svgText);
var svgAsText = new XMLSerializer().serializeToString(svgText.documentElement);
console.log(svgAsText);
doc.addSVG(svgAsText, 20, 20, doc.internal.pageSize.width - 20*2)
//console.log(doc);
// Save the PDF
doc.output('datauri');
});
Obtengo este script de estoPues contestaSolo sus resultadosPDF en blanco.Cuando yoconsole.log(doc)
antes de la salida, mostrará resultados, pero no dará como resultadoPDF...
Y yo también estoy trabajando enSVGELEMENTOPDF función de estoURL GITHUB y trabajé en este código también.
// I recommend to keep the svg visible as a preview
var svg = $('#container > svg').get(0);
// you should set the format dynamically, write [width, height] instead of 'a4'
var pdf = new jsPDF('p', 'pt', 'a4');
svgElementToPdf(svg, pdf, {
scale: 72/96, // this is the ratio of px to pt units
removeInvalid: true // this removes elements that could not be translated to pdf from the source svg
});
pdf.output('datauri'); // use output() to get the jsPDF buffer
Pero no puedo lograrlo ... Y amablemente me aconsejen ... Cómo resolver este problema enJSPDF