Skip to content

Engine extension

NextPDF Gotenberg

Office-to-PDF conversion via the Gotenberg microservice.

Free · Apache-2.0NextPDF ^3.0 || ^5.2 · PSR-18 client ^1.0 · PSR-17 factories ^1.1 · Gotenberg instance · PHP >=8.4 <9.0

NextPDF Gotenberg bridges Gotenberg’s LibreOffice-powered document conversion with NextPDF. It sends Office documents (DOCX, XLSX, PPTX, ODT, ODS, ODP) to a Gotenberg microservice via PSR-18 HTTP, receives the converted PDF, and returns it ready for NextPDF post-processing: digital signatures, PDF/A-4 archival output, and watermarks.

How it fits

Built into your workflow

Six office formats, one converter

Send DOCX, XLSX, PPTX, ODT, ODS, or ODP and the bridge detects the format from the file extension and hands it to Gotenberg’s LibreOffice conversion. One call path covers every supported office format.

Bring your own HTTP client

The bridge talks to Gotenberg over PSR-18, so it stays vendor-agnostic about how requests are sent. Wire in Guzzle, Symfony HttpClient, Buzz, or any PSR-18 implementation you already use, and swap it while keeping conversion code unchanged.

Converted, then post-processed

Gotenberg returns a PDF that flows straight back into the NextPDF engine for post-processing. Add signatures, PDF/A output, or watermarks to the converted document in the same pipeline, with SSRF protection, file-size limits, filename sanitization, and Content-Type validation guarding the request.

Get started

Install

terminal
composer require nextpdf/gotenberg

In code

How it works

Basic file conversion

php
use NextPDF\Gotenberg\GotenbergBridge;
use NextPDF\Gotenberg\GotenbergConfig;

$config = new GotenbergConfig(
    apiUrl: 'https://gotenberg.example.com',
    timeout: 30,
    apiKey: 'your-api-key',
);

$bridge = new GotenbergBridge(
    config: $config,
    httpClient: $psrHttpClient,
    requestFactory: $psrRequestFactory,
    streamFactory: $psrStreamFactory,
);

$result = $bridge->convertFile('/path/to/report.docx');
file_put_contents('/path/to/report.pdf', $result->pdfData);

Health check

php
if ($bridge->isAvailable()) {
    echo 'Gotenberg is ready';
} else {
    echo 'Gotenberg is not available';
}

Capabilities

What you get

  • Office formats—DOCX, XLSX, PPTX, ODT, ODS, ODP via LibreOffice conversion
  • PSR-18 HTTP—uses any PSR-18 compliant HTTP client (Guzzle, Symfony HttpClient, etc.)
  • Security—SSRF protection, file size limits, filename sanitization, Content-Type validation
  • Health check—built-in isAvailable() to verify Gotenberg service status
  • Auto format detection—automatic format detection from file extension
  • Multipart upload—multipart/form-data encoding with landscape and page range options

When to use it

Use this when you need to turn Office documents (DOCX, XLSX, PPTX, ODT, ODS, ODP) into PDFs through a Gotenberg/LibreOffice microservice, then post-process them with NextPDF (signatures, PDF/A, watermarks).