Pdf examples with jsPDF


#1

Hi,
whith a non visula plugin
with

this.getReactWebPackages = function() {
// Return dependencies that need to be included in the exported project’s package.json file.
// Each key is an npm package name that must be imported, and the value is the package version.
//
// Example:
// return { “somepackage”: “^1.2.3” }

return {“jspdf”:"^1.5.3",“jspdf-autotable”:"^3.1.2"}
}

this.writesCustomReactWebComponent = false;

this.getReactWebComponentName = function() {
// Preferred class name for this component.
// The exporter may still need to modify this (e.g. if there already is a component by this name),
// so in the actual export method below, we must use the className value provided as a parameter.
return “testnonvisual”;
}

this.getReactWebImports = function(exporter) {
var arr = [
{ varName : “{jspdf}”, path : “jspdf” } ,{ varName : “{autotable}”, path : “jspdf-autotable” }
];
return arr;
}

and with some js
whe can make pdf reports…

var jsPDF = require(‘jspdf’);
var doc = new jsPDF()
/*
doc.setFontSize(40)
doc.text(35, 25, ‘Rapporto di intervento’)
doc.addImage(imgData, ‘JPEG’, 15, 40, 180, 160)
*/

var doc = new jsPDF();

// From HTML
doc.autoTable({html: '.table'});

// From Javascript
let finalY = doc.previousAutoTable.finalY;
doc.text("Rapporto di servizio", 14, finalY + 15);
doc.autoTable({
    startY: finalY + 20,
    head: [
        ['ID', 'Name', 'Email', 'Country', 'IP-address'],
    ],
    body: [
        ['1', 'Donna', 'dmoore0@furl.net', 'China', '211.56.242.221'],
        ['2', 'Janice', 'jhenry1@theatlantic.com', 'Ukraine', '38.36.7.199'],
        ['3', 'Ruth', 'rwells2@constantcontact.com', 'Trinidad and Tobago', '19.162.133.184'],
        ['4', 'Jason', 'jray3@psu.edu', 'Brazil', '10.68.11.42'],
        ['5', 'Jane', 'jstephens4@go.com', 'United States', '47.32.129.71'],
        ['6', 'Adam', 'anichols5@com.com', 'Canada', '18.186.38.37']
    ],
});

finalY = doc.previousAutoTable.finalY;
doc.text("From HTML with CSS", 14, finalY + 15);
doc.autoTable({
    startY: finalY + 20,
    html: '.table',
    useCss: true,
});

//doc.save(‘a4.pdf’)
window.open(doc.output(‘bloburl’))
//doc.output(‘dataurlnewwindow’);