From c03bd56369d06783412bf418ed9db25a00588478 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luiz=20Am=C3=A9rico?= Date: Tue, 3 Dec 2019 21:21:56 -0300 Subject: [PATCH] Update version to 0.11 --- CHANGELOG.md | 3 ++ README.md | 138 +++++++++++++++++++++++++++------------------------ package.json | 2 +- 3 files changed, 76 insertions(+), 67 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 02917d75b..617fd75ed 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ ### 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 @@ -9,6 +11,7 @@ - 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 diff --git a/README.md b/README.md index 37213eefa..81dc9b2b2 100644 --- a/README.md +++ b/README.md @@ -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! @@ -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 @@ -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(); diff --git a/package.json b/package.json index 654060622..db49e4c91 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,7 @@ "document", "vector" ], - "version": "0.10.0", + "version": "0.11.0", "homepage": "http://pdfkit.org/", "author": { "name": "Devon Govett",