PHPackages                             pittacusw/parse-bill - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [PDF &amp; Document Generation](/categories/documents)
4. /
5. pittacusw/parse-bill

ActiveLibrary[PDF &amp; Document Generation](/categories/documents)

pittacusw/parse-bill
====================

Wrapper to parse XML Bills and generate a PDF file

v2(3mo ago)099LGPL-3.0PHPPHP ^8.3

Since Mar 24Pushed 3mo ago1 watchersCompare

[ Source](https://github.com/PittacusW/parse-bill)[ Packagist](https://packagist.org/packages/pittacusw/parse-bill)[ RSS](/packages/pittacusw-parse-bill/feed)WikiDiscussions main Synced today

READMEChangelog (2)Dependencies (10)Versions (3)Used By (0)

pittacusw/parse-bill
====================

[](#pittacuswparse-bill)

Laravel package for parsing Chilean DTE XML documents and rendering them as PDF files.

The package is designed around the existing printable layout used by this project. The PDF view contract has been kept intact during the optimization pass so margins, page structure, cedible copy rules, and the legal layout behavior continue to follow the current implementation.

What It Does
------------

[](#what-it-does)

- Parses XML DTE payloads from either a file path or a raw XML string
- Extracts the `Documento` payload into a PHP object structure that the Blade views can render
- Generates the SII TED PDF417 barcode when a TED node is present
- Renders PDF output through `barryvdh/laravel-dompdf`
- Resolves document type, county/SII branch, and additional tax labels from reference tables
- Exposes helpers for reading the document signature value

Requirements
------------

[](#requirements)

- PHP `^8.3`
- Laravel `^13.2`
- Database tables for the reference lookups used by the PDF views

Installation
------------

[](#installation)

```
composer require pittacusw/parse-bill
```

Publish the package assets and run the migrations:

```
php artisan vendor:publish --provider="Pittacusw\ParseBill\ParseBillServiceProvider"
php artisan migrate
```

Seed Required Reference Data
----------------------------

[](#seed-required-reference-data)

The PDF renderer expects lookup data for:

- document types
- counties and SII branches
- additional taxes

Seed the required tables with the included seeders:

```
php artisan db:seed --class="Pittacusw\ParseBill\Seeders\SiiBranchesTableSeeder"
php artisan db:seed --class="Pittacusw\ParseBill\Seeders\CountiesTableSeeder"
php artisan db:seed --class="Pittacusw\ParseBill\Seeders\DocumentsTypesTableSeeder"
php artisan db:seed --class="Pittacusw\ParseBill\Seeders\AdditionalTaxesTableSeeder"
```

Optional seeders are also available for economic activities, reference types, and transfer types.

Configuration
-------------

[](#configuration)

After publishing, the package config file is available at `config/pittacusw-parse-bill.php`.

By default it points to these models:

```
return [
    'county' => \Pittacusw\ParseBill\Models\County::class,
    'documents_type' => \Pittacusw\ParseBill\Models\DocumentsType::class,
    'additional_tax' => \Pittacusw\ParseBill\Models\AdditionalTax::class,
];
```

Override these entries if your application uses custom models for the same tables.

Usage
-----

[](#usage)

### Parse XML

[](#parse-xml)

```
use Pittacusw\ParseBill\ReadXml;

$document = ReadXml::parse($xmlOrPath);
```

`$xmlOrPath` can be:

- an absolute or relative path to an XML file
- a raw XML string

The parser normalizes single `Detalle`, `Referencia`, `DscRcgGlobal`, and `ImptoReten` nodes into arrays so the renderer can iterate them consistently.

### Read the Signature Value

[](#read-the-signature-value)

```
use Pittacusw\ParseBill\ReadXml;

$signature = ReadXml::signature($xmlOrPath);
```

### Generate a PDF

[](#generate-a-pdf)

```
use Pittacusw\ParseBill\ParsePdf;

$pdf = ParsePdf::render($xmlOrPath);

return $pdf->stream('documento.pdf');
```

You can also save or return the binary output:

```
$contents = ParsePdf::render($xmlOrPath)->output();
```

Layout Guarantees
-----------------

[](#layout-guarantees)

This package intentionally preserves the current visual PDF structure:

- the letter-sized PDF output remains the default
- the existing Blade templates and CSS layout contract are preserved
- fixed margin behavior is unchanged
- cedible second-page behavior for DTE types `33`, `34`, and `52` is preserved
- county/SII branch resolution still comes from the configured reference tables

If you need to change layout rules for another legal regime or document standard, do it through dedicated view changes and add fixture-based tests before shipping.

Testing
-------

[](#testing)

The package now includes a PHPUnit + Testbench suite covering:

- XML parsing for both `SetDTE` and direct `Documento` roots
- collection normalization for repeatable DTE nodes
- signature extraction
- Blade lookup directives
- PDF generation smoke tests
- layout-sensitive view contract checks

Run the suite with:

```
composer test
```

Notes
-----

[](#notes)

- The renderer depends on reference-table data being present. Missing document types, counties, or tax codes will lead to incomplete labels in the PDF.
- TED barcode rendering depends on the XML containing a `TED` node and on the barcode library being available in the runtime environment.
- If you customize the PDF view, keep a close eye on page height and overflow because those directly affect the legal printable layout.

###  Health Score

39

—

LowBetter than 84% of packages

Maintenance82

Actively maintained with recent releases

Popularity9

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity50

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~3 days

Total

2

Last Release

97d ago

PHP version history (2 changes)v1PHP ^8.1

v2PHP ^8.3

### Community

Maintainers

![](https://www.gravatar.com/avatar/97c33f4ec07e9426c6c66fe4d0b0840a31823e10992dcd1824bc91982d043ea3?d=identicon)[contal](/maintainers/contal)

---

Top Contributors

[![PittacusW](https://avatars.githubusercontent.com/u/5810290?v=4)](https://github.com/PittacusW "PittacusW (28 commits)")

---

Tags

laraveltouchef

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/pittacusw-parse-bill/health.svg)

```
[![Health](https://phpackages.com/badges/pittacusw-parse-bill/health.svg)](https://phpackages.com/packages/pittacusw-parse-bill)
```

###  Alternatives

[unopim/unopim

UnoPim Laravel PIM

10.5k2.4k](/packages/unopim-unopim)[bagisto/bagisto

Bagisto Laravel E-Commerce

27.6k172.1k9](/packages/bagisto-bagisto)[spatie/laravel-pdf

Create PDFs in Laravel apps

1.0k4.8M47](/packages/spatie-laravel-pdf)[elegantly/laravel-invoices

Store invoices safely in your Laravel application

23546.8k2](/packages/elegantly-laravel-invoices)[fleetbase/fleetops-api

Fleet &amp; Transport Management Extension for Fleetbase

1731.5k7](/packages/fleetbase-fleetops-api)[slimani/filament-media-manager

A media manager plugin for Filament.

126.9k](/packages/slimani-filament-media-manager)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
