Skip to content

Commit 58e5304

Browse files
committed
Update readme and docs
1 parent eb869fc commit 58e5304

3 files changed

Lines changed: 78 additions & 15 deletions

File tree

README.md

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ A JavaScript PDF generation library for Node and the browser.
66

77
## Description
88

9-
PDFKit is a PDF document generation library for Node and the browser that makes creating complex, multi-page, printable documents easy.
10-
It's written in CoffeeScript, but you can choose to use the API in plain 'ol JavaScript if you like. The API embraces
11-
chainability, and includes both low level functions as well as abstractions for higher level functionality. The PDFKit API
9+
PDFKit is a PDF document generation library for Node and the browser that makes creating complex, multi-page, printable documents easy.
10+
It's written in CoffeeScript, but you can choose to use the API in plain 'ol JavaScript if you like. The API embraces
11+
chainability, and includes both low level functions as well as abstractions for higher level functionality. The PDFKit API
1212
is designed to be simple, so generating complex documents is often as simple as a few function calls.
1313

1414
Check out some of the [documentation and examples](http://pdfkit.org/docs/getting_started.html) to see for yourself!
@@ -49,15 +49,17 @@ Installation uses the [npm](http://npmjs.org/) package manager. Just type the f
4949
* Underlines
5050
* etc.
5151
* Outlines
52-
52+
* PDF security
53+
* Encryption
54+
* Access privileges (printing, copying, modifying, annotating, form filling, content accessibility, document assembly)
55+
5356
## Coming soon!
5457

5558
* Patterns fills
56-
* PDF Security
5759
* Higher level APIs for creating tables and laying out content
5860
* More performance optimizations
5961
* Even more awesomeness, perhaps written by you! Please fork this repository and send me pull requests.
60-
62+
6163
## Example
6264

6365
```coffeescript
@@ -111,9 +113,9 @@ doc.addPage()
111113
# Finalize PDF file
112114
doc.end()
113115
```
114-
115-
[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
116+
117+
[The PDF output from this example](http://pdfkit.org/demo/out.pdf) (with a few additions) shows the power of PDFKit — producing
118+
complex documents with a very small amount of code. For more, see the `demo` folder and the
117119
[PDFKit programming guide](http://pdfkit.org/docs/getting_started.html).
118120

119121
## Browser Usage
@@ -122,13 +124,13 @@ There are two ways to use PDFKit in the browser. The first is to use [Browserif
122124
which is a Node module packager for the browser with the familiar `require` syntax. The second is to use
123125
a prebuilt version of PDFKit, which you can [download from Github](https://github.com/devongovett/pdfkit/releases).
124126

125-
In addition to PDFKit, you'll need somewhere to stream the output to. HTML5 has a
127+
In addition to PDFKit, you'll need somewhere to stream the output to. HTML5 has a
126128
[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
129+
get URLs to this data in order to display PDF output inside an iframe, or upload to a server, etc. In order to
128130
get a Blob from the output of PDFKit, you can use the [blob-stream](https://github.com/devongovett/blob-stream)
129131
module.
130132

131-
The following example uses Browserify to load `PDFKit` and `blob-stream`, but if you're not using Browserify,
133+
The following example uses Browserify to load `PDFKit` and `blob-stream`, but if you're not using Browserify,
132134
you can load them in whatever way you'd like (e.g. script tags).
133135

134136
```coffeescript
@@ -157,9 +159,9 @@ stream.on 'finish', ->
157159

158160
You can see an interactive in-browser demo of PDFKit [here](http://pdfkit.org/demo/browser.html).
159161

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

165167
## Documentation

docs/getting_started.coffee.md

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,67 @@ capitalized.
183183
* `CreationDate` - the date the document was created (added automatically by PDFKit)
184184
* `ModDate` - the date the document was last modified
185185
186+
## Encryption and Access Privileges
187+
188+
PDF specification allow you to encrypt the PDF file and require a password when opening the file,
189+
and/or set permissions of what users can do with the PDF file. PDFKit implements standard security
190+
handler in PDF version 1.3 (40-bit RC4), version 1.4 (128-bit RC4), PDF version 1.7 (128-bit AES),
191+
and PDF version 1.7 ExtensionLevel 3 (256-bit AES).
192+
193+
To enable encryption, provide a user password when creating the `PDFDocument` in `options` object.
194+
The PDF file will be encrypted when a user password is provided, and users will be prompted to enter
195+
the password to decrypt the file when opening it.
196+
197+
* `userPassword` - the user password (string value)
198+
199+
To set access privileges for the PDF file, you need to provide an owner password and permission
200+
settings in the `option` object when creating `PDFDocument`. By default, all operations are disallowed.
201+
You need to explicitly allow certain operations.
202+
203+
* `ownerPassword` - the owner password (string value)
204+
* `allowPrinting` - whether printing is allowed. Specify `"lowResolution"` to allow degraded printing, or `"highResolution"` to allow printing with high resolution
205+
* `allowModifying` - whether modifying the file is allowed. Specify `true` to allow modifying document content
206+
* `allowCopying` - whether copying text or graphics is allowed. Specify `true` to allow copying
207+
* `allowAnnotating` - whether annotating, form filling is allowed. Specify `true` to allow annotating and form filling
208+
* `allowFillingForms` - whether form filling and signing is allowed. Specify `true` to allow filling in form fields and signing
209+
* `allowContentAccessibility` - whether copying text for accessibility is allowed. Specify `true` to allow copying for accessibility
210+
* `allowDocumentAssembly` - whether assembling document is allowed. Specify `true` to allow document assembly
211+
212+
You can specify either user password, owner password or both passwords.
213+
Behavior differs according to passwords you provides:
214+
215+
* When only user password is provided,
216+
users with user password are able to decrypt the file and have full access to the document.
217+
* When only owner password is provided,
218+
users are able to decrypt and open the document without providing any password,
219+
but the access is limited to those operations explicitly permitted.
220+
Users with owner password have full access to the document.
221+
* When both passwords are provided,
222+
users with user password are able to decrypt the file
223+
but only have limited access to the file according to permission settings.
224+
Users with owner password have full access to the document.
225+
226+
Note that PDF file itself cannot enforce access privileges.
227+
When file is decrypted, PDF viewer applications have full access to the file content,
228+
and it is up to them to respect permission settings.
229+
230+
To choose encryption method, you need to specify PDF version.
231+
PDFKit will choose best encryption method available in the PDF version you specified.
232+
233+
* `pdfVersion` - a string value specifying PDF file version
234+
235+
Available options includes:
236+
237+
* `1.3` - PDF version 1.3 (default), 40-bit RC4 is used
238+
* `1.4` - PDF version 1.4, 128-bit RC4 is used
239+
* `1.5` - PDF version 1.5, 128-bit RC4 is used
240+
* `1.6` - PDF version 1.6, 128-bit AES is used
241+
* `1.7` - PDF version 1.7, 128-bit AES is used
242+
* `1.7ext3` - PDF version 1.7 ExtensionLevel 3, 256-bit AES is used
243+
244+
When using PDF version 1.7 ExtensionLevel 3, password is truncated to 127 bytes of its UTF-8 representation.
245+
In older versions, password is truncated to 32 bytes, and only Latin-1 characters are allowed.
246+
186247
### Adding content
187248

188249
Once you've created a `PDFDocument` instance, you can add content to the

docs/guide.pdf

23.3 KB
Binary file not shown.

0 commit comments

Comments
 (0)