Skip to content

Commit

Permalink
Merge pull request #1066 from blikblum/update-v0.11
Browse files Browse the repository at this point in the history
Update version to 0.11
  • Loading branch information
devongovett committed Dec 10, 2019
2 parents 88adaa7 + c03bd56 commit 0fc21a7
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 67 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Expand Up @@ -2,13 +2,16 @@

### Unreleased

### [v0.11.0] - 2019-12-03

- Fix infinite loop when an individual character is bigger than the width of the text.
- Fix infinite loop when text is positioned after page right margin
- Allow links in continued text to be stopped by setting link to null
- Add support to interlaced PNG files
- Do not emit \_interopDefault helper in commonjs build
- Fix gradient with multiple stops (#1045)
- Set link annotation flag to print by default
- Add support for AcroForms
- Drop support for (uncommon) cid less fonts on standalone build (reduces bundle size)

### [v0.10.0] - 2019-06-06
Expand Down
138 changes: 72 additions & 66 deletions README.md
Expand Up @@ -4,9 +4,9 @@ A JavaScript PDF generation library for Node and the browser.

## Description

PDFKit is a PDF document generation library for Node and the browser that makes creating complex, multi-page, printable
documents easy. 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
PDFKit is a PDF document generation library for Node and the browser that makes creating complex, multi-page, printable
documents easy. 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.

Check out some of the [documentation and examples](http://pdfkit.org/docs/getting_started.html) to see for yourself!
Expand All @@ -18,45 +18,46 @@ You can also try out an interactive in-browser demo of PDFKit [here](http://pdfk

## Installation

Installation uses the [npm](http://npmjs.org/) package manager. Just type the following command after installing npm.
Installation uses the [npm](http://npmjs.org/) package manager. Just type the following command after installing npm.

npm install pdfkit

## Features

* Vector graphics
* HTML5 canvas-like API
* Path operations
* SVG path parser for easy path creation
* Transformations
* Linear and radial gradients
* Text
* Line wrapping
* Text alignments
* Bulleted lists
* Font embedding
* Supports TrueType (.ttf), OpenType (.otf), WOFF, WOFF2, TrueType Collections (.ttc), and Datafork TrueType (.dfont) fonts
* Font subsetting
* See [fontkit](http://github.com/foliojs/fontkit) for more details on advanced glyph layout support.
* Image embedding
* Supports JPEG and PNG files (including indexed PNGs, and PNGs with transparency)
* Annotations
* Links
* Notes
* Highlights
* Underlines
* etc.
* Outlines
* PDF security
* Encryption
* Access privileges (printing, copying, modifying, annotating, form filling, content accessibility, document assembly)
- Vector graphics
- HTML5 canvas-like API
- Path operations
- SVG path parser for easy path creation
- Transformations
- Linear and radial gradients
- Text
- Line wrapping
- Text alignments
- Bulleted lists
- Font embedding
- Supports TrueType (.ttf), OpenType (.otf), WOFF, WOFF2, TrueType Collections (.ttc), and Datafork TrueType (.dfont) fonts
- Font subsetting
- See [fontkit](http://github.com/foliojs/fontkit) for more details on advanced glyph layout support.
- Image embedding
- Supports JPEG and PNG files (including indexed PNGs, and PNGs with transparency)
- Annotations
- Links
- Notes
- Highlights
- Underlines
- etc.
- AcroForms
- Outlines
- PDF security
- Encryption
- Access privileges (printing, copying, modifying, annotating, form filling, content accessibility, document assembly)

## Coming soon!

* Patterns fills
* 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.
- Patterns fills
- 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

Expand All @@ -72,72 +73,77 @@ const doc = new PDFDocument();
doc.pipe(fs.createWriteStream('output.pdf'));

// 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);
doc
.font('fonts/PalatinoBold.ttf')
.fontSize(25)
.text('Some text with an embedded font!', 100, 100);

// Add an image, constrain it to a given size, and center it vertically and horizontally
doc.image('path/to/image.png', {
fit: [250, 300],
align: 'center',
valign: 'center'
fit: [250, 300],
align: 'center',
valign: 'center'
});

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

// Draw a triangle
doc.save()
.moveTo(100, 150)
.lineTo(100, 250)
.lineTo(200, 250)
.fill("#FF3300");
doc
.save()
.moveTo(100, 150)
.lineTo(100, 250)
.lineTo(200, 250)
.fill('#FF3300');

// Apply some transforms and render an SVG path with the 'even-odd' fill rule
doc.scale(0.6)
.translate(470, -380)
.path('M 250,75 L 323,301 131,161 369,161 177,301 z')
.fill('red', 'even-odd')
.restore();
doc
.scale(0.6)
.translate(470, -380)
.path('M 250,75 L 323,301 131,161 369,161 177,301 z')
.fill('red', 'even-odd')
.restore();

// 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/');
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/');

// 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
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).

## Browser Usage

There are three ways to use PDFKit in the browser:
- Use [Browserify](http://browserify.org/). See demo [source code](demo/browser.js) and [build script](https://github.com/foliojs/pdfkit/blob/master/package.json#L56)
- Use [webpack](https://webpack.js.org/). See [complete example](https://github.com/blikblum/pdfkit-webpack-example).
- Use prebuilt version. Distributed as `pdfkit.standalone.js` file in the [releases](https://github.com/foliojs/pdfkit/releases) or in the package `js` folder.

- Use [Browserify](http://browserify.org/). See demo [source code](demo/browser.js) and [build script](https://github.com/foliojs/pdfkit/blob/master/package.json#L56)
- Use [webpack](https://webpack.js.org/). See [complete example](https://github.com/blikblum/pdfkit-webpack-example).
- Use prebuilt version. Distributed as `pdfkit.standalone.js` file in the [releases](https://github.com/foliojs/pdfkit/releases) or in the package `js` folder.

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 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
of prebuilt version usage.
of prebuilt version usage.

```javascript
// require dependencies
const PDFDocument = require('pdfkit');
const blobStream = require('blob-stream');
const blobStream = require('blob-stream');

// create a document the same way as above
const doc = new PDFDocument();
Expand Down
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -9,7 +9,7 @@
"document",
"vector"
],
"version": "0.10.0",
"version": "0.11.0",
"homepage": "http://pdfkit.org/",
"author": {
"name": "Devon Govett",
Expand Down

0 comments on commit 0fc21a7

Please sign in to comment.