atgp/factur-x

用于管理您的 Factur-X / ZUGFeRD 2.0 PDF 发票文件的 PHP 库

v2.1.0 2024-02-26 12:42 UTC

This package is auto-updated.

Last update: 2024-08-26 13:47:30 UTC


README

Factur-X 是一种法德电子发票标准,符合欧洲电子发票标准 EN 16931。Factur-X 规范可在 FNFE-MPE 网站上以英文和法语获取。在德国,Factur-X 标准也称为 ZUGFeRD 2.2

此库可让您管理您的 Factur-X PDF 发票文件

  • 从普通 PDF 发票和 Factur-X XML 文件生成 Factur-X PDF 发票
  • 从 Factur-X PDF 发票中提取 Factur-X XML
  • 验证 Factur-X XML 与官方 Factur-X XML 架构定义

目录

需求

  • PHP 7.4+
  • Composer
  • FPDI (MIT 许可)
  • Smalot (LGPL 许可)

安装

使用 Composer 安装

composer require atgp/factur-x

使用方法

您可以从 "tests" 目录中的测试页面查看代码,这里也有一些简单的实现示例

<?php
// Include or autoload (with Composer) all library classes

// Generates Factur-X PDF invoice from PDF and Factur-X XML
$writer = new \Atgp\FacturX\Writer();
$facturxPdf = $writer->generate($pdf, $facturxXml);

// Extracts Factur-X XML
$reader = new \Atgp\FacturX\Reader();
$facturxXml = $reader->extractXML($facturxPdf);

// Validates Factur-X XML against official Factur-X XML Schema Definition 
$validator = new \Atgp\FacturX\XsdValidator();
if (false === ($isValid = $validator->validate($facturxXml)) {
    var_dump($validator->getErrors());
}
// ... or throw exceptions if error(s) are occurred
$validator->validateWithException($facturxXml);

还有更多选项可用,请查看源代码以获取更多信息。

许可证

本项目采用 MIT 许可

变更日志

  • v2.0.0 [BC] : 2023-11-06
    • 需要 php 7.4+
    • 重构类以明确用途
    • 简化 "smalot/pdfparser" 的需求
    • 在生成的 factur-x pdf 中导入外部链接
  • v1.1.0 : 2019-01-09
    • 升级 Factur-x xsd 到 v1.0.06
    • 修复 PDF-A 兼容性问题,关于 endobj 和 ICC 配置文件
  • v1.0.0 : 2019-01-09
    • 需要 php 5.6+
    • 此库的第一个版本,用于读取、检查和编写 factur-x 文档