PHPackages                             zahfouf/php-libreoffice - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. zahfouf/php-libreoffice

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

zahfouf/php-libreoffice
=======================

Framework-agnostic LibreOffice headless document conversion library for PHP.

v1.2.3(4mo ago)481MITPHPPHP ^8.1CI failing

Since Feb 15Pushed 4mo ago1 watchersCompare

[ Source](https://github.com/ZAHFOUF/php-libreoffice)[ Packagist](https://packagist.org/packages/zahfouf/php-libreoffice)[ RSS](/packages/zahfouf-php-libreoffice/feed)WikiDiscussions main Synced today

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

PHP LibreOffice wrapper for converting Word to PDF
==================================================

[](#php-libreoffice-wrapper-for-converting-word-to-pdf)

Simple PHP package to convert Word files (`.doc`, `.docx`) to PDF using LibreOffice (`soffice`) in headless mode.

 [![](https://camo.githubusercontent.com/f75faf604609072693914eb7b1f8ad3338b317fe4ea404693e003fbb3f21116d/68747470733a2f2f736d2e70636d61672e636f6d2f742f70636d61675f61752f7265766965772f6c2f6c696272656f666669632f6c696272656f66666963655f713162652e333834302e6a7067)](https://camo.githubusercontent.com/f75faf604609072693914eb7b1f8ad3338b317fe4ea404693e003fbb3f21116d/68747470733a2f2f736d2e70636d61672e636f6d2f742f70636d61675f61752f7265766965772f6c2f6c696272656f666669632f6c696272656f66666963655f713162652e333834302e6a7067) [![](https://camo.githubusercontent.com/4c2fb487e9eb45cc299f538840fa0b4140cf4e7e58b4cbd3290be0e04d5be337/68747470733a2f2f7777772e736563746f726c696e6b2e636f6d2f696d672f626c6f672f7068702d7765622d646576656c6f706d656e742e6a7067)](https://camo.githubusercontent.com/4c2fb487e9eb45cc299f538840fa0b4140cf4e7e58b4cbd3290be0e04d5be337/68747470733a2f2f7777772e736563746f726c696e6b2e636f6d2f696d672f626c6f672f7068702d7765622d646576656c6f706d656e742e6a7067)

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

[](#installation)

```
composer require zahfouf/php-libreoffice
```

CLI Commands
------------

[](#cli-commands)

After installation, the CLI binary is available at:

```
vendor/bin/libreoffice
```

### `lo:install`

[](#loinstall)

Installs LibreOffice automatically on Ubuntu/Debian.

```
vendor/bin/libreoffice lo:install
```

Notes:

- Windows: automatic installation is not supported (the command prints the official download URL).
- Non-Debian/Ubuntu Linux: install LibreOffice using your distribution package manager.

### `lo:probe`

[](#loprobe)

Checks that the LibreOffice binary works and saves default values:

- binary path (`binary`)
- temporary directory (`temp_dir`)

```
vendor/bin/libreoffice lo:probe --binary="C:\Program Files\LibreOffice\program\soffice.exe" --temp-dir="C:\laragon\tmp"
```

These values are stored in `src/Config/global_options.php`.

### `lo:convert`

[](#loconvert)

Converts a Word document to PDF.

```
vendor/bin/libreoffice lo:convert "C:\docs\invoice.docx" --to=pdf --out="C:\docs\out"
```

Useful options:

- `--binary`: path to `soffice`
- `--timeout`: timeout in seconds
- `--temp-dir`: temporary directory
- `--profile`: strategy (`none|per_job|per_worker|shared_mutex`)
- `--worker-id`: worker id (for `per_worker`)
- `--keep-temp`: keep temporary files on failure

Usage example (code)
--------------------

[](#usage-example-code)

```
