You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/getting_started.coffee.md
+61Lines changed: 61 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -183,6 +183,67 @@ capitalized.
183
183
* `CreationDate` - the date the document was created (added automatically by PDFKit)
184
184
* `ModDate` - the date the document was last modified
185
185
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
+
186
247
### Adding content
187
248
188
249
Once you've created a `PDFDocument` instance, you can add content to the
0 commit comments