{"id":13407553,"url":"https://github.com/foliojs/pdfkit","last_synced_at":"2025-12-18T01:35:54.444Z","repository":{"id":37269792,"uuid":"2030956","full_name":"foliojs/pdfkit","owner":"foliojs","description":"A JavaScript PDF generation library for Node and the browser","archived":false,"fork":false,"pushed_at":"2025-05-03T13:45:22.000Z","size":47786,"stargazers_count":10220,"open_issues_count":380,"forks_count":1172,"subscribers_count":168,"default_branch":"master","last_synced_at":"2025-05-12T16:18:51.073Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://pdfkit.org/","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/foliojs.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2011-07-11T15:12:29.000Z","updated_at":"2025-05-12T12:54:29.000Z","dependencies_parsed_at":"2023-02-10T18:00:15.608Z","dependency_job_id":"3a32f021-7519-4387-936d-efb773907adb","html_url":"https://github.com/foliojs/pdfkit","commit_stats":{"total_commits":615,"total_committers":104,"mean_commits":5.913461538461538,"dds":0.5886178861788618,"last_synced_commit":"4bad866564234efb44b1ab899d45657694644862"},"previous_names":["devongovett/pdfkit"],"tags_count":27,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/foliojs%2Fpdfkit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/foliojs%2Fpdfkit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/foliojs%2Fpdfkit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/foliojs%2Fpdfkit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/foliojs","download_url":"https://codeload.github.com/foliojs/pdfkit/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253774593,"owners_count":21962199,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-07-30T20:00:42.834Z","updated_at":"2025-12-18T01:35:54.353Z","avatar_url":"https://github.com/foliojs.png","language":"JavaScript","readme":"# PDFKit\n\nA JavaScript PDF generation library for Node and the browser.\n\n## Description\n\nPDFKit is a PDF document generation library for Node and the browser that makes creating complex, multi-page, printable\ndocuments easy. The API embraces chainability, and includes both low level functions as well as abstractions for higher\nlevel functionality. The PDFKit API is designed to be simple, so generating complex documents is often as simple as\na few function calls.\n\nCheck out some of the [documentation and examples](http://pdfkit.org/docs/getting_started.html) to see for yourself!\nYou can also read the guide as a [self-generated PDF](http://pdfkit.org/docs/guide.pdf) with example output displayed inline.\nIf you'd like to see how it was generated, check out the README in the [docs](https://github.com/foliojs/pdfkit/tree/master/docs)\nfolder.\n\nYou can also try out an interactive in-browser demo of PDFKit [here](http://pdfkit.org/demo/browser.html).\n\n## Installation\n\nInstallation uses the [npm](http://npmjs.org/) package manager. Just type the following command after installing npm.\n\n    npm install pdfkit\n\n## Features\n\n- Vector graphics\n  - HTML5 canvas-like API\n  - Path operations\n  - SVG path parser for easy path creation\n  - Transformations\n  - Linear and radial gradients\n- Text\n  - Line wrapping (with soft hyphen recognition)\n  - Text alignments\n  - Bulleted lists\n- Font embedding\n  - Supports TrueType (.ttf), OpenType (.otf), WOFF, WOFF2, TrueType Collections (.ttc), and Datafork TrueType (.dfont) fonts\n  - Font subsetting\n  - See [fontkit](http://github.com/foliojs/fontkit) for more details on advanced glyph layout support.\n- Image embedding\n  - Supports JPEG and PNG files (including indexed PNGs, and PNGs with transparency)\n- Annotations\n  - Links\n  - Notes\n  - Highlights\n  - Underlines\n  - etc.\n- AcroForms\n- Outlines\n- PDF security\n  - Encryption\n  - Access privileges (printing, copying, modifying, annotating, form filling, content accessibility, document assembly)\n- Accessibility support (marked content, logical structure, Tagged PDF, PDF/UA)\n\n## Coming soon!\n\n- Patterns fills\n- Higher level APIs for creating tables and laying out content\n- More performance optimizations\n- Even more awesomeness, perhaps written by you! Please fork this repository and send me pull requests.\n\n## Example\n\n```javascript\nconst PDFDocument = require('pdfkit');\nconst fs = require('fs');\n\n// Create a document\nconst doc = new PDFDocument();\n\n// Pipe its output somewhere, like to a file or HTTP response\n// See below for browser usage\ndoc.pipe(fs.createWriteStream('output.pdf'));\n\n// Embed a font, set the font size, and render some text\ndoc\n  .font('fonts/PalatinoBold.ttf')\n  .fontSize(25)\n  .text('Some text with an embedded font!', 100, 100);\n\n// Add an image, constrain it to a given size, and center it vertically and horizontally\ndoc.image('path/to/image.png', {\n  fit: [250, 300],\n  align: 'center',\n  valign: 'center'\n});\n\n// Add another page\ndoc\n  .addPage()\n  .fontSize(25)\n  .text('Here is some vector graphics...', 100, 100);\n\n// Draw a triangle\ndoc\n  .save()\n  .moveTo(100, 150)\n  .lineTo(100, 250)\n  .lineTo(200, 250)\n  .fill('#FF3300');\n\n// Apply some transforms and render an SVG path with the 'even-odd' fill rule\ndoc\n  .scale(0.6)\n  .translate(470, -380)\n  .path('M 250,75 L 323,301 131,161 369,161 177,301 z')\n  .fill('red', 'even-odd')\n  .restore();\n\n// Add some text with annotations\ndoc\n  .addPage()\n  .fillColor('blue')\n  .text('Here is a link!', 100, 100)\n  .underline(100, 100, 160, 27, { color: '#0000FF' })\n  .link(100, 100, 160, 27, 'http://google.com/');\n\n// Finalize PDF file\ndoc.end();\n```\n\n[The PDF output from this example](http://pdfkit.org/demo/out.pdf) (with a few additions) shows the power of PDFKit — producing\ncomplex documents with a very small amount of code. For more, see the `demo` folder and the\n[PDFKit programming guide](http://pdfkit.org/docs/getting_started.html).\n\n## Browser Usage\n\nThere are three ways to use PDFKit in the browser:\n\n- Use [Browserify](http://browserify.org/). See demo [source code](https://github.com/foliojs/pdfkit/blob/master/examples/browserify/browser.js) and [build script](https://github.com/foliojs/pdfkit/blob/master/package.json#L62)\n- Use [webpack](https://webpack.js.org/). See [complete example](https://github.com/foliojs/pdfkit/blob/master/examples/webpack).\n- Use prebuilt version. Distributed as `pdfkit.standalone.js` file in the [releases](https://github.com/foliojs/pdfkit/releases) or in the package `js` folder.\n\nIn addition to PDFKit, you'll need somewhere to stream the output to. HTML5 has a\n[Blob](https://developer.mozilla.org/en-US/docs/Web/API/Blob) object which can be used to store binary data, and\nget URLs to this data in order to display PDF output inside an iframe, or upload to a server, etc. In order to\nget a Blob from the output of PDFKit, you can use the [blob-stream](https://github.com/devongovett/blob-stream)\nmodule.\n\nThe following example uses Browserify or webpack to load `PDFKit` and `blob-stream`. See [here](https://codepen.io/blikblum/pen/gJNWMg?editors=1010) and [here](https://codepen.io/blikblum/pen/YboVNq?editors=1010) for examples\nof prebuilt version usage.\n\n```javascript\n// require dependencies\nconst PDFDocument = require('pdfkit');\nconst blobStream = require('blob-stream');\n\n// create a document the same way as above\nconst doc = new PDFDocument();\n\n// pipe the document to a blob\nconst stream = doc.pipe(blobStream());\n\n// add your content to the document here, as usual\n\n// get a blob when you are done\ndoc.end();\nstream.on('finish', function() {\n  // get a blob you can do whatever you like with\n  const blob = stream.toBlob('application/pdf');\n\n  // or get a blob URL for display in the browser\n  const url = stream.toBlobURL('application/pdf');\n  iframe.src = url;\n});\n```\n\nYou can see an interactive in-browser demo of PDFKit [here](http://pdfkit.org/demo/browser.html).\n\nNote that in order to Browserify a project using PDFKit, you need to install the `brfs` module with npm,\nwhich is used to load built-in font data into the package. It is listed as a `devDependency` in\nPDFKit's `package.json`, so it isn't installed by default for Node users.\nIf you forget to install it, Browserify will print an error message.\n\n## Documentation\n\nFor complete API documentation and more examples, see the [PDFKit website](http://pdfkit.org/).\n\n## License\n\nPDFKit is available under the MIT license.\n","funding_links":[],"categories":["Packages","Content Abstractions","JavaScript","包","Repository","others","Programming Languages"],"sub_categories":["Mad science","黑科技","Office","NodeJS"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffoliojs%2Fpdfkit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffoliojs%2Fpdfkit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffoliojs%2Fpdfkit/lists"}