1.0.7 • Published 3 years ago

@ocelotlstudio/cfdi-pdf v1.0.7

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

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

1.0.2

3 years ago

1.0.7

3 years ago

1.0.6

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago