pdfme

pdfmeMIT活跃维护

用 TypeScript 和 React 写的开源 PDF 生成库,自带所见即所得模板设计器和 PDF 预览,浏览器和 Node.js 里都能直接生成自定义 PDF。

Open-source PDF generation library built with TypeScript and React. Features a WYSIWYG template designer, PDF viewer, and powerful generation capabilities. Create custom PDFs effortlessly in both browser and Node.js environments.

6.2.8发布于 2026-10-21 09:23 UTC5,044star +21 / 7 天560fork同步于 2026-11-10 17:37 UTC

怎么上手

由 README 提炼,执行前请确认
npm install @pdfme/generator @pdfme/common
硬件要求按 README 说明

README 未说明

下载:源码 zip·GitHub Releases(安装包)本站不镜像安装包

项目说明

由 README 自动翻译提炼

TypeScript 编写的开源 PDF 生成库,带 React 可视化模板设计器,浏览器和 Node 都能用

用 TypeScript 和 React 写的开源 PDF 生成库,自带所见即所得模板设计器和 PDF 预览,浏览器和 Node.js 里都能直接生成自定义 PDF。

核心能力

  • 用 JSON 模板描述版式,生成 PDF 无需复杂操作
  • 提供 WYSIWYG 设计器,拖拽即可制作模板
  • 内置 PDF 查看器,基于 PDF.js 渲染
  • 同一套模板在 Node 与浏览器环境通用
  • 附带 CLI,可校验模板、诊断环境并生成 PDF

容易踩的坑

README 未给出完整安装与初始化示例,需按官网 Getting Started 补齐依赖;CLI 功能需额外安装 @pdfme/cli;字体与 basePdf 配置不当会导致生成失败,可先用 pdfme doctor 排查

内容由模型根据 README 生成,可能不完整或不准确,以官方文档为准。看原文 README

最近发版

