pdfkit is organized in the following folders:
lib
: The actual source code.js
: The built / distributable code.docs
: Code and artifacts to generate documentation.demo
: Node and browser demos.tests/unit
: Tests behavior of specific classes / methods.tests/visual
: Compare the pdf output against a reference.Working on your first Pull Request? You can learn how from this free series How to Contribute to an Open Source Project on GitHub
To install the project you need to have node
Fork the project, clone your fork:
# Clone your fork
git clone https://github.com/<your-username>/pdfkit.git
# Navigate to the newly cloned directory
cd pdfkit
npm install
to install dependencies
npm run build
to build the library
npm run demo
to run the demo (check demo/out.pdf)
npm run browser-demo
to run the browser demo (check demo/browser.html)
Tip: Keep your
master
branch pointing at the original repository and make pull requests from branches on your fork. To do this, run:git remote add upstream https://github.com/foliojs/pdfkit.git git fetch upstream git branch --set-upstream-to=upstream/master masterThis will add the original repository as a "remote" called "upstream," then fetch the git information from that remote, then set your local
master
branch to use the upstream master branch whenever you rungit pull
. Then you can make all of your pull request branches based on thismaster
branch. Whenever you want to update your version ofmaster
, do a regulargit pull
.
Tests are run using Jest and are categorized as unit and visual tests.
Visual tests check the pdf image screenshot against a reference stored as snapshots.
Unit tests check behavior of specific classes / methods isolatedly.
Test commands
npm run test
: Run all testsnpm run test:unit
: Run unit testsnpm run test:visual
: Run visual testsnpm run lint
: Run linterTo write new tests, look for the *.spec.js files at test/unit
and test/visual
as examples
Visual tests should use an embedded font, instead of system fonts, to ensure uniform rendering between different environments
See README.md
in the docs
subdirectory for more information.
Please go through existing issues and pull requests to check if somebody else is already working on it.
Also, make sure to run the tests and lint the code before you commit your changes.
Tests should be added to check the changed behavior even if is a bug fix.
If the proposed change affects document structure a unit test should be added, if affects rendering, add a visual test
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。