pdfkit 0.9.1 → 0.12.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1 @@
1
+ demo/bundle.js
package/CHANGELOG.md CHANGED
@@ -2,7 +2,42 @@
2
2
 
3
3
  ### Unreleased
4
4
 
5
- ### [v0.9.1] - 2019-3-04
5
+ ### [v0.12.1] - 2021-04-02
6
+
7
+ - Update crypto-js to v3.3 (fix security issue)
8
+ - Update fontkit to 1.8.1
9
+
10
+ ### [v0.12.0] - 2021-04-02
11
+
12
+ - Add support for Embedded Files and File Attachment Annotations
13
+ - Accessibility support
14
+ - Replace integration tests by visual regression tests
15
+ - Fix access permissions in PDF version 1.7ext3
16
+ - Fix Buffer() is deprecation warning
17
+ - Add `forms.md` to generate documentation files
18
+ - Fix "@" in FontName
19
+
20
+ ### [v0.11.0] - 2019-12-03
21
+
22
+ - Fix infinite loop when an individual character is bigger than the width of the text.
23
+ - Fix infinite loop when text is positioned after page right margin
24
+ - Allow links in continued text to be stopped by setting link to null
25
+ - Add support to interlaced PNG files
26
+ - Do not emit \_interopDefault helper in commonjs build
27
+ - Fix gradient with multiple stops (#1045)
28
+ - Set link annotation flag to print by default
29
+ - Add support for AcroForms
30
+ - Drop support for (uncommon) cid less fonts on standalone build (reduces bundle size)
31
+
32
+ ### [v0.10.0] - 2019-06-06
33
+
34
+ - Fix links to pages within the document
35
+ - Add support for named destinations
36
+ - Throw errors when `dash(...)` is passed invalid lengths
37
+ - Remove PDFDocument#output method
38
+ - Add standalone build (js/pdfkit.standalone.js)
39
+
40
+ ### [v0.9.1] - 2019-04-30
6
41
 
7
42
  - Fix setting printing permission
8
43
  - Fix corruption of string objects in browser
@@ -11,7 +46,7 @@
11
46
  - Add standalone virtual file system implementation
12
47
  - Add option (fontLayoutCache) to disable font layout cache
13
48
 
14
- ### [v0.9.0] - 2019-1-28
49
+ ### [v0.9.0] - 2019-01-28
15
50
 
16
51
  - Convert to code base from coffescript to ES6+
17
52
  - Fix loading grayscale / transparent PNG files
package/README.md CHANGED
@@ -4,140 +4,150 @@ A JavaScript PDF generation library for Node and the browser.
4
4
 
5
5
  ## Description
6
6
 
7
- PDFKit is a PDF document generation library for Node and the browser that makes creating complex, multi-page, printable
8
- documents easy. The API embraces chainability, and includes both low level functions as well as abstractions for higher
9
- level functionality. The PDFKit API is designed to be simple, so generating complex documents is often as simple as
7
+ PDFKit is a PDF document generation library for Node and the browser that makes creating complex, multi-page, printable
8
+ documents easy. The API embraces chainability, and includes both low level functions as well as abstractions for higher
9
+ level functionality. The PDFKit API is designed to be simple, so generating complex documents is often as simple as
10
10
  a few function calls.
11
11
 
12
12
  Check out some of the [documentation and examples](http://pdfkit.org/docs/getting_started.html) to see for yourself!
13
13
  You can also read the guide as a [self-generated PDF](http://pdfkit.org/docs/guide.pdf) with example output displayed inline.
14
- If you'd like to see how it was generated, check out the README in the [docs](https://github.com/devongovett/pdfkit/tree/master/docs)
14
+ If you'd like to see how it was generated, check out the README in the [docs](https://github.com/foliojs/pdfkit/tree/master/docs)
15
15
  folder.
16
16
 
17
17
  You can also try out an interactive in-browser demo of PDFKit [here](http://pdfkit.org/demo/browser.html).
18
18
 
19
19
  ## Installation
20
20
 
21
- Installation uses the [npm](http://npmjs.org/) package manager. Just type the following command after installing npm.
21
+ Installation uses the [npm](http://npmjs.org/) package manager. Just type the following command after installing npm.
22
22
 
23
23
  npm install pdfkit
24
24
 
25
25
  ## Features
26
26
 
27
- * Vector graphics
28
- * HTML5 canvas-like API
29
- * Path operations
30
- * SVG path parser for easy path creation
31
- * Transformations
32
- * Linear and radial gradients
33
- * Text
34
- * Line wrapping
35
- * Text alignments
36
- * Bulleted lists
37
- * Font embedding
38
- * Supports TrueType (.ttf), OpenType (.otf), WOFF, WOFF2, TrueType Collections (.ttc), and Datafork TrueType (.dfont) fonts
39
- * Font subsetting
40
- * See [fontkit](http://github.com/devongovett/fontkit) for more details on advanced glyph layout support.
41
- * Image embedding
42
- * Supports JPEG and PNG files (including indexed PNGs, and PNGs with transparency)
43
- * Annotations
44
- * Links
45
- * Notes
46
- * Highlights
47
- * Underlines
48
- * etc.
49
- * Outlines
50
- * PDF security
51
- * Encryption
52
- * Access privileges (printing, copying, modifying, annotating, form filling, content accessibility, document assembly)
27
+ - Vector graphics
28
+ - HTML5 canvas-like API
29
+ - Path operations
30
+ - SVG path parser for easy path creation
31
+ - Transformations
32
+ - Linear and radial gradients
33
+ - Text
34
+ - Line wrapping
35
+ - Text alignments
36
+ - Bulleted lists
37
+ - Font embedding
38
+ - Supports TrueType (.ttf), OpenType (.otf), WOFF, WOFF2, TrueType Collections (.ttc), and Datafork TrueType (.dfont) fonts
39
+ - Font subsetting
40
+ - See [fontkit](http://github.com/foliojs/fontkit) for more details on advanced glyph layout support.
41
+ - Image embedding
42
+ - Supports JPEG and PNG files (including indexed PNGs, and PNGs with transparency)
43
+ - Annotations
44
+ - Links
45
+ - Notes
46
+ - Highlights
47
+ - Underlines
48
+ - etc.
49
+ - AcroForms
50
+ - Outlines
51
+ - PDF security
52
+ - Encryption
53
+ - Access privileges (printing, copying, modifying, annotating, form filling, content accessibility, document assembly)
54
+ - Accessibility support (marked content, logical structure, Tagged PDF, PDF/UA)
53
55
 
54
56
  ## Coming soon!
55
57
 
56
- * Patterns fills
57
- * Higher level APIs for creating tables and laying out content
58
- * More performance optimizations
59
- * Even more awesomeness, perhaps written by you! Please fork this repository and send me pull requests.
58
+ - Patterns fills
59
+ - Higher level APIs for creating tables and laying out content
60
+ - More performance optimizations
61
+ - Even more awesomeness, perhaps written by you! Please fork this repository and send me pull requests.
60
62
 
61
63
  ## Example
62
64
 
63
65
  ```javascript
64
66
  const PDFDocument = require('pdfkit');
67
+ const fs = require('fs');
65
68
 
66
69
  // Create a document
67
- const doc = new PDFDocument;
70
+ const doc = new PDFDocument();
68
71
 
69
72
  // Pipe its output somewhere, like to a file or HTTP response
70
73
  // See below for browser usage
71
74
  doc.pipe(fs.createWriteStream('output.pdf'));
72
75
 
73
76
  // Embed a font, set the font size, and render some text
74
- doc.font('fonts/PalatinoBold.ttf')
75
- .fontSize(25)
76
- .text('Some text with an embedded font!', 100, 100);
77
+ doc
78
+ .font('fonts/PalatinoBold.ttf')
79
+ .fontSize(25)
80
+ .text('Some text with an embedded font!', 100, 100);
77
81
 
78
82
  // Add an image, constrain it to a given size, and center it vertically and horizontally
79
83
  doc.image('path/to/image.png', {
80
- fit: [250, 300],
81
- align: 'center',
82
- valign: 'center'
84
+ fit: [250, 300],
85
+ align: 'center',
86
+ valign: 'center'
83
87
  });
84
88
 
85
89
  // Add another page
86
- doc.addPage()
87
- .fontSize(25)
88
- .text('Here is some vector graphics...', 100, 100);
90
+ doc
91
+ .addPage()
92
+ .fontSize(25)
93
+ .text('Here is some vector graphics...', 100, 100);
89
94
 
90
95
  // Draw a triangle
91
- doc.save()
92
- .moveTo(100, 150)
93
- .lineTo(100, 250)
94
- .lineTo(200, 250)
95
- .fill("#FF3300");
96
+ doc
97
+ .save()
98
+ .moveTo(100, 150)
99
+ .lineTo(100, 250)
100
+ .lineTo(200, 250)
101
+ .fill('#FF3300');
96
102
 
97
103
  // Apply some transforms and render an SVG path with the 'even-odd' fill rule
98
- doc.scale(0.6)
99
- .translate(470, -380)
100
- .path('M 250,75 L 323,301 131,161 369,161 177,301 z')
101
- .fill('red', 'even-odd')
102
- .restore();
104
+ doc
105
+ .scale(0.6)
106
+ .translate(470, -380)
107
+ .path('M 250,75 L 323,301 131,161 369,161 177,301 z')
108
+ .fill('red', 'even-odd')
109
+ .restore();
103
110
 
104
111
  // Add some text with annotations
105
- doc.addPage()
106
- .fillColor("blue")
107
- .text('Here is a link!', 100, 100)
108
- .underline(100, 100, 160, 27, {color: "#0000FF"})
109
- .link(100, 100, 160, 27, 'http://google.com/');
112
+ doc
113
+ .addPage()
114
+ .fillColor('blue')
115
+ .text('Here is a link!', 100, 100)
116
+ .underline(100, 100, 160, 27, { color: '#0000FF' })
117
+ .link(100, 100, 160, 27, 'http://google.com/');
110
118
 
111
119
  // Finalize PDF file
112
120
  doc.end();
113
121
  ```
114
122
 
115
123
  [The PDF output from this example](http://pdfkit.org/demo/out.pdf) (with a few additions) shows the power of PDFKit — producing
116
- complex documents with a very small amount of code. For more, see the `demo` folder and the
124
+ complex documents with a very small amount of code. For more, see the `demo` folder and the
117
125
  [PDFKit programming guide](http://pdfkit.org/docs/getting_started.html).
118
126
 
119
127
  ## Browser Usage
120
128
 
121
- There are two ways to use PDFKit in the browser. The first is to use [Browserify](http://browserify.org/),
122
- which is a Node module packager for the browser with the familiar `require` syntax. The second is to use
123
- a prebuilt version of PDFKit, which you can [download from Github](https://github.com/devongovett/pdfkit/releases).
129
+ There are three ways to use PDFKit in the browser:
124
130
 
125
- In addition to PDFKit, you'll need somewhere to stream the output to. HTML5 has a
131
+ - 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)
132
+ - Use [webpack](https://webpack.js.org/). See [complete example](https://github.com/blikblum/pdfkit-webpack-example).
133
+ - Use prebuilt version. Distributed as `pdfkit.standalone.js` file in the [releases](https://github.com/foliojs/pdfkit/releases) or in the package `js` folder.
134
+
135
+ In addition to PDFKit, you'll need somewhere to stream the output to. HTML5 has a
126
136
  [Blob](https://developer.mozilla.org/en-US/docs/Web/API/Blob) object which can be used to store binary data, and
127
- get URLs to this data in order to display PDF output inside an iframe, or upload to a server, etc. In order to
137
+ get URLs to this data in order to display PDF output inside an iframe, or upload to a server, etc. In order to
128
138
  get a Blob from the output of PDFKit, you can use the [blob-stream](https://github.com/devongovett/blob-stream)
129
139
  module.
130
140
 
131
- The following example uses Browserify to load `PDFKit` and `blob-stream`, but if you're not using Browserify,
132
- you can load them in whatever way you'd like (e.g. script tags).
141
+ 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
142
+ of prebuilt version usage.
133
143
 
134
144
  ```javascript
135
145
  // require dependencies
136
146
  const PDFDocument = require('pdfkit');
137
- const blobStream = require('blob-stream');
147
+ const blobStream = require('blob-stream');
138
148
 
139
149
  // create a document the same way as above
140
- const doc = new PDFDocument;
150
+ const doc = new PDFDocument();
141
151
 
142
152
  // pipe the document to a blob
143
153
  const stream = doc.pipe(blobStream());