pdfmake README

项目的 README,来自 github.com/bpampuch/pdfmake。合并为一个 markdown 文件:README.md。

pdfmake Node.js CI GitHub npm

PDF document generation library for Node.js and browsers, written in pure JavaScript.

Check out the playground and examples.

Features

Installation

Install with npm:

npm install pdfmake

Quick start

Node.js

Save the following as example.js:

const pdfmake = require('pdfmake');
const Roboto = require('pdfmake/fonts/Roboto');

pdfmake.addFonts(Roboto);

const docDefinition = {
	content: ['Hello from pdfmake!']
};

pdfmake.createPdf(docDefinition).write('document.pdf').catch(console.error);

Run node example.js to create document.pdf in the current directory.

Browser

Save the following as index.html next to your node_modules directory and open it in a browser.

<!doctype html>
<meta charset="utf-8">
<script src="node_modules/pdfmake/build/pdfmake.min.js"></script>
<script src="node_modules/pdfmake/build/vfs_fonts.js"></script>

<button onclick="pdfMake.createPdf(docDefinition).download('document.pdf').catch(console.error)">Download PDF</button>
<script>
	const docDefinition = {
		content: ['Hello from pdfmake!']
	};
</script>

Documentation

See the documentation for usage and API details.

Documentation improvements are welcome in the documentation repository.

Building from source

git clone https://github.com/bpampuch/pdfmake.git
cd pdfmake
npm install
npm run build

License

MIT

Authors

pdfmake is based on PDFKit.

Thanks to all contributors.

pdfmake (bpampuch/pdfmake)

正在搜索数据库…

这是什么?pdfmake 是一个用纯 JavaScript 编写的 PDF 文档生成库,既可以在服务端(Node.js)运行,也可以在浏览器端运行。
它是框架还是库?它是一个库,你可以把它导入自己的 Node.js 或浏览器项目中,通过编程方式生成 PDF,它本身不是独立的应用程序。
我该怎么把它添加到项目里?通过 npm 或 yarn 安装,然后使用提供的脚本从源代码构建;还有一个在线体验环境,无需安装任何东西即可试用。
它内部会依赖其他库吗?它依赖 pdfkit 进行底层 PDF 渲染,内部还依赖 linebreak 和 xmldoc;构建时需要 Node.js 20 或更高版本。
它能在哪里运行?由于它是纯 JavaScript 编写的,因此可以在 Node.js 服务器上运行,也可以直接在网页浏览器中运行。
开箱即用支持哪些排版功能?支持自动换行、文字对齐、有序和无序列表、表格(支持跨列和跨行,宽度可设为自动、固定或星号(*)比例)、报纸式多栏排版、图片、矢量图形、页眉页脚、页码、页边距、自定义分页符、嵌入字体和目录。
我能设置 PDF 的元数据,比如作者或主题吗?可以,pdfmake 提供了辅助方法用于设置作者、主题等文档元数据,还提供了打开、打印或下载生成的 PDF 的方法。
作者
bpampuch
大小
152.6 MB
星标
12.4K
时长
12年
提交 · 90 天