Download the PHP package paperdoc-dev/paperdoc-lib without Composer

On this page you can find all versions of the php package paperdoc-dev/paperdoc-lib. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package paperdoc-lib

Paperdoc Library

Latest Version Pre-release PHP Version Tests

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


Features


Requirements

Dependency Version
PHP ^8.2
ext-dom *
ext-mbstring *
ext-zip *
ext-zlib *

Optional (Laravel)

Package Version
illuminate/support ^11.0 | ^12.0

Installation

Laravel auto-discovery

The PaperdocServiceProvider and Paperdoc facade are registered automatically via Laravel's package auto-discovery.


Quick Start

DocumentManager uses static methods (create, save, open, …). A document is built from Section instances: use addSection($section) or addSection() to append an empty section, or openSection() when you want a fluent chain (addParagraph, addHeading, …) on the new section. Bold and other run styles live on TextStyle. For advanced layouts (custom page size, full-page backgrounds, absolutely-positioned text zones, running headers/footers), see Page layout below.

Standalone PHP

Laravel (via Facade)


Supported Formats

Format Parse Render/Generate
PDF
HTML
DOCX
XLSX
PPTX
CSV
Markdown
DOC
XLS
PPT

Document Model

Every format shares the same strongly-typed in-memory structure:

All block elements implement Paperdoc\Contracts\BlockElementInterface. Styles live in Document/Style/ (ParagraphStyle, TextStyle, TableStyle), links in Document/Link/TextLink, typed document properties in Document/Metadata.

Example — build a richly-typed document


Page layout, text zones, headers & footers

Available since v0.7.0. Each section can declare its own page geometry through a PageSetup value object, and place absolutely-positioned TextZone blocks anywhere on the page. Combine several sections (each with its own PageSetup) to build documents where every page has a different size and background. Add a global RunningElement to the Document to draw a header/footer on every page.

Configure a page

Section exposes shortcut setters (setPageSize(), setPageDimensions(), setPagePadding(), setPageBackgroundImage(), setPageBackgroundColor()) that delegate to a lazily-created PageSetup.

Setter / Factory Purpose
PageSetup::fromSize(PageSize, $orientation = 'portrait') Use a standard format (A3/A4/A5/A6/Letter/Legal/Tabloid/Executive)
PageSetup::custom($width, $height) Any dimensions in PDF points
landscape() / portrait() Flip the active orientation
setPadding(...) (1–4 values) CSS-style shorthand for top/right/bottom/left padding
setBackgroundColor($hex) Solid full-bleed background color
setBackgroundImage(Image) Full-bleed image (on-disk or Image::fromData())
setBackgroundSize(string) (v0.7.1) cover (default), contain, auto, stretch (=100% 100%), or any CSS string
setBackgroundPosition(string) (v0.7.1) CSS string, default 'center center'
setBackgroundRepeat(string) (v0.7.1) CSS string, default 'no-repeat'

Fit the background image — cover / contain / auto / stretch

Available since v0.7.1. Both renderers (PDF and HTML) honour the same four CSS-like modes. cover and auto automatically clip the overflow with a clip path in the PDF and overflow: hidden in the HTML output.

BG_SIZE_* constant CSS equivalent Behaviour
BG_SIZE_COVER cover Fills the page, preserves aspect ratio, overflow is clipped (default)
BG_SIZE_CONTAIN contain Fits inside the page, preserves aspect ratio (may leave empty bands)
BG_SIZE_AUTO auto Image at its natural size, centred, clipped if larger than the page
BG_SIZE_STRETCH 100% 100% Stretches to fill the page; aspect ratio is not preserved (legacy mode)

Any other CSS-valid string ('50% auto', '300pt 200pt', …) is accepted as-is in HTML output.

Place text precisely with TextZone

Overflow strategy Behaviour
TextZone::OVERFLOW_CLIP (Default) Silently truncates content that doesn't fit
TextZone::OVERFLOW_ELLIPSIS Truncates and ends the last visible line with (PDF: native; HTML: pseudo-element)
TextZone::OVERFLOW_VISIBLE No clipping — content may flow outside the box (kept for parity with CSS)

Coordinates use the top-left convention (x=0, y=0 is the top-left of the page) for both PDF and HTML — the PdfRenderer flips to PDF's bottom-left origin internally.

Per-paragraph alignment inside a zone — v0.7.1

Each paragraph of a TextZone carries its own ParagraphStyle, so you can mix several alignments in the same zone (centred title, justified body, right-aligned signature, …):

In the PDF, justification is implemented with the native PDF word-spacing operator (Tw); the last line of a paragraph is intentionally left-aligned to avoid stretched short lines.

Document-wide headers and footers

Supported placeholders in the template: {page} (1-indexed current page), {pages} (total pages), {title} (the document title), {date} (Y-m-d) and {datetime} (Y-m-d H:i). The renderer resolves them per page so you don't need to update the template between pages.

The HTML renderer adds a translucent rgba(255, 255, 255, 0.85) backdrop with a backdrop-filter: blur(2px) behind the running elements so they remain legible on top of any background image. The library does not automatically reserve vertical space for the header/footer — keep that in mind when positioning a TextZone close to a page edge.

Per-section header / footer override (v0.8.0)

A document-level header/footer applies uniformly to every page by default. Often that's not what you want — a cover page should NOT carry the page-number footer (it would either disappear under the artwork or fight with the imagery for legibility), and a colophon on the last page might want a different label. Since v0.8.0, sections can override or suppress the document-level running elements:

