Socket
Socket
Sign inDemoInstall

@react-pdf/pdfkit

Package Overview
Dependencies
92
Maintainers
1
Versions
49
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.2.0 to 1.3.0

49

package.json
{
"name": "@react-pdf/pdfkit",
"version": "1.2.0",
"version": "1.3.0",
"description": "A PDF generation library for Node.js",

@@ -17,6 +17,13 @@ "main": "dist/pdfkit.cjs.js",

"scripts": {
"build": "rollup -c",
"build": "rimraf ./dist && rollup -c",
"prepublish": "npm run build",
"prebuild": "node ./src/font/data/compressData.js",
"postbuild": "rimraf ./src/font/data/*.b64.afm"
"prebuild": "node ./lib/font/data/compressData.js",
"postbuild": "rimraf ./lib/font/data/*.b64.afm",
"browser-demo": "browserify demo/browser.js > demo/bundle.js",
"pdf-guide": "node docs/generate.js",
"website": "node docs/generate_website.js",
"docs": "npm run pdf-guide && npm run website && npm run browser-demo",
"test": "jest -i",
"test:integration": "jest integration/ -i",
"test:unit": "jest unit/ -i"
},

@@ -26,16 +33,23 @@ "files": [

],
"dependencies": {
"@react-pdf/fontkit": "^1.11.0",
"@react-pdf/png-js": "^1.0.0",
"lz-string": "^1.4.4"
},
"devDependencies": {
"babel-core": "^6.26.3",
"babel-jest": "^23.6.0",
"babel-plugin-external-helpers": "^6.22.0",
"babel-preset-env": "^1.7.0",
"babel-preset-es2015": "^6.24.1",
"blob-stream": "^0.1.2",
"brace": "^0.2.1",
"brfs": "~2.0.1",
"browserify": "^13.3.0",
"codemirror": "~3.20.0",
"eslint": "^5.3.0",
"iconv-lite": "^0.4.13",
"jade": "~1.1.5",
"jest": "^23.4.2",
"markdown": "~0.5.0",
"rimraf": "^2.6.2",
"rollup": "^0.52.2",
"rollup-plugin-babel": "^2.7.1",
"rollup-plugin-babel": "3",
"rollup-plugin-bundle-size": "https://github.com/vimeo/rollup-plugin-bundle-size",
"rollup-plugin-cpy": "^1.0.0",
"rollup-plugin-ignore": "^1.0.3",

@@ -47,3 +61,18 @@ "rollup-plugin-json": "^2.1.0",

"rollup-plugin-uglify": "^3.0.0"
},
"dependencies": {
"@react-pdf/fontkit": "^1.11.0",
"@react-pdf/png-js": "^1.0.0",
"crypto-js": "^3.1.9-1",
"linebreak": "^0.3.0",
"lz-string": "^1.4.4",
"saslprep": "1.0.1"
},
"jest": {
"testPathIgnorePatterns": [
"/node_modules/",
"<rootDir>/demo/"
],
"testURL": "http://localhost/"
}
}

@@ -5,9 +5,7 @@ # PDFKit

