PHPackages                             sim-pdf/sim-pdf-libs - 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. sim-pdf/sim-pdf-libs

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

sim-pdf/sim-pdf-libs
====================

Advanced PDF generation library for Laravel with multi-page support, custom page breaks, headers/footers, and comprehensive styling

10PHP

Since Oct 21Pushed 6mo agoCompare

[ Source](https://github.com/5u00n/sim-pdf-libs)[ Packagist](https://packagist.org/packages/sim-pdf/sim-pdf-libs)[ RSS](/packages/sim-pdf-sim-pdf-libs/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

SimPDF Library
==============

[](#simpdf-library)

A comprehensive PDF generation library for Laravel with advanced features including multi-page support, custom page breaks, headers/footers, and full styling capabilities.

Features
--------

[](#features)

- 🚀 **Multi-page Support** - Handle large documents with automatic pagination
- 📄 **Custom Page Breaks** - Break pages anywhere you want, even within tables
- 📊 **Table Pagination** - Smart table breaking with repeated headers
- 🔢 **Page Numbering** - Automatic page numbering with custom formats
- 📋 **Headers &amp; Footers** - Customizable headers and footers for each page
- 🎨 **Advanced Styling** - Full CSS support including Microsoft Word-like formatting
- 💧 **Watermarks** - Add watermarks to your PDFs
- 🔖 **Bookmarks** - Create PDF bookmarks for navigation
- 📝 **Metadata** - Set PDF metadata (title, author, subject, etc.)
- ⚡ **Performance** - Optimized for large documents and high performance

🚀 Installation
--------------

[](#-installation)

### Packagist Installation (Recommended)

[](#packagist-installation-recommended)

```
# Install from Packagist
composer require sim-pdf/sim-pdf-libs

# Publish config (optional)
php artisan vendor:publish --provider="SimPdf\SimPdfLibs\SimPdfServiceProvider" --tag="config"
```

### One-Command Installer

[](#one-command-installer)

```
# Download and run installer (from your Laravel project root)
curl -O https://raw.githubusercontent.com/5u00n/sim-pdf-libs/main/install-simpdf.php && php install-simpdf.php
```

### Git Installation

[](#git-installation)

```
# Install from Git repository
composer config repositories.sim-pdf vcs https://github.com/5u00n/sim-pdf-libs
composer require sim-pdf/sim-pdf-libs:dev-main
```

🎯 Quick Start
-------------

[](#-quick-start)

### Basic PDF (3 lines!)

[](#basic-pdf-3-lines)

```
use SimPdf\SimPdfLibs\Facades\SimPdf;

$html = 'Hello WorldThis is a PDF!';
return SimPdf::loadHtml($html)->download('document.pdf');
```

### Test Installation

[](#test-installation)

After installation, visit: `http://your-app.test/simpdf/test`

🎯 When to Use SimPDF
--------------------

[](#-when-to-use-simpdf)

### ✅ **Perfect For:**

[](#-perfect-for)

- **📊 Reports &amp; Invoices** - Professional business documents
- **📋 Contracts &amp; Legal Docs** - Multi-page documents with headers/footers
- **📚 Manuals &amp; Guides** - Large documents with bookmarks and page numbers
- **📈 Data Reports** - Tables with pagination and custom breaks
- **🎨 Styled Documents** - Microsoft Word-like formatting
- **📄 Forms &amp; Applications** - Complex layouts with styling
- **📑 Catalogs &amp; Brochures** - Multi-page marketing materials
- **📊 Financial Statements** - Professional financial documents

### ❌ **Not Ideal For:**

[](#-not-ideal-for)

- **🖼️ Image-heavy PDFs** - Use specialized image-to-PDF tools
- **📱 Interactive PDFs** - Use Adobe Acrobat or similar
- **🎬 Video/Audio PDFs** - Use multimedia PDF tools
- **📊 Complex Charts** - Use chart-specific libraries first

### 🚀 **Best Use Cases:**

[](#-best-use-cases)

#### 1. **Business Reports**

[](#1-business-reports)

```
// Perfect for monthly/quarterly reports
SimPdf::loadHtml($reportHtml)
    ->setPaper('A4', 'portrait')
    ->enablePageNumbers()
    ->setHeader('Monthly Report - ' . date('F Y'))
    ->setFooter('Confidential - Page {PAGE_NUM}')
    ->download('monthly-report.pdf');
```

#### 2. **Invoice Generation**

[](#2-invoice-generation)

```
// Perfect for invoices with line items
SimPdf::loadHtml($invoiceHtml)
    ->breakTable(['repeat_header' => true])
    ->setHeader('INVOICE #' . $invoiceNumber)
    ->setFooter('Payment due within 30 days')
    ->download('invoice.pdf');
```

#### 3. **User Manuals**

[](#3-user-manuals)

```
// Perfect for documentation with bookmarks
SimPdf::loadHtml($manualHtml)
    ->addBookmark('Introduction', 1)
    ->addBookmark('Installation', 1)
    ->addBookmark('Configuration', 1)
    ->addBookmark('Troubleshooting', 1)
    ->enablePageNumbers()
    ->download('user-manual.pdf');
```

📚 Real-World Usage Examples
---------------------------

[](#-real-world-usage-examples)

### 1. **Employee Report Card**

[](#1-employee-report-card)

```
// Perfect for HR reports with multiple pages
$html = view('reports.employee-card', [
    'employee' => $employee,
    'performance' => $performanceData,
    'goals' => $goals
])->render();

return SimPdf::loadHtml($html)
    ->setPaper('A4', 'portrait')
    ->enablePageNumbers(['position' => 'bottom-center'])
    ->setHeader('Employee Performance Report')
    ->setFooter('Confidential - HR Department')
    ->addWatermark('CONFIDENTIAL', ['opacity' => 0.1])
    ->download('employee-report-' . $employee->id . '.pdf');
```

### 2. **Product Catalog**

[](#2-product-catalog)

```
// Perfect for e-commerce catalogs
$html = view('catalog.products', [
    'products' => $products,
    'categories' => $categories
])->render();

return SimPdf::loadHtml($html)
    ->setPaper('A4', 'portrait')
    ->breakTable(['repeat_header' => true, 'min_rows' => 3])
    ->setHeader('Product Catalog 2024')
    ->setFooter('Visit our website for more products')
    ->addBookmark('Electronics', 1)
    ->addBookmark('Clothing', 1)
    ->addBookmark('Home & Garden', 1)
    ->download('product-catalog.pdf');
```

### 3. **Financial Statement**

[](#3-financial-statement)

```
// Perfect for financial documents
$html = view('financial.statement', [
    'revenue' => $revenueData,
    'expenses' => $expensesData,
    'balance' => $balanceSheet
])->render();

return SimPdf::loadHtml($html)
    ->setPaper('A4', 'landscape')
    ->breakTable(['repeat_header' => true])
    ->setHeader('Financial Statement - Q' . $quarter . ' ' . $year)
    ->setFooter('Prepared by: ' . auth()->user()->name)
    ->addWatermark('DRAFT', ['opacity' => 0.3, 'color' => '#ff0000'])
    ->setMetadata([
        'Title' => 'Financial Statement',
        'Author' => auth()->user()->name,
        'Subject' => 'Quarterly Financial Report'
    ])
    ->download('financial-statement-q' . $quarter . '.pdf');
```

### 4. **Contract Document**

[](#4-contract-document)

```
// Perfect for legal documents
$html = view('contracts.agreement', [
    'contract' => $contract,
    'parties' => $parties,
    'terms' => $terms
])->render();

return SimPdf::loadHtml($html)
    ->setPaper('A4', 'portrait')
    ->addPageBreak('page', ['before' => '.contract-section'])
    ->setHeader('Service Agreement - ' . $contract->number)
    ->setFooter('Page {PAGE_NUM} of {PAGE_COUNT} - Legal Document')
    ->addBookmark('Parties', 1)
    ->addBookmark('Terms & Conditions', 1)
    ->addBookmark('Payment Terms', 1)
    ->addBookmark('Signatures', 1)
    ->download('contract-' . $contract->number . '.pdf');
```

📚 Advanced Usage
----------------

[](#-advanced-usage)

### Multi-page PDF with Headers and Footers

[](#multi-page-pdf-with-headers-and-footers)

```
$html = '

Multi-page Document

    Page 1
    Content for page 1...

    Page 2
    Content for page 2...

';

SimPdf::loadHtml($html)
    ->setPaper('A4', 'portrait')
    ->enablePageNumbers([
        'position' => 'bottom-right',
        'format' => 'Page {PAGE_NUM} of {PAGE_COUNT}'
    ])
    ->setHeader('Company Header', [
        'height' => '60px',
        'background' => '#f8f9fa'
    ])
    ->setFooter('© 2024 Company Name', [
        'height' => '40px',
        'background' => '#f8f9fa'
    ])
    ->download('multi-page-document.pdf');
```

### Advanced Table with Custom Breaks

[](#advanced-table-with-custom-breaks)

```
$html = '

            Name
            Email
            Department

';

SimPdf::loadHtml($html)
    ->setPaper('A4', 'portrait')
    ->breakTable([
        'repeat_header' => true,
        'min_rows' => 5,
        'max_rows' => 20
    ])
    ->addStyle('
        .breakable-table {
            page-break-inside: auto;
        }
        .breakable-table thead {
            display: table-header-group;
        }
        .breakable-table tbody {
            page-break-inside: avoid;
        }
    ')
    ->download('table-document.pdf');
```

Advanced Features
-----------------

[](#advanced-features)

### Custom Page Breaks

[](#custom-page-breaks)

```
// Break before specific element
SimPdf::loadHtml($html)
    ->addPageBreak('page', ['before' => 'New Section'])
    ->download('document.pdf');

// Break after specific element
SimPdf::loadHtml($html)
    ->addPageBreak('page', ['after' => ''])
    ->download('document.pdf');

// Avoid breaking inside elements
SimPdf::loadHtml($html)
    ->addPageBreak('avoid', ['element' => '.no-break'])
    ->download('document.pdf');
```

### Watermarks and Bookmarks

[](#watermarks-and-bookmarks)

```
SimPdf::loadHtml($html)
    ->addWatermark('CONFIDENTIAL', [
        'opacity' => 0.3,
        'font-size' => '48px',
        'color' => '#ff0000',
        'rotation' => -45
    ])
    ->addBookmark('Introduction', 1)
    ->addBookmark('Details', 1)
    ->addBookmark('Summary', 1)
    ->download('document.pdf');
```

### Metadata and Styling

[](#metadata-and-styling)

```
SimPdf::loadHtml($html)
    ->setMetadata([
        'Title' => 'My Document',
        'Author' => 'John Doe',
        'Subject' => 'Important Document',
        'Keywords' => 'PDF, Laravel, Document'
    ])
    ->addStyle('
        body { font-family: Arial, sans-serif; }
        h1 { color: #2c3e50; }
        .highlight { background-color: #ffff00; }
    ')
    ->download('document.pdf');
```

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

[](#configuration)

The package comes with a comprehensive configuration file at `config/simpdf.php`. You can customize:

- Default paper size and orientation
- Font settings and caching
- Page break behavior
- Header and footer defaults
- Page numbering format
- Watermark settings
- Performance options
- Security settings

Laravel Integration
-------------------

[](#laravel-integration)

### Controller Example

[](#controller-example)

```
