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 portPrimarySequenceContent types
source✔  application/pdf 
Output portPrimarySequenceContent types
result✔  application/pdf 
Option nameTypeValuesDefault valueRequired
owner-passwordxs:string  ✔ 
user-passwordxs:string  ✔ 
assemblexs:boolean? () 
compressionxs:string('none', 'default') 'default' 
extractxs:boolean? () 
extract-for-accessibilityxs:boolean? () 
fill-in-formxs:boolean? () 
key-sizexs:integer 256 
modifyxs:boolean? () 
modify-annotationsxs:boolean? () 
printxs:boolean? () 
print-faithfulxs:boolean? () 
readonlyxs:boolean? () 
This is an extension step; to use it, your pipeline must include its declaration. For example, by including the extension library with an import at the top of your pipeline:
<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-password

The owner password. The owner has unrestricted access to the PDF.

user-password

The user password. Users with this password are limited by the access restrictions.

key-size

Sets the key size to use during encryption. The values 40, 128, and 256 are allowed.

assemble

If false, users are restricted from assembling PDFs.

extract

If false, users are restricted from extracting (copying and pasting) from the PDF.

extract-for-accessibility

If false, users are restricted from using extraction for accessibility.

fill-in-form

If false, users are prevented from filling in forms.

modify

If false, users are restricted from modifying the PDF.

modify-annotations

If false, users are restricted from modifying annotations in the PDF.

print

If false, users are restricted from printing the PDF.

print-faithful

If false, users are restricted from faithfully printing the PDF.

readonly

Determines 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.