The xf:security element may be used to specify advanced PDF security options.
Its syntax is of the following form:
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:xf="http://www.ecrion.com/xf/1.0">
<xf:security owner-password="ownerpass" user-password="userpass" encryption-strength="128" allow-printing="true" allow-modify-contents="true" allow-copy="true" allow-modify-annotations="true" allow-fill-in="true" allow-screen-readers="true" allow-assembly="true" allow-degraded-printing="true"/>
<fo:layout-master-set>
<fo:simple-page-master master-name="all-pages" page-height="2in" page-width="6in">
<fo:region-body region-name="xsl-region-body" column-gap="0.25in" padding="6pt" margin="0.7in" />
<fo:region-before region-name="xsl-region-before" display-align="after" extent="0.7in" padding="6pt"/>
<fo:region-after region-name="xsl-region-after" display-align="before" extent="0.7in" padding="6pt"/>
</fo:simple-page-master>
<fo:page-sequence-master master-name="default-sequence">
<fo:repeatable-page-master-reference master-reference="all-pages"/>
</fo:page-sequence-master>
</fo:layout-master-set>
<fo:page-sequence master-reference="default-sequence">
<fo:flow flow-name="xsl-region-body">
<fo:block>Hello World!</fo:block>
</fo:flow>
</fo:page-sequence>
</fo:root>
The element must be placed inside the fo:root tag, before any fo:page-sequence elements.
Attributes have the following meanings:
| • | The owner-password attribute allows setting an owner password for the PDF. |
| • | The user-password attribute allows setting a user password for the PDF. |
| • | The encryption-strength attribute allows specifying the encryption strength. Valid options are 40 and 128. Default is 40. |
The following table describes the permission flags and their meanings:
PDF Permission Flags
Name |
Description |
allow-printing |
If this flag is set, the document will be allowed to print. |
allow-modify-contents |
Specifies whether the document's contents can be modified. |
allow-copy |
Specifies whether the document can be copied. |
allow-modify-annotations |
Specifies whether the document's annotations can be modified. |
allow-fill-in |
Specifies whether the document's forms can be filled in. |
allow-screen-readers |
Specifies whether the document can be read by Acrobat Reader. |
allow-assembly |
Allows assembling the document (inserting, rotating, or deleting pages and creating bookmarks or thumbnail images). |
allow-degraded-printing |
Allow printing as a rasterized image. |
If the xf:security element is present, then all flags default to false unless otherwise specified. If the element is absent, then no restrictions are enforced.