Xojo Developer Conference
25/27th April 2018 in Denver.
MBS Xojo Conference
6/7th September 2018 in Munich, Germany.

DynaPDF Manual - Page 187

Previous Page 186   Index   Next Page 188

Function Reference
Page 187 of 750
#define rsPrintHighRes
0x00000800 // Disable high res. printing
#define rsExlMetadata
0x00001000 // PDF 1.5 Exclude metadata streams
#define rsEmbFilesOnly
0x00002000 // PDF 1.6 AES Encryption only
This function finishes the PDF file, encrypts it, and frees all used resources if the file was not created
in memory. The buffer of a memory based PDF file can be accessed with GetBuffer() after the
function was called. Note that GetBuffer() does not free the used resources because it returns a
pointer to the original buffer. After the buffer was processed by your application call FreePDF() to
free the used resources. See also CreateNewPDF(), GetBuffer(), FreePDF().
The parameter KeyLen specifies the encryption filter and key length which should be used to encrypt
the PDF file. The parameter Restrict specifies which features should be disabled in a viewer
application. Note that several restriction flags depend on the used encryption filter. Flags which are
not supported by the encryption filter will be ignored.
However, the restriction flags cannot be combined in any order; only specific flag combinations are
allowed. Valid flag combinations are described in detail on the next page.
Passwords
PDF files support two different passwords to decrypt a PDF file. A viewer asks for the owner
password when the user tries to change the encryption settings. So, the owner password grands full
access to the PDF file. If no open password is set, a viewer opens the PDF file with user privilegs
without asking for a password.
If an open password is set, the PDF file cannot be opened without entering the open or owner
password. The open password causes the file to be opened with user privilegs. So, the user cannot
change the security settings and only non-restricted features can be used.
Beginning with PDF 1.6 it is also possible to encrypt embedded files only (flag rsEmbFilesOnly). The
PDF file is left unencrypted in this case but access to the embedded files can be restriced. The open
password can be used to grand access on the embedded file to authorized persons only. A viewer
asks for the password only if it is set and if the user tries to open or extract the embedded file.
Note that this feature is supported since Adobe's Acrobat or Reader 7. Prior versions cannot open
such a PDF file also if it is unencrypted.
In no password is set the PDF file is still encrypted and the file is opened with user privilegs in a
viewer. However, the seceurity settings can be easily changed in this case if the user tests an empty
password.
Because the PDF file can be decrypted without requiring a password if no open password was set, it
is easy to remove the entire encryption settings, this can be done by many tools incl. DynaPDF.
Remarks:
A PDF file can always be decrypted with a PDF library like DynaPDF if the user or owner password
is not set. So, if a PDF file must be secure then both password must be set!
 

Previous topic: CloseFileEx

Next topic: Encryption flags