PHPackages                             petecoop/odt - 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. [File &amp; Storage](/categories/file-storage)
4. /
5. petecoop/odt

ActiveLibrary[File &amp; Storage](/categories/file-storage)

petecoop/odt
============

Render .odt files with Blade, convert to pdf with Libre/OpenOffice

1.0.2(6mo ago)2834MITPHPCI passing

Since May 11Pushed 6mo ago2 watchersCompare

[ Source](https://github.com/petecoop/odt)[ Packagist](https://packagist.org/packages/petecoop/odt)[ RSS](/packages/petecoop-odt/feed)WikiDiscussions main Synced 6d ago

READMEChangelog (10)Dependencies (9)Versions (22)Used By (0)

ODT
===

[](#odt)

Use Open Document Text (.odt) files as templates in PHP/Laravel projects, rendering them with Blade syntax and outputting as ODT or PDF.

This allows you to create complex document templates in LibreOffice or OpenOffice, including loops and conditionals using Blade syntax, render them with dynamic data and convert into PDF.

### Why

[](#why)

I've found that there are some things that just can't be done when generating PDF's with HTML or PDF libraries that word processors have solved. This is usually where dynamic content can flow over multiple pages, and you want to do things like repeat table headers, or have some items of text stay together, or other more complex layouts like anchoring a section to the bottom of the final page. This also allows non-developers to create and edit document templates in a familiar word processor rather than having to write HTML or code.

### Installation

[](#installation)

```
composer require petecoop/odt
```

### Usage

[](#usage)

#### In Laravel

[](#in-laravel)

Access via the `ODT` facade:

```
use Petecoop\ODT\Facades\ODT;

ODT::open(resource_path("file.odt"))
    ->render([
        "some" => "arguments",
    ]);
```

#### Other PHP Projects

[](#other-php-projects)

Call `ODT::make()` to create an instance:

```
use Petecoop\ODT\ODT;

ODT::make()
    ->open(__DIR__ . "/templates/file.odt")
    ->render([
        "some" => "arguments",
    ]);
```

#### Converting to PDF

[](#converting-to-pdf)

Conversion can be done using either the `soffice` binary directly, or via a [Gotenberg](https://gotenberg.dev/) server. `soffice` is the default and is slower due to the overhead of starting the LibreOffice process for each conversion, but requires no additional setup (other than installing LibreOffice). Gotenberg is faster for multiple conversions as it keeps a LibreOffice process running in the background, but requires a Gotenberg server to be running.

#### Using `soffice` for conversion

[](#using-soffice-for-conversion)

The `soffice` binary is required to be installed for PDF conversion. This should be available if LibreOffice or OpenOffice is installed on the system.

To convert to PDF, use the `pdf()` method after rendering.

```
$pdf = ODT::open(resource_path("file.odt"))
    ->render([
        "some" => "arguments",
    ])
    ->pdf();
```

If `soffice` is not in the system PATH, you can specify the path to the binary using the `officeBinary` method:

```
ODT::officeBinary('/path/to/soffice')
    ->open(resource_path("file.odt"));

// if using ODT::make()
ODT::make('/path/to/soffice')
    ->open(__DIR__ . "/templates/file.odt");
```

#### Using Gotenberg for conversion

[](#using-gotenberg-for-conversion)

To use Gotenberg for PDF conversion, you need to have a Gotenberg server running. You can specify the Gotenberg server URL using the `gotenberg` method:

```
$pdf = ODT::gotenberg('http://localhost:3000')
    ->open(resource_path("file.odt"))
    ->render([
        "some" => "arguments",
    ])
    ->pdf();
```

A HTTP Client is required to be installed, if outside of Laravel you can install the Guzzle client:

```
composer require php-http/guzzle7-adapter
```

See a full [list of clients](https://docs.php-http.org/en/latest/clients.html) if you'd like to use a different one.

#### Saving or Downloading

[](#saving-or-downloading)

The resulting .odt or PDF file can be saved to disk or returned as a download response:

```
$odt = ODT::open(resource_path("file.odt"))
    ->render([
        "some" => "arguments",
    ]);

// Save ODT file
$odt->save(storage_path("file.odt"));

// Convert to PDF and save
$pdf = $odt->pdf()->save(storage_path("file.pdf"));

// Return as download response in a Laravel Controller
return $pdf;
```

### Templating

[](#templating)

Some Blade directives are provided to help with common templating tasks in ODT files.

### Image Embedding

[](#image-embedding)

Use the `@image` directive to embed base64 encoded images into your ODT templates. This directive accepts a base64 image string and optional maximum width and height parameters (in cm).

```
@image($base64ImageString, '5cm', '5cm')
```

#### Table Rows

[](#table-rows)

When in Libre/Open Office you can't wrap a `@foreach` around a table row - use `@rowforeach`, this can be done inside a table cell. The entire row will be repeated for each item.

```
@rowforeach($users as $user)
{{ $user->name }}
```

All other cells in the row will have access to the `$user` variable.

`@rowif` can be used to conditionally include a table row based on an expression. This is useful if you want to display a row only when certain conditions are met.

```
@rowif($product->description)
{{ $product->description }}
```

Note: due to a limitation of matching nested parentheses, only one level of nested parentheses is supported in the `@rowforeach(...)` and `@rowif(...)` expressions. e.g. `@rowforeach($users as $user)` or `@rowforeach($items->where('active', true) as $item)` will work, but more complex expressions with multiple levels of parentheses will not.

If you need more control over what is before / after the row use `@beforerow / @endbeforerow` and `@afterrow / @endafterrow`. This example is the equivalent of the above but allows you to put any other directives before or after the row.

```
@beforerow@foreach ($users as $user)@endbeforerow
{{ $user->name }}
@afterrow@endforeach@endafterrow
```

###  Health Score

41

—

FairBetter than 89% of packages

Maintenance67

Regular maintenance activity

Popularity17

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity61

Established project with proven stability

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

Recently: every ~191 days

Total

20

Last Release

205d ago

Major Versions

0.3.1 → 1.0.02025-10-23

### Community

Maintainers

![](https://www.gravatar.com/avatar/7bfb05a4659b16939bc3dc697db922e7a08eabd2c9de6fe6bb54bf5ee86a4061?d=identicon)[petecoop](/maintainers/petecoop)

---

Top Contributors

[![petecoop](https://avatars.githubusercontent.com/u/1655361?v=4)](https://github.com/petecoop "petecoop (51 commits)")

###  Code Quality

TestsPest

### Embed Badge

![Health badge](/badges/petecoop-odt/health.svg)

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

###  Alternatives

[vich/uploader-bundle

Ease file uploads attached to entities

1.9k25.9M116](/packages/vich-uploader-bundle)[laravel/browser-kit-testing

Provides backwards compatibility for BrowserKit testing in the latest Laravel release.

5139.4M286](/packages/laravel-browser-kit-testing)[sulu/sulu

Core framework that implements the functionality of the Sulu content management system

1.3k1.3M152](/packages/sulu-sulu)[prestashop/prestashop

PrestaShop is an Open Source e-commerce platform, committed to providing the best shopping cart experience for both merchants and customers.

9.0k15.4k](/packages/prestashop-prestashop)[ec-cube/ec-cube

EC-CUBE EC open platform.

78527.0k1](/packages/ec-cube-ec-cube)[spatie/laravel-export

Create a static site bundle from a Laravel app

646127.9k5](/packages/spatie-laravel-export)

PHPackages © 2026

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