定制 phpcfdi/cfditopdf 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

phpcfdi/cfditopdf

最新稳定版本:v0.5.0

Composer 安装命令:

composer require phpcfdi/cfditopdf

包简介

Create a generic PDF file from a CFDI 3.3 & 4.0 (CLI included)

README 文档

README

Source Code Packagist PHP Version Support Discord Latest Version Software License Build Status Reliability Maintainability Code Coverage Violations Total Downloads Docker Downloads

Create a generic PDF file from a CFDI 3.3 & 4.0

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 [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
  -f, --fonts-dir           Path where TCPDF fonts are located
  -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 suffix ".pdf" extension

Basic usage from docker

docker run -it --rm --user="$(id -u):$(id -g)" cfditopdf --help

See more information on the Docker README file.

Basic usage as a PHP library

<?php declare(strict_types=1);

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

// clean cfdi
$xml = \PhpCfdi\CfdiCleaner\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');

To change the way data is translated from CfdiData to HTML you could provide a specialized translator to Html2PdfBuilder when the object is constructed.

In the following example is using the default HTML translator that uses Plates, only changing the directory where templates are located and the template name. The expected result must be compatible with Html2Pdf.

<?php declare(strict_types=1);
$htmlTranslator = new \PhpCfdi\CfdiToPdf\Builders\HtmlTranslators\PlatesHtmlTranslator(
    'directory_where_templates_are_located',
    'main_template_name'
);
$converter = new \PhpCfdi\CfdiToPdf\Converter(
    new \PhpCfdi\CfdiToPdf\Builders\Html2PdfBuilder($htmlTranslator)
);

PHP Support

This library is compatible with at least the oldest PHP Supported Version with active support. Please, try to use PHP full potential.

We adhere to Semantic Versioning. We will not introduce any compatibility backwards change on major versions.

Internal classes (using @internal annotation) are not part of this agreement as they must only exist inside this project. Do not use them in your project.

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 © PHPCFDI and licensed for use under the MIT License (MIT). Please see LICENSE for more information.

统计信息

  • 总下载量: 40.02k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 42
  • 点击次数: 2
  • 依赖项目数: 4
  • 推荐数: 0

GitHub 信息

  • Stars: 41
  • Watchers: 4
  • Forks: 22
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 未知

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固