Giter Site home page Giter Site logo

cfditopdf's Introduction

phpcfdi/cfditopdf

Source Code Latest Version Software License Build Status Scrutinizer Coverage Status Total Downloads

Create a generic PDF file from a CFDI 3.3

In some cases you just simply need a PDF file from a Mexican CFDI (Comprobante Fiscal Digital por Internet). This tool help you to create a generic one. You can also use it to build your own and pretty formats.

Installation

Use composer, so please run

composer require phpcfdi/cfditopdf

Basic usage from CLI

$ bin/cfditopdf --help
bin/cfditopdf [options] <cfdi-file> [<pdf-file>]
  -h, --help                Show this help
  -v, --version             Show command version
  -d, --dirty               Do not try to clean up the cfdi file
  -l, --resource-location   Use this path to store the xml resources locally,
                            if none then it will always download xlst resources
  cfdi-file                 Path of the XML file (input file)
  pdf-file                  Path of the PDF file (output file) if none then it will remove
                            ".xml" extension and sufix ".pdf" extension

Basic usage as a PHP library

<?php declare(strict_types=1);

$cfdifile = 'datafiles/cfdi.xml';
$xml = file_get_contents($cfdifile);

// clean cfdi
$xml = \CfdiUtils\Cleaner\Cleaner::staticClean($xml);

// create the main node structure
$comprobante = \CfdiUtils\Nodes\XmlNodeUtils::nodeFromXmlString($xml);

// create the CfdiData object, it contains all the required information
$cfdiData = (new \PhpCfdi\CfdiToPdf\CfdiDataBuilder())
    ->build($comprobante);

// create the converter
$converter = new \PhpCfdi\CfdiToPdf\Converter(
    new \PhpCfdi\CfdiToPdf\Builders\Html2PdfBuilder()
);

// create the invoice as output.pdf
$converter->createPdfAs($cfdiData, 'output.pdf');

PHP Support

This library is compatible with PHP versions 7.0 and above. Please, try to use the full potential of the language.

Contributing

Contributions are welcome! Please read CONTRIBUTING for details and don't forget to take a look in the TODO and CHANGELOG files.

Copyright and License

The phpcfdi/cfditopdf library is copyright © Carlos C Soto and licensed for use under the MIT License (MIT). Please see LICENSE for more information.

cfditopdf's People

Contributors

eclipxe13 avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.