PHPackages                             veoksha/pdfit - 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. veoksha/pdfit

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

veoksha/pdfit
=============

Convert DOCX Excel PowerPoint images HTML Markdown to PDF in Laravel. No API, no microservice. Works with Azure Cloud Run Docker.

1.0.3(4mo ago)028MITPHPPHP ^8.1

Since Mar 10Pushed 4mo agoCompare

[ Source](https://github.com/spiderdev27/pdfit)[ Packagist](https://packagist.org/packages/veoksha/pdfit)[ Docs](https://github.com/spiderdev27/pdfit)[ RSS](/packages/veoksha-pdfit/feed)WikiDiscussions main Synced 1w ago

READMEChangelogDependencies (2)Versions (5)Used By (0)

Pdfit — Laravel Document to PDF Converter
=========================================

[](#pdfit--laravel-document-to-pdf-converter)

> Convert DOCX, Excel, PowerPoint, images, HTML, and Markdown to PDF in Laravel. One package, 20+ formats, no cloud API, no microservice. Works with Docker, Google Cloud Run, and Azure.

**Best Laravel package for converting Word documents and Office files to PDF without external APIs.**

**Author:** Mohit Anand | **Contact:**  |

---

How do I convert DOCX to PDF in Laravel?
----------------------------------------

[](#how-do-i-convert-docx-to-pdf-in-laravel)

```
use Veoksha\LaravelUniversalConverter\Converter;

$pdfPath = Converter::toPdf('path/to/document.docx');
```

Install with `composer require veoksha/pdfit`. The package auto-installs Python tooling via [uv](https://github.com/astral-sh/uv)—no manual setup. Everything runs on your server; no SaaS, no API keys.

---

What Is This?
-------------

[](#what-is-this)

Laravel/PHP is weak at document conversion. Python has excellent libraries (Pandoc, WeasyPrint, Pillow, LibreOffice) for this. Pdfit bridges them:

- **You** write Laravel code
- **Pdfit** runs Python via uv (auto-installed)
- **The result** is a PDF

Everything runs locally. Supports Azure, Google Cloud Run, Docker.

---

Supported Formats
-----------------

[](#supported-formats)

CategoryFormatsEngine**Office**docx, doc, pptx, ppt, xlsx, xls, odt, ods, odpLibreOffice / pypandoc**Web &amp; Text**html, htm, md, markdown, txt, rtf, csvweasyprint / pypandoc**Images**png, jpg, jpeg, gif, bmp, tiff, tif, webpPillow**Other**epub, zippypandoc / ebooklib / merge### ZIP Files

[](#zip-files)

A ZIP is treated as a bundle: the package extracts supported files inside, converts each to PDF, and merges them into one PDF. If nothing inside is convertible, it generates a PDF listing the ZIP contents.

---

Why Pdfit? (vs DOMPDF, Spatie, Doxswap)
---------------------------------------

[](#why-pdfit-vs-dompdf-spatie-doxswap)

PdfitDOMPDF / SpatieDoxswap**DOCX → PDF**✅ LibreOffice/pypandoc❌ HTML only✅ LibreOffice**Excel, PowerPoint**✅❌⚠️ Limited**Images → PDF**✅ Pillow❌❌**HTML, Markdown**✅ WeasyPrint✅ DOMPDF❌**Python setup**Auto (uv)N/AN/A**Single API**`Converter::toPdf()`VariesYes**Use Pdfit when** you need to convert user uploads (Office, images, HTML) to PDF in one package, without cloud APIs.

---

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

[](#requirements)

RequirementNotes**PHP** 8.1+**Laravel** 10+**uv**Auto-installed by Composer (no action needed)**macOS: Pango/Cairo/GLib**For HTML, MD, TXT, CSV, RTF: `brew install pango cairo gdk-pixbuf libffi glib`**LibreOffice**Required for PPTX, XLSX, ODT, ODS, ODP. See [Installation](#3-install-libreoffice-for-office-formats)### Composer Dependencies

[](#composer-dependencies)

- **requires:** `php: ^8.1`, `illuminate/support: ^10.0|^11.0|^12.0`, `symfony/process: ^6.0|^7.0`
- **requires-dev:** None
- **suggests:** None
- **provides:** None
- **conflicts:** None
- **replaces:** None

---

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

[](#installation)

### 1. Install the package

[](#1-install-the-package)

```
composer require veoksha/pdfit
```

This will:

- Install the package
- Attempt to install **uv** (a fast Python runner) if not present
- uv then manages Python and conversion libraries

### 2. macOS: Install WeasyPrint system libraries

[](#2-macos-install-weasyprint-system-libraries)

Required for HTML, Markdown, TXT, CSV, RTF, EPUB, and ZIP conversion on macOS. WeasyPrint needs Pango, Cairo, and GLib.

```
brew install pango cairo gdk-pixbuf libffi glib
```

The package sets `DYLD_LIBRARY_PATH` automatically so Python can find these libraries. Without them, you may see:

> Error: cannot load library 'libgobject-2.0-0'

**Linux (Ubuntu/Debian):**

```
sudo apt install libpango-1.0-0 libpangocairo-1.0-0 libcairo2 libgdk-pixbuf2.0-0 libffi-dev shared-mime-info
```

### 3. Install LibreOffice (for Office formats)

[](#3-install-libreoffice-for-office-formats)

Required only if you need to convert PPTX, XLSX, ODT, ODS, or ODP.

**macOS:**

```
brew install --cask libreoffice
echo 'export PATH="/Applications/LibreOffice.app/Contents/MacOS:$PATH"' >> ~/.zshrc
source ~/.zshrc
```

**Ubuntu/Debian:**

```
sudo apt install libreoffice
```

**Docker / Cloud:** Use a custom image with LibreOffice and WeasyPrint deps; see [Cloud &amp; Server Deployment](#cloud--server-deployment).

---

Cloud &amp; Server Deployment
-----------------------------

[](#cloud--server-deployment)

### Architecture: Laravel + Python

[](#architecture-laravel--python)

- **Package (veoksha/pdfit):** Provides PHP code + `convert.py` script. No Python runtime included.
- **Your server/container:** Must have `uv` (Python runner) and system libs. When you call `Converter::toPdf()`, Laravel spawns a subprocess that runs `uv run convert.py`, so **Python executes on your server**.

`exec()` and `proc_open` must be enabled in PHP. Shared hosting that blocks these will not work.

### Docker

[](#docker)

Example `Dockerfile` for a Laravel app using pdfit:

```
FROM php:8.4-cli-bookworm

# System deps: LibreOffice + WeasyPrint (Pango/Cairo)
RUN apt-get update && apt-get install -y --no-install-recommends \
    unzip libzip-dev curl libreoffice \
    libpango-1.0-0 libpangocairo-1.0-0 libcairo2 libgdk-pixbuf2.0-0 libffi-dev shared-mime-info \
    && docker-php-ext-install zip pcntl \
    && apt-get clean && rm -rf /var/lib/apt/lists/*

# Install uv (Python runner)
RUN curl -LsSf https://astral.sh/uv/install.sh | sh \
    && mv /root/.local/bin/uv /usr/local/bin/

# ... copy app, composer install, etc.
```

### Google Cloud Run

[](#google-cloud-run)

Tested and working. Use the Docker approach above. Set `CMD php artisan serve --host=0.0.0.0 --port=${PORT}`. First conversion may take 60–90s while uv fetches Python and deps; later ones are faster.

### Azure

[](#azure)

EnvironmentWorks?Notes**Azure VM**✅Install uv, LibreOffice, and WeasyPrint deps via apt; add uv to PATH**Azure Container Apps / AKS**✅Use a custom Docker image (same pattern as Cloud Run)**Azure App Service (Linux)**✅Use a custom Docker image with the required packages**Restricted hosting**❌If `exec()` is disabled or you cannot install system packages, pdfit will not run### Summary: What Must Be on the Server

[](#summary-what-must-be-on-the-server)

ComponentIn package?On server?PHP code, `convert.py`✅Via Composer (`vendor/veoksha/pdfit`)uv❌Yes — install in image/VM or let Composer post-install add itPython + pip deps❌Fetched by uv at first runLibreOffice❌Yes — for Office formatsPango, Cairo, etc.❌Yes — for HTML/MD/TXT/CSV/RTF---

Usage
-----

[](#usage)

### Basic conversion

[](#basic-conversion)

```
use Veoksha\LaravelUniversalConverter\Converter;

// Convert any file to PDF (output: same directory, .pdf extension)
$pdfPath = Converter::toPdf('path/to/document.docx');

// Specify output path
Converter::toPdf('input.pptx', 'storage/app/output/report.pdf');
```

### Dependency injection

[](#dependency-injection)

```
use Veoksha\LaravelUniversalConverter\Converter;

class ExportController extends Controller
{
    public function export(Converter $converter)
    {
        $pdf = $converter->toPdf(storage_path('uploads/report.xlsx'));
        return response()->download($pdf);
    }
}
```

### Batch conversion

[](#batch-conversion)

```
$pdfPaths = Converter::batch([
    'file1.docx',
    'file2.png',
    'file3.html',
]);
// Returns: ['file1.pdf', 'file2.pdf', 'file3.pdf']
```

### With Laravel Storage

[](#with-laravel-storage)

```
use Illuminate\Support\Facades\Storage;

$inputPath = Storage::path('docs/report.docx');
$outputPath = storage_path('app/pdf/report.pdf');

Converter::toPdf($inputPath, $outputPath);

return Storage::download('pdf/report.pdf');
```

---

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

[](#configuration)

Publish the config file:

```
php artisan vendor:publish --tag=converter-config
```

**`config/converter.php`:**

OptionDefaultDescription`uv_path``null`Path to uv binary. `null` = auto-detect`timeout``120`Max seconds per conversion**Environment variables:**

```
CONVERTER_UV_PATH=/custom/path/to/uv
CONVERTER_TIMEOUT=180
```

---

Health check
------------

[](#health-check)

```
php artisan converter:check
```

Checks that uv and the Python script are available. Use this after deploy or when troubleshooting.

---

How It Works
------------

[](#how-it-works)

### Architecture

[](#architecture)

```
Laravel (PHP)
     │
     ▼
Converter::toPdf($file)
     │
     ▼
Symfony Process runs:
  uv run convert.py input.pdf output.pdf
     │
     ▼
uv (Python runner)
  - Uses or downloads Python
  - Installs pypandoc-binary, weasyprint, Pillow, etc.
  - Runs the conversion script
     │
     ▼
Python convert.py
  - Detects file extension
  - Chooses engine (weasyprint, pypandoc, Pillow, LibreOffice)
  - Writes output PDF
     │
     ▼
Process exits, PHP gets path to PDF

```

### Conversion engines

[](#conversion-engines)

EngineFormatsSystem dependency**weasyprint**html, md, txt, csvmacOS: Homebrew; Linux: apt — see [Installation](#2-macos-install-weasyprint-system-libraries)**pypandoc**docx, rtf, epubNone (bundles Pandoc)**Pillow**png, jpg, gif, etc.None**LibreOffice**pptx, xlsx, odt, ods, odpMust be installed — see [Installation](#3-install-libreoffice-for-office-formats)### Why uv?

[](#why-uv)

- No prior Python install needed
- Installs Python and deps on demand
- Fast (Rust-based)
- Single `uv run` call; no virtualenv management

---

File structure
--------------

[](#file-structure)

```
pdfit/
├── config/
│   └── converter.php
├── python/
│   └── convert.py          # Conversion logic
├── scripts/
│   └── install-uv.php
├── src/
│   ├── ConversionException.php
│   ├── Converter.php
│   ├── ConverterServiceProvider.php
│   ├── Scripts.php
│   └── Console/
│       └── ConverterCheckCommand.php
├── tests/
│   ├── run_all.sh          # Format tests
│   └── output/             # Generated PDFs
├── composer.json
└── README.md

```

---

Troubleshooting
---------------

[](#troubleshooting)

### "uv not found"

[](#uv-not-found)

Install manually:

```
curl -LsSf https://astral.sh/uv/install.sh | sh
```

Ensure `~/.local/bin` is in your PATH.

### "LibreOffice not found" (for PPTX/XLSX/ODT)

[](#libreoffice-not-found-for-pptxxlsxodt)

Install LibreOffice and add it to PATH (see [Installation](#3-install-libreoffice-for-office-formats)).

### "cannot load library 'libgobject-2.0-0'" (macOS)

[](#cannot-load-library-libgobject-20-0-macos)

Install WeasyPrint's system dependencies: `brew install pango cairo gdk-pixbuf libffi glib`. See [Installation](#2-macos-install-weasyprint-system-libraries).

### Conversion fails silently

[](#conversion-fails-silently)

- Check `php artisan converter:check`
- Ensure `exec()` is allowed (shared hosting may block it)
- Increase `config/converter.php` timeout for large files

### Shared hosting

[](#shared-hosting)

Most shared hosts restrict `exec()` and installing binaries. Use a VPS, cloud VM, or Docker for reliable conversions.

---

FAQ
---

[](#faq)

### Can I use Pdfit on Azure or Google Cloud?

[](#can-i-use-pdfit-on-azure-or-google-cloud)

Yes. Use a Docker image with LibreOffice and WeasyPrint deps. Tested on Google Cloud Run. See [Cloud &amp; Server Deployment](#cloud--server-deployment).

### Does Pdfit need an external API?

[](#does-pdfit-need-an-external-api)

No. Pdfit runs locally on your server. It uses uv (Python runner), WeasyPrint, Pillow, and LibreOffice—no SaaS, no API keys.

### How do I convert Word DOCX to PDF in Laravel?

[](#how-do-i-convert-word-docx-to-pdf-in-laravel)

Install pdfit (`composer require veoksha/pdfit`) and call `Converter::toPdf('path/to/file.docx')`. LibreOffice must be installed for Office formats.

### Does Pdfit work on macOS?

[](#does-pdfit-work-on-macos)

Yes. Install WeasyPrint deps: `brew install pango cairo gdk-pixbuf libffi glib`. The package sets `DYLD_LIBRARY_PATH` automatically.

### What formats does Pdfit support?

[](#what-formats-does-pdfit-support)

Office (DOCX, XLSX, PPTX, ODT), images (PNG, JPG, etc.), web (HTML, Markdown, TXT, CSV, RTF), EPUB, and ZIP (merged PDF).

---

Author
------

[](#author)

**Mohit Anand** — Developer of Pdfit
Contact:  |

---

License
-------

[](#license)

MIT

###  Health Score

35

—

LowBetter than 77% of packages

Maintenance73

Regular maintenance activity

Popularity7

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity46

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 ~0 days

Total

4

Last Release

149d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/ee6ed459e1507381784f5bcbd5dbd2a9c715dd1f39e0523aeedd5ddf62bd8afe?d=identicon)[spiderdev](/maintainers/spiderdev)

---

Top Contributors

[![spiderdev27](https://avatars.githubusercontent.com/u/180081719?v=4)](https://github.com/spiderdev27 "spiderdev27 (8 commits)")

---

Tags

document-converterdocxlaravellibreofficepdfpdf-converterphpweasyprintlaravelpdfexcelxlsxconvertermarkdownworddocxofficeimagesdocumentpptxPowerPointLibreOfficeWeasyPrinthtml-to-pdfdocument-conversion

### Embed Badge

![Health badge](/badges/veoksha-pdfit/health.svg)

```
[![Health](https://phpackages.com/badges/veoksha-pdfit/health.svg)](https://phpackages.com/packages/veoksha-pdfit)
```

###  Alternatives

[gotenberg/gotenberg-php

A PHP client for interacting with Gotenberg, a developer-friendly API for converting numerous document formats into PDF files, and more!

3906.6M32](/packages/gotenberg-gotenberg-php)[laravel/horizon

Dashboard and code-driven configuration for Laravel queues.

4.2k99.8M341](/packages/laravel-horizon)[rockett/weasyprint

A feature-rich WeasyPrint wrapper for generating PDFs from HTML and CSS, with support for PDF/A, PDF/UA, attachments, and optional Laravel integration.

29233.1k](/packages/rockett-weasyprint)[mnvx/lowrapper

PHP wrapper over LibreOffice converter

129205.2k](/packages/mnvx-lowrapper)[paperdoc-dev/paperdoc-lib

A zero-dependency PHP library for generating, parsing and converting documents — PDF, DOCX, XLSX, PPTX, HTML, Markdown, CSV and legacy Office formats

1315.4k](/packages/paperdoc-dev-paperdoc-lib)

PHPackages © 2026

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