Resolution rule — for every page, the renderer picks (in order) :

  1. If Section::hideHeader() / hideFooter() was called → no header/footer is drawn.
  2. If Section::setHeader() / setFooter() was called with a non-null element → that element is drawn.
  3. Otherwise → the document-level header/footer is drawn (if any).

Both PDF and HTML renderers honour this resolution.

Vertical alignment of section content (v0.8.0)

By default the content of a section flows from the top padding downwards. For pages that should breathe vertically — chapter openers, colophons, frontispieces, single-paragraph "blank" pages — you can centre or bottom-anchor the content :

Implementation notes :

Per-side padding shortcuts (v0.8.0)

Section::setPagePadding(...$values) already accepts CSS-shorthand 1-/2-/3-/4-value forms. When only ONE side needs tweaking — typical for a frontispiece title that should sit ~110pt from the top — the new per-side shortcuts are clearer :

Available : setPagePaddingTop(), setPagePaddingRight(), setPagePaddingBottom(), setPagePaddingLeft(). They all return $this for chaining.


First-line indent and letter-spacing (v0.8.0)

Two style-level additions that previously had to be hacked at the application layer :

Paragraph first-line indent

ParagraphStyle::setFirstLineIndent(float $points) mirrors the CSS text-indent property : only the first line of the paragraph starts further to the right. Negative values produce a hanging indent (first line jutting OUT to the left of the block — a typographic device used in lists or dictionary entries).

The PDF wrap engine sees a tighter budget for the first line so wrapping accounts for the indent correctly. The HTML renderer emits text-indent: Xpt on the paragraph's inline style.

Run letter-spacing

TextStyle::setLetterSpacing(float $points) opens out a run of text by the requested number of points between every pair of adjacent glyphs. Common uses : an opened-out section heading (setLetterSpacing(1.5)), or marking an acronym in small-caps style. Negative values pull glyphs closer.

PDF emits the native Tc operator and resets to 0 after the run, so copy-paste from the rendered file gives back the original (un-spaced) text — a property the previous "insert thin spaces between every glyph" workarounds did not have. HTML emits letter-spacing: Xpt. measureTextWidth() and wrapText() correctly account for letter-spacing.


Horizontal rule (v0.8.0)

A first-class block element for visual separators :

Property Type Default Notes
width string\|float '100%' Either a CSS-style percentage ('50%') or absolute pt.
thickness float (pt) 0.5 Word-style "thin rule" by default.
color string hex '#999999' CSS hex (#rgb or #rrggbb).
alignment Alignment CENTER LEFT / CENTER / RIGHT for partial-width rules.
marginTop float (pt) 6.0 Vertical breathing space above the rule.
marginBottom float (pt) 6.0 Below.

Renderers :


Rendering

Since v0.5.0, every element of the document model is natively rendered by all four core renderers — no element is silently dropped, every output is a valid file format.

Element DOCX PDF HTML Markdown
Heading (1–6) <w:pStyle w:val="HeadingN"/> + bookmark anchor typed font sizes (24/20/16/14/13/12 pt) + navy <h1><h6> with id #######, optional {#id}
Paragraph <w:p> + run styling wrapped text + inline run styles <p> + inline <span> plain text + emphasis
ListBlock <w:numPr> + word/numbering.xml, nested <w:ilvl> / 1. markers, depth-based indent <ul> / <ol start="N">, nested - / 1., two-space indent
Blockquote <w:pStyle w:val="Quote"/> + indent indented italic muted-grey <blockquote> (nested children) > prefixed lines
CodeBlock <w:pStyle w:val="Code"/> + Consolas + <w:br/> Courier, dedicated spacing <pre><code class="language-…"> fenced ` bash

php artisan vendor:publish --tag=paperdoc-config bash composer test

or

./vendor/bin/phpunit

src/ ├── Concerns/ # Shared traits ├── Console/ # Artisan commands ├── Contracts/ # DocumentInterface, ParserInterface, BlockElementInterface… ├── Document/ # Core model (Document, Section, Paragraph, Heading, ListBlock, Bookmark, CodeBlock, Blockquote, Metadata…) ├── Enum/ # Format enums ├── Exceptions/ # PaperdocException + typed exceptions ├── Facades/ # Laravel Facade ├── Factory/ # Document/Parser factories ├── Llm/ # AI/LLM integration (Neuron AI) ├── Ocr/ # OCR integration ├── Parsers/ # Format-specific parsers ├── Renderers/ # Format-specific renderers ├── Support/ # DocumentManager and helpers └── PaperdocServiceProvider.php



---

## Contributing

We welcome contributions! Please read [CONTRIBUTING.md](CONTRIBUTING.md) before opening a pull request.

### Contributors

Thanks to everyone who has contributed to **paperdoc-lib**. A full list is kept in [CONTRIBUTORS.md](CONTRIBUTORS.md).

- **Olivier Mourlevat** — [@olivM](https://github.com/olivM) — DOCX hyperlink parsing, HTML/Markdown hyperlink rendering ([#4](https://github.com/paperdoc-dev/paperdoc-lib/pull/4))

---

## Changelog

See [CHANGELOG.md](CHANGELOG.md) for release history.

---

## License

Paperdoc Library is released under the **[MIT License](LICENSE)** — free to use, modify and distribute, commercial or not.

© Paperdoc — [paperdoc.dev](https://paperdoc.dev)

All versions of paperdoc-lib with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
ext-dom Version *
ext-mbstring Version *
ext-zip Version *
ext-zlib Version *
neuron-core/neuron-ai Version ^3.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package paperdoc-dev/paperdoc-lib contains the following files

Loading the files please wait ...