@ocelotlstudio/cfdi-pdf
v1.0.7
Published
Creates a pdf based on an XML CFDI
Downloads
75
Readme
cfdi-pdf
A small library for generate xml CFDI 3.3 to PDF
How to install
ES6 module
npm install --save @ocelotlstudio/cfdi-pdf
or with yarn
yarn add @ocelotlstudio/cfdi-pdf
Usage
Then you're ready to generate pdf:
Simple Usage
import CfdiPdf from '@ocelotlstudio/cfdi-pdf';
try {
const xmlString = `<?xml version="1.0" encoding="utf-8"?>
<cfdi:Comprobante Version="3.3" ...>
...
</cfdi:Comprobante>`;
/**
* Function to get pdf from valid xml cfdi string
* @param {string} xml
* @param {Options=} options
* @returns {Promise<string>} a pdf in base64 string
*/
const parserData = await CfdiPdf.generatePdf(xmlString);
} catch (e) {
console.log(e);
}
With options
import CfdiPdf from '@ocelotlstudio/cfdi-pdf';
try {
const xmlString = `<?xml version="1.0" encoding="utf-8"?>
<cfdi:Comprobante Version="3.3" ...>
...
</cfdi:Comprobante>`;
const options = {
text: 'onlytest',
image: 'imageinbase64',
cadenaOriginal: 'for visualice correct cadena original',
address: 'receptor address',
};
/**
* Function to get pdf from valid xml cfdi string
* @param {string} xml
* @param {Options=} options
* @returns {Promise<string>} a pdf in base64 string
*/
const parserData = await CfdiPdf.generatePdf(xmlString, options);
} catch (e) {
console.log(e);
}
Features
- Generate PDF from types: I, E, T and P
License
MIT