承接 dragonofmercy/phppdf 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

dragonofmercy/phppdf

最新稳定版本:v1.7.0

Composer 安装命令:

composer require dragonofmercy/phppdf

包简介

Modern PHP library for PDF generation.

README 文档

README

phppdf - modern PHP 8.4 library for PDF generation

phppdf

CI Latest Version Total Downloads PHP Version License

Modern PHP 8.4 library for PDF generation. Pure PHP, no external runtime dependencies beyond the standard mbstring, openssl, and zlib extensions.

Status: stable (1.0). The public API follows semantic versioning; breaking changes are reserved for the next major version. See CHANGELOG.md.

What works today

A quick tour - each feature has a full guide in the wiki.

  • Documents - standard formats (A4 / Letter / Legal and more) and custom sizes, portrait or landscape, multi-page, metadata, AES-256 password protection, and viewer hints.
  • Coordinates - millimetres by default (origin top-left, Y pointing down), or PDF points via Unit::PT.
  • Graphics - lines, rectangles, circles, paths, fill / stroke, dashes, line caps / joins, and transforms.
  • Text - the 12 standard PDF fonts, multi-line text, configurable leading, and full Western Latin (accents and typographic characters).
  • Custom TrueType / OpenType fonts - register your own families and use them like the built-ins: full Unicode reach (Latin / Greek / Cyrillic / CJK), selectable text, and automatic glyph subsetting for small files.
  • Cells - text boxes with borders, fill, padding, alignment (left / center / right / justify), automatic word-wrap, and three width-fit modes.
  • Text measurement - $page->stringWidth(...) returns the exact width of a string in the current font.
  • Images - JPEG and PNG (all color types, with transparency), auto-detected, embedded once and placed as many times as you like.
  • SVG vector images - inline or from a file, fully vector: shapes, paths, gradients, patterns, clipping, masks, CSS styling, embedded rasters, real selectable <text> / <textPath>, and a pure-PHP <filter> raster.
  • Barcodes & QR codes - 1D (EAN-13 / 8, Code 128 / 39 / 93, UPC-A, ITF) and 2D (QR, Aztec, DataMatrix, PDF417), all pure-PHP and vector, with optional human-readable text and vertical 1D rendering.
  • Bookmarks & hyperlinks - a nested table-of-contents sidebar and clickable areas that open a URL or jump to another page.
  • Interactive forms - fillable text fields, checkboxes, radio buttons, dropdowns, listboxes, and push buttons, with per-field styling, JavaScript actions (calculation / formatting / validation), and automatic field linking.
  • Digital signatures - sign with a real PKCS#7 / CMS signature via Document::sign() and a PKCS#12 credential, with RFC 3161 timestamps, multiple signers, the strict PAdES profiles (B-B / B-T), and long-term-validation (LTV) building blocks.
  • Markdown - render a CommonMark core subset, either flowing with automatic page breaks (Page::markdown()) or inside an auto-sized cell; styleable via MarkdownStyle.
  • Tables - data grids via Page::table(): fixed or fill columns, headers repeated across pages, zebra striping, borders, a per-cell style callback, text-or-image cells, column spanning (colSpan), and grouped headers.
  • Right-to-left text - Unicode bidirectional reordering (UAX #9) for Hebrew, Arabic, and other RTL scripts on cells, tables, and Markdown. Set a document base direction with setBaseDirection(), override per cell with direction:, per table cell with Cell::direction(), or per Markdown block with the direction: argument on Page::markdown() / cell(markdown: true); Direction::AUTO detects the base from the text. An RTL base right-aligns by default. No page-coordinate flip - layout, images, and tables are unaffected. Arabic cursive shaping is included: letters are joined using the correct contextual presentation forms (isolated / initial / medial / final) and the four mandatory lam-alef ligatures are formed automatically; the font's cmap must contain the Arabic presentation forms (e.g. GNU FreeSerif, DejaVu Sans, Tahoma - modern GSUB-only fonts that omit the legacy presentation-form block are not supported). Markdown RTL: bidi reordering and Arabic shaping apply to each Markdown block, RTL blocks are right-aligned, and list markers / blockquote bars are mirrored to the right side; inline code and fenced code blocks stay LTR.
  • Multi-column layout - flow cell() and markdown() across equal-width columns with $page->columns(...), filling each column before the next and continuing onto new pages.
  • PDF/A archival - emit PDF/A-2 and PDF/A-3 (levels b, u, and a) with one enablePdfA() call, validated against veraPDF; A-3 embeds associated files such as a Factur-X / ZUGFeRD e-invoice. Level A (PdfALevel::A2A / A3A) auto-enables tagging and requires the catalog language, e.g. enablePdfA(PdfALevel::A2A, 'en-US'). Combining enablePdfA(PdfALevel::A2A, 'en-US') with enablePdfUA('en-US') produces a single file that is both PDF/A-2a and PDF/UA-1.
  • Tagged PDF & PDF/UA-1 accessibility - opt-in structure tagging via enableTagging(): cells, images, tables, and Markdown are tagged automatically into a logical structure tree (StructTreeRoot, MarkInfo, ParentTree, marked content), with an optional document language. enablePdfUA() goes further and produces output that validates as PDF/UA-1 (isCompliant under veraPDF): decoration is marked as /Artifact, figures carry alternate text (image(alt: ...)), table headers get a scope, DisplayDocTitle and an XMP pdfuaid are emitted, and a fail-fast guard enforces embedded fonts, a title, and figure alt text. Text hyperlinks made with cell(link: ...) are tagged as accessible <Link> elements (with /OBJR, /StructParent, and a description). Markdown inline links are also tagged automatically as <Link> elements when tagging is on, so markdown() with links is PDF/UA-1 conformant. Image hyperlinks are tagged on both surfaces: Page::image(link: ..., linkAlt: ...) and Markdown block image links [![alt](img)](url) both emit a <Link> wrapping the <Figure>, keeping documents with image links PDF/UA-1 conformant.

Not yet implemented

  • Bidi explicit embedding/override/isolate controls, and per-column-header direction in tables.

Installation

composer require dragonofmercy/phppdf

Quick start

use DragonOfMercy\PhpPdf\Document;

$pdf = new Document();
$pdf->addPage();
$pdf->save('out.pdf');

$pdf->output() returns the PDF bytes as a string instead of writing to disk.

Documentation

Full usage documentation lives in the wiki:

Development

The library source lives under build/. To get started:

git clone https://github.com/dragonofmercy/php-pdf.git
cd php-pdf/build
composer install
composer check   # PHPStan (level max) + PHPUnit

See the Contributing wiki page for coding conventions, golden fixture workflow, and how to add new features.

License

MIT - see LICENSE.

Support

If this project helps to increase your productivity, you can give me a cup of coffee :)

Donate

统计信息

  • 总下载量: 36
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 13
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-05-06

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固