⚠️ This extension is deprecated because it is part of the jsreport-pdf-utils now.
jsreport extension adding password protection to PDF reports
Adding pdf-password
extension will let you add password protection to PDF rendered by any PDF recipe extension (such as jsreport-phantom-pdf, jsreport-electron-pdf, etc)
npm install jsreport-pdf-password
To use pdf-password
in template rendering set the available options for password protection in the request.
{
template: {
content: '...',
recipe: '...',
engine: '...',
pdfPassword: {
active: true,
password: '1234'
/* ...other options... */
}
}
}
-
active
(Boolean)
-> tells if password protection should be active in this request, defaults tofalse
. -
password
(String)
-> The password to be used when protecting the pdf, this option isrequired
when theactive
option istrue
. -
ownerPassword
(String)
-> The owner password is used to protect the pdf file from modifications -
protectionLevel
(Number)
-> Specifies the level of protection for the pdf, posibles values are:-1
-> none, thedefault
level will be used3
-> allow the user to print the document4
-> allow modification of the document5
-> allow copying or extracting text and graphics from the document, this is thedefault
used if none is set6
-> allow adding text annotations, fill form field9
-> allow filling forms10
-> allow extracting text and graphics in support of accessibility only11
-> allow assembling the document. rotate, insert, delete pages, bookmarks and thumbnails12
-> allow printing the document in a good res. Setting just 3 will normally print a low res form
this option requires
ownerPassword
option to be set
You can apply this extension also manually to jsreport-core
var jsreport = require('jsreport-core')()
jsreport.use(require('jsreport-pdf-password')())