Name
cx:pdf-encrypt — Encrypt a PDF.
Synopsis
This step applies password protection to a PDF and can restrict the permissions available to users.
| Input port | Primary | Sequence | Content types |
|---|---|---|---|
| source | ✔ | application/pdf |
| Output port | Primary | Sequence | Content types |
|---|---|---|---|
| result | ✔ | application/pdf |
| Option name | Type | Values | Default value | Required |
|---|---|---|---|---|
| owner-password | xs:string | ✔ | ||
| user-password | xs:string | ✔ | ||
| assemble | xs:boolean? | () | ||
| compression | xs:string | ('none', 'default') | 'default' | |
| extract | xs:boolean? | () | ||
| extract-for-accessibility | xs:boolean? | () | ||
| fill-in-form | xs:boolean? | () | ||
| key-size | xs:integer | 256 | ||
| modify | xs:boolean? | () | ||
| modify-annotations | xs:boolean? | () | ||
| xs:boolean? | () | |||
| print-faithful | xs:boolean? | () | ||
| readonly | xs:boolean? | () |
<p:import href="https://xmlcalabash.com/ext/library/pdf-steps.xpl"/>Declaration
1 |<p:declare-step xmlns:cx="http://xmlcalabash.com/ns/extensions"
| xmlns:p="http://www.w3.org/ns/xproc"
| type="cx:pdf-encrypt">
| <p:input port="source" content-types="application/pdf"/>
5 | <p:output port="result" content-types="application/pdf"/>
| <p:option name="owner-password" as="xs:string" required="true"/>
| <p:option name="user-password" as="xs:string" required="true"/>
| <p:option name="key-size" as="xs:integer" select="256"/>
| <p:option name="assemble" as="xs:boolean?"/>
10 | <p:option name="extract" as="xs:boolean?"/>
| <p:option name="extract-for-accessibility" as="xs:boolean?"/>
| <p:option name="fill-in-form" as="xs:boolean?"/>
| <p:option name="modify" as="xs:boolean?"/>
| <p:option name="modify-annotations" as="xs:boolean?"/>
15 | <p:option name="print" as="xs:boolean?"/>
| <p:option name="print-faithful" as="xs:boolean?"/>
| <p:option name="readonly" as="xs:boolean?"/>
| <p:option name="compression" values="('none', 'default')" select="'default'"/>
|</p:declare-step>Description
This step applies owner and user passwords to a PDF. It can optionally apply permissions to limit a users ability to perform operations on the PDF, such as print it or modify it.
Options
The access restriction options (assemble, extract, etc.) and the key size are defined by the PDF specification and the underlying PDFBox APIs.
If an access restriction is not specified, the PDFBox and/or PDF default value will be used.
owner-passwordThe owner password. The owner has unrestricted access to the PDF.
user-passwordThe user password. Users with this password are limited by the access restrictions.
key-sizeSets the key size to use during encryption. The values 40, 128, and 256 are allowed.
assembleIf false, users are restricted from assembling PDFs.
extractIf false, users are restricted from extracting (copying and pasting) from the PDF.
extract-for-accessibilityIf false, users are restricted from using extraction for accessibility.
fill-in-formIf false, users are prevented from filling in forms.
modifyIf false, users are restricted from modifying the PDF.
modify-annotationsIf false, users are restricted from modifying annotations in the PDF.
printIf false, users are restricted from printing the PDF.
print-faithfulIf false, users are restricted from faithfully printing the PDF.
readonlyDetermines whether or not the PDF is readonly.
Document properties
No document properties are preserved.
Additional examples
The XML Calabash test suite contains examples of the cx:pdf-encrypt step.