README 未给出完整安装与初始化示例,需按官网 Getting Started 补齐依赖;CLI 功能需额外安装 @pdfme/cli;字体与 basePdf 配置不当会导致生成失败,可先用 pdfme doctor 排查
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.
npm install @pdfme/generator @pdfme/commonREADME 未说明
TypeScript 编写的开源 PDF 生成库,带 React 可视化模板设计器,浏览器和 Node 都能用
用 TypeScript 和 React 写的开源 PDF 生成库,自带所见即所得模板设计器和 PDF 预览,浏览器和 Node.js 里都能直接生成自定义 PDF。
核心能力
- 用 JSON 模板描述版式,生成 PDF 无需复杂操作
- 提供 WYSIWYG 设计器,拖拽即可制作模板
- 内置 PDF 查看器,基于 PDF.js 渲染
- 同一套模板在 Node 与浏览器环境通用
- 附带 CLI,可校验模板、诊断环境并生成 PDF
容易踩的坑
- 6.2.8最新正式版2026-10-21 · 2026-10-21 09:23 UTC
Bug fixes
- Designer: selection and schema ids are kept across
updateOptions— callingupdateOptionsno 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:
sidebarOpenis applied on everyupdateOptionscall — passing the samesidebarOpenvalue again now takes effect. (#1697)- Behavior change: a sidebar the user opened manually is now closed by
updateOptions({ sidebarOpen: false }).
- Behavior change: a sidebar the user opened manually is now closed by
- Playground: fixed the Vite alias configuration.
Other
- Dependency updates. (#1694)
Full Changelog: https://github.com/pdfme/pdfme/compare/6.2.7...6.2.8
- Designer: selection and schema ids are kept across
- 6.2.72026-10-21 · 2026-10-21 08:48 UTC
查看更新说明
Bug fixes
- Designer: stop the endless
onChangeSelectionloop — the Designer now notifiesonChangeSelectiononly when the selection actually changes, and no longer fires an empty notification on mount. (#1692, fixes #1691) - Designer:
options.themenow 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)
drawSvgsupportsstroke-dasharrayandstroke-dashoffset. (#1679)
Visual changes (please check if you customize the theme)
- Border color changed globally, including the default light theme:
colorBordergoes from#d9d9d9to#8e8e8e(3:1 contrast) across Designer, Form and Viewer. - Placeholder color changed:
colorTextPlaceholdernow usescolorTextSecondaryfor better contrast. - Automatic dark theme: when the host passes a dark
colorBgBase, antd'sdarkAlgorithmis 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
- Designer: stop the endless
- 6.2.62026-10-16 · 2026-10-16 01:29 UTC
查看更新说明
What's Changed
- fix(common): harden
isUrlSafeToFetchIP 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/common6.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
- fix(common): harden
- 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
generatecalls, 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)
- Page number in Preview and Designer:
- 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, soinputsstaystring[][]. Other values (URLs, GIF, WebP, SVG, broken data) are not drawn and log one warning; empty cells are left blank. Row height followscolumnStyles.imageHeightMode:fixedusescolumnStyles.imageHeightin mm (default 20mm), andautofollows the image's aspect ratio at the column width, capped to fit the page on a blankbasePdf. Images are drawn withcontainfit 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.verticalAlignmentmap, with the same shape asalignment. 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
columnStylesmap (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
cellTypeorverticalAlignmentkeep the same row heights and PDF output. One page-break edge case changed: when a table withrepeatHeadis 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)
- Image columns in tables: A table column can now hold images instead of text. It is opt-in per column with
用户点评
登录用户的真实使用记录,可按版本和硬件筛选还没有人点评。第一个说出真实体验的人最有价值。
pdfme
Features
| Fast PDF Generator | Easy PDF Template Design | Simple 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 generationpdfme doctor: diagnose runtime, font,basePdf, and output-path issues beforegeneratepdfme 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.
![]() | |||
|---|---|---|---|
| ProgressLab | PhotoQuest | Famly | New Sponsor |
Contributors
Special Thanks
- pdf-lib: Used for PDF generation.
- fontkit: Used for font rendering.
- PDF.js: Used for PDF viewing.
- React: Used in building the UI.
- form-render: Used in building the UI.
- antd: Used in building the UI.
- react-moveable, react-selecto, @scena/react-guides: Used in the Designer UI.
- dnd-kit: Used in the Designer UI.
- Lucide: Used in the Designer UI and Schema's icon.
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!