5 个版本6.2.8
  1. 6.2.8最新正式版2026-10-21 · 2026-10-21 09:23 UTC

    Bug fixes

    • Designer: selection and schema ids are kept across updateOptions — calling updateOptions no longer clears the current selection or regenerates schema ids. This also fixes the canvas going blank when the sidebar was toggled after adding a page. (#1696, related to #1691)
    • Designer: sidebarOpen is applied on every updateOptions call — passing the same sidebarOpen value again now takes effect. (#1697)
      • Behavior change: a sidebar the user opened manually is now closed by updateOptions({ sidebarOpen: false }).
    • Playground: fixed the Vite alias configuration.

    Other

    • Dependency updates. (#1694)

    Full Changelog: https://github.com/pdfme/pdfme/compare/6.2.7...6.2.8

  2. 6.2.72026-10-21 · 2026-10-21 08:48 UTC
    查看更新说明

    Bug fixes

    • Designer: stop the endless onChangeSelection loop — the Designer now notifies onChangeSelection only when the selection actually changes, and no longer fires an empty notification on mount. (#1692, fixes #1691)
    • Designer: options.theme now applies to the property panel — the property panel is rendered with the Designer's own antd instance, so host theme tokens take effect. (#1693, fixes #1690)
    • lineTitle headings in the property panel now use the theme's text color and divider color, so they stay readable and consistent in both light and dark themes.
    • Shift + Arrow nudges by 0.1mm in the Designer. (#1685)
    • Playground mobile layout fixes. (#1675)

    Features

    • Configurable Designer sidebar widths. (#1682, #1310)
    • drawSvg supports stroke-dasharray and stroke-dashoffset. (#1679)

    Visual changes (please check if you customize the theme)

    • Border color changed globally, including the default light theme: colorBorder goes from #d9d9d9 to #8e8e8e (3:1 contrast) across Designer, Form and Viewer.
    • Placeholder color changed: colorTextPlaceholder now uses colorTextSecondary for better contrast.
    • Automatic dark theme: when the host passes a dark colorBgBase, antd's darkAlgorithm is applied automatically.

    Known issue

    • The selection can be cleared after calling updateOptions. This will be fixed in the next release.

    Other

    • README demo GIF and docs updates; removed an unused CI workflow. (#1676, #1681)

    Full Changelog: https://github.com/pdfme/pdfme/compare/6.2.6...6.2.7

  3. 6.2.62026-10-16 · 2026-10-16 01:29 UTC
    查看更新说明

    What's Changed

    • fix(common): harden isUrlSafeToFetch IP parsing and reject localhost aliases (d03d0bc)

    Security

    This release fixes GHSA-2rg9-wxfw-wrr7 (severity: Low) in @pdfme/common (affected: 5.5.10 – 6.2.5).

    @pdfme/common 6.2.6 hardens the URL safety check used when fetching external resources (isUrlSafeToFetch). The following targets are now rejected: CGNAT addresses (100.64.0.0/10), *.localhost, localhost.localdomain / ip6-localhost / ip6-loopback, IPv6 unique local addresses (fc00::/7) and link-local addresses (fe80::/10). If you load images or fonts from these targets, host them at a public URL or pass the data directly.

    Full Changelog: https://github.com/pdfme/pdfme/compare/6.2.5...6.2.6

  4. 6.2.52026-10-14 · 2026-10-14 08:33 UTC
    查看更新说明

    This release fixes several bugs, all contributed by @brgl8. Thank you!

    Fixes

    • Page number in Preview and Designer: {currentPage} in read-only fields now shows the correct page number in Preview and the Designer. (#1670)
    • JSON parsing of input values: Values that cannot be JSON are no longer passed to JSON.parse. (#1667)
    • Font parsing: Each font is now parsed once and reused across generate calls, which makes repeated generation faster. (#1668)
    • Encrypted PDFs: Strings in encrypted PDFs are now decrypted from their bytes, and objects that are not encrypted are skipped. (#1666)
    • String handling: Fixed string handling. (#1671)
  5. 6.2.42026-10-06 · 2026-10-06 08:44 UTC
    查看更新说明

    This release adds image columns to tables. You can switch any table column to Image in the Designer, upload PNG or JPEG images per cell in the Designer and Form, and render them in generated PDFs. Tables also get per-column vertical alignment, and column styles now stay with the right column when a column is removed.

    Features

    • Image columns in tables: A table column can now hold images instead of text. It is opt-in per column with columnStyles.cellType ('text' | 'image', default 'text'). Each image cell's value is a PNG or JPEG data URL, so inputs stay string[][]. Other values (URLs, GIF, WebP, SVG, broken data) are not drawn and log one warning; empty cells are left blank. Row height follows columnStyles.imageHeightMode: fixed uses columnStyles.imageHeight in mm (default 20mm), and auto follows the image's aspect ratio at the column width, capped to fit the page on a blank basePdf. Images are drawn with contain fit and positioned by the column's horizontal and vertical alignment. Header cells stay text, image cells do not change column widths, and the image plugin does not have to be registered. (#484, #1660)
    • Column Style card in the Designer: The table's Column Style card is now one merged card with a block per column. For each column you can set the type (Text or Image), horizontal and vertical alignment, and, for image columns, the height mode (fixed mm or auto). With 7 or more columns, each column starts collapsed to a one-line summary. Switching a column between Text and Image clears that column's body cells. (#1663)
    • Image cells in the Designer and Form: While an image cell is being edited, you can select a PNG or JPEG file or remove the image. Empty cells show a placeholder, and clicking an empty image cell in the Form or Designer opens the file picker. If the browser blocks the picker, use the Select image button. (#1663)
    • Per-column vertical alignment: New columnStyles.verticalAlignment map, with the same shape as alignment. It overrides Head Style and Body Style for that column, including the header cell, and also sets the vertical position of images. Columns without a value render exactly as before. (#1663)

    Fixes

    • Column styles after removing a column: Deleting a table column in the Designer now shifts every columnStyles map (alignment, fontName, the new image keys, and others) so each style stays on its column. Before, a style set on a later column ended up on the wrong column. (#1658)

    Upgrade notes

    • Existing templates: Templates without cellType or verticalAlignment keep the same row heights and PDF output. One page-break edge case changed: when a table with repeatHead is the only field on its page and only its header fits there, the table now moves to the top of that page together with its first row, instead of leaving a header-only page. (#1660)

    Maintenance

    • Dropped the deprecated @types/bwip-js (bwip-js ships its own types), upgraded Vitest to 5 and Vite+ to 1.0, and improved Sentry setup for the playground build. No runtime changes to the published packages. (#1657, #1659, #1661, #1662)

用户点评

登录用户的真实使用记录,可按版本和硬件筛选
共 0 条

    还没有人点评。第一个说出真实体验的人最有价值。

    README 原文

    未翻译

    pdfme

    Features

    Fast PDF GeneratorEasy PDF Template DesignSimple JSON Template
    Works on Node and in the browser. Use templates to generate PDFs—complex operations are not required.Anyone can easily create templates using the designer.Templates are JSON data that is easy to understand and work with.

    Custom Feature Requests

    While pdfme is an open-source project released under the MIT License, we are open to considering custom feature additions for a fee.
    If you are willing to pay, we can evaluate and implement your requested features.
    Please note that any additional functionality will always be released as open source. If this approach works for you, please contact us.

    For a detailed list of supported features, please refer to the Supported Features page.

    Documentation

    For complete documentation on pdfme, please refer to the Getting Started guide.

    For the planned next major release changes, see the migration guide draft.

    Need interactive help? Use DeepWiki to ask questions about pdfme's documentation and source code directly.

    CLI Workflow

    For agentic workflows, local verification, or JSON-first template iteration, use @pdfme/cli.

    • pdfme validate: validate template or unified job JSON before generation
    • pdfme doctor: diagnose runtime, font, basePdf, and output-path issues before generate
    • pdfme generate --image --grid: generate PDFs and inspect layout via rendered page images

    Examples Using pdfme

    If you're looking for code examples to get started with pdfme, check out the pdfme-playground website and the playground source code. Setup instructions can be found in the DEVELOPMENT.md file.

    Sponsors

    Support this project by becoming a sponsor. Your logo will appear here with a link to your website.

    ProgressLabNew Sponsor
    ProgressLabPhotoQuestFamlyNew Sponsor

    Contributors

    Special Thanks

    I definitely could not have created pdfme without these libraries. I am grateful to the developers of these projects.

    If you want to contribute to pdfme, please refer to the Development Guide.
    We look forward to your contributions!