[![](https://img.shields.io/gratipay/devongovett.svg)](https://gratipay.com/devongovett)
## Description
PDFKit is a PDF document generation library for Node and the browser that makes creating complex, multi-page, printable documents easy.
It's written in CoffeeScript, but you can choose to use the API in plain 'ol JavaScript if you like. The API embraces
chainability, and includes both low level functions as well as abstractions for higher level functionality. The PDFKit API
PDFKit is a PDF document generation library for Node and the browser that makes creating complex, multi-page, printable documents easy.
It's written in CoffeeScript, but you can choose to use the API in plain 'ol JavaScript if you like. The API embraces
chainability, and includes both low level functions as well as abstractions for higher level functionality. The PDFKit API
is designed to be simple, so generating complex documents is often as simple as a few function calls.

@@ -52,30 +50,32 @@

* etc.
* Outlines
* PDF security
* Encryption
* Access privileges (printing, copying, modifying, annotating, form filling, content accessibility, document assembly)
## Coming soon!
* Patterns fills
* Outlines
* PDF Security
* Higher level APIs for creating tables and laying out content
* More performance optimizations
* Even more awesomeness, perhaps written by you! Please fork this repository and send me pull requests.
## Example
```coffeescript
PDFDocument = require 'pdfkit'
```javascript
const PDFDocument = require('pdfkit');
# Create a document
doc = new PDFDocument
// Create a document
const doc = new PDFDocument;
# Pipe its output somewhere, like to a file or HTTP response
# See below for browser usage
doc.pipe fs.createWriteStream('output.pdf')
// Pipe its output somewhere, like to a file or HTTP response
// See below for browser usage
doc.pipe(fs.createWriteStream('output.pdf'));
# Embed a font, set the font size, and render some text
// Embed a font, set the font size, and render some text
doc.font('fonts/PalatinoBold.ttf')
.fontSize(25)
.text('Some text with an embedded font!', 100, 100)
.text('Some text with an embedded font!', 100, 100);
# Add an image, constrain it to a given size, and center it vertically and horizontally
// Add an image, constrain it to a given size, and center it vertically and horizontally
doc.image('path/to/image.png', {

@@ -87,8 +87,8 @@ fit: [250, 300],

# Add another page
// Add another page
doc.addPage()
.fontSize(25)
.text('Here is some vector graphics...', 100, 100)
.text('Here is some vector graphics...', 100, 100);
# Draw a triangle
// Draw a triangle
doc.save()

@@ -98,5 +98,5 @@ .moveTo(100, 150)

.lineTo(200, 250)
.fill("#FF3300")
.fill("#FF3300");
# Apply some transforms and render an SVG path with the 'even-odd' fill rule
// Apply some transforms and render an SVG path with the 'even-odd' fill rule
doc.scale(0.6)

@@ -106,17 +106,17 @@ .translate(470, -380)

.fill('red', 'even-odd')
.restore()
.restore();
# Add some text with annotations
// Add some text with annotations
doc.addPage()
.fillColor("blue")
.text('Here is a link!', 100, 100)
.underline(100, 100, 160, 27, color: "#0000FF")
.link(100, 100, 160, 27, 'http://google.com/')
.underline(100, 100, 160, 27, {color: "#0000FF"})
.link(100, 100, 160, 27, 'http://google.com/');
# Finalize PDF file
doc.end()
// Finalize PDF file
doc.end();
```
[The PDF output from this example](http://pdfkit.org/demo/out.pdf) (with a few additions) shows the power of PDFKit — producing
complex documents with a very small amount of code. For more, see the `demo` folder and the
[The PDF output from this example](http://pdfkit.org/demo/out.pdf) (with a few additions) shows the power of PDFKit — producing
complex documents with a very small amount of code. For more, see the `demo` folder and the
[PDFKit programming guide](http://pdfkit.org/docs/getting_started.html).

@@ -130,33 +130,34 @@

In addition to PDFKit, you'll need somewhere to stream the output to. HTML5 has a
In addition to PDFKit, you'll need somewhere to stream the output to. HTML5 has a
[Blob](https://developer.mozilla.org/en-US/docs/Web/API/Blob) object which can be used to store binary data, and
get URLs to this data in order to display PDF output inside an iframe, or upload to a server, etc. In order to
get URLs to this data in order to display PDF output inside an iframe, or upload to a server, etc. In order to
get a Blob from the output of PDFKit, you can use the [blob-stream](https://github.com/devongovett/blob-stream)
module.
The following example uses Browserify to load `PDFKit` and `blob-stream`, but if you're not using Browserify,
The following example uses Browserify to load `PDFKit` and `blob-stream`, but if you're not using Browserify,
you can load them in whatever way you'd like (e.g. script tags).
```coffeescript
# require dependencies
PDFDocument = require 'pdfkit'
blobStream = require 'blob-stream'
```javascript
// require dependencies
const PDFDocument = require('pdfkit');
const blobStream = require('blob-stream');
# create a document the same way as above
doc = new PDFDocument
// create a document the same way as above
const doc = new PDFDocument;
# pipe the document to a blob
stream = doc.pipe(blobStream())
// pipe the document to a blob
const stream = doc.pipe(blobStream());
# add your content to the document here, as usual
// add your content to the document here, as usual
# get a blob when you're done
doc.end()
stream.on 'finish', ->
# get a blob you can do whatever you like with
blob = stream.toBlob('application/pdf')
// get a blob when you're done
doc.end();
stream.on('finish', function() {
// get a blob you can do whatever you like with
const blob = stream.toBlob('application/pdf');
# or get a blob URL for display in the browser
url = stream.toBlobURL('application/pdf')
iframe.src = url
// or get a blob URL for display in the browser
const url = stream.toBlobURL('application/pdf');
iframe.src = url;
});
```

@@ -166,5 +167,5 @@

Note that in order to Browserify a project using PDFKit, you need to install the `brfs` module with npm,
which is used to load built-in font data into the package. It is listed as a `devDependency` in
PDFKit's `package.json`, so it isn't installed by default for Node users.
Note that in order to Browserify a project using PDFKit, you need to install the `brfs` module with npm,
which is used to load built-in font data into the package. It is listed as a `devDependency` in
PDFKit's `package.json`, so it isn't installed by default for Node users.
If you forget to install it, Browserify will print an error message.

@@ -171,0 +172,0 @@

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc