Papercut
Guide
Laravel
Reference
Examples
Changelog
GitHub
Guide
Laravel
Reference
Examples
Changelog
GitHub
  • Start

    • Introduction
    • Installation
    • Your first document
  • Building documents

    • Layout
    • Text
    • Tables
    • Pages and pagination
    • Images, SVG, links and QR codes
    • Decorators
  • Look and output

    • Styles and themes
    • Fonts
    • Rich text
    • HTML export
    • Fonts in HTML
    • Word export
    • Passwords, signatures and merging

Word export experimental

Experimental

Word export is new. Word, LibreOffice and Google Docs lay out the file themselves, so spacing and page breaks can differ slightly from the PDF, and the output may change between minor versions while it settles. Check exported files in the readers your users have, and report what looks wrong.

Any document can also be exported as a Word file (.docx) that people can open and edit in Word, LibreOffice or Google Docs. It uses the same theme, fonts and named styles as the PDF.

Word export lives in its own package, so apps that only make PDFs don't install it:

composer require papercut/docx
Laravel
$invoice = Papercut::view('pdf.invoice', compact('invoice'));

return $invoice->pdf()->download('invoice.pdf');    // PDF
return $invoice->docx()->download('invoice.docx');  // Word
PHP
use Papercut\{Document, Page, Text};
use Papercut\Docx\DocxExporter;

$document = Document::make(Page::a4()->body(Text::make('Hello')));

$document->export(new DocxExporter())->save('hello.docx');

In Laravel, ->docx() returns a PendingOutput, with the same toString(), save(), store(), download() and inline() methods as a PDF. Without papercut/docx installed, the export throws MissingExporter with the command to run. Preview routes show a Word file with ?format=docx, or a 404 with the install command when the package is missing.

What readers see

Word, LibreOffice and Google Docs lay out the pages themselves, so a page break can land a line or two away from where it is in the PDF.

Papercut writes the layout in a form all three understand. Columns flow as paragraphs. Rows become tables with no borders, at the widths the PDF uses. A box with padding, a border or a background becomes a table with one cell. Lists, tables, links, headings, page numbers and pagination rules such as keep-together carry over. Each run of pages with the same size, margins, header, footer and layers becomes a Word section of its own, so a landscape page or a page without the header comes out as it does in the PDF.

Some things are approximated or left out. The ones in the table below are reported as a warning with the node's path, and strict mode fails on anything left out. The way the layout itself is written (rows as tables, boxes as one-cell tables, header and footer distances, fonts by name, colours with transparency blended onto white) applies to every document, so it isn't reported each time.

Opacity carries over: Word has none, so each colour of a faded node is blended onto what lies beneath it (the fill around it, else white). Text backgrounds keep their exact colour.

In the PDFIn Word
Font weights other than regular and bold≈ bold from 600, regular below
Fixed heights, flexible spacers in a column, wrapping rows≈
min-lines above 2≈ Word keeps 2 lines together
Table cell justify other than start, center or end≈ top
A block link around several paragraphs≈ a link on each paragraph's text
Corner radius on a box✗ left out
An image, QR code or SVG in a background (before anything else in it) or alone in an overlay place≈ a floating picture at the same place on every page; Word draws it with the header, so an overlay sits behind the body's text
Anything else in a background or overlay layer, a border or background on a layer picture, PDF page templates, embedded PDF pages✗ left out
Styled QR codes without Imagick≈ plain squares
SVG text≈ in the system's fonts
Pictures without the PHP extension they need (below)✗ left out

Pictures

Word shows PNG, JPEG, GIF and BMP as they are. Everything else is drawn into a picture at the size the PDF gives it, so it looks the same in Word, LibreOffice and Google Docs:

In the PDFIn WordNeeds
WebP and AVIF imagesconverted to PNGext-gd
Image covercropped to the box from the middleext-gd (else ≈ contain)
Opacity on an image, QR code or SVGfaded in the pictureext-gd
QR codessharp squares at 300 dpiext-gd
Styled QR codes (shapes, eyes, colours, gradients)drawn as in the PDF at 300 dpiext-imagick and bacon/bacon-qr-code
SVGdrawn at 300 dpi; nothing outside the file is loadedext-imagick that reads SVG

Imagick is only needed for Word export; PDF and HTML don't use it.

Edit this page on GitHub
Last Updated: 10/28/26, 9:22 PM
Prev
Fonts in HTML
Next
Passwords, signatures and merging