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

DynaPDF Manual - Page 513

Previous Page 512   Index   Next Page 514

Function Reference
Page 513 of 750
Due to the license agreement of Adobe, all manufacturers of applications which make the treatment
of encrypted PDF files possible, must respect the access permissions of a PDF file, if the file was
opened with the open password.
Only if the file was opened with the owner password, all rights should be granted. See PDF Reference
1.7 for further information. This document is available at http://www.adobe.com.
If the property UseExactPwd is set to false (see SetUseExactPwd()), the function checks whether the
open or owner password in the file is an empty string. If one password is not set, then the file is
decrypted no matter whether the supplied password was wrong.
However, the property UseExactPwd should be true, if the application is a commercial product
Use the function IsWrongPwd() to determine whether the function failed due to a wrong password.
The function requires the return value of this function to determine whether the password was
wrong. The function can be executed in a loop so that the user is able to enter another password.
Damaged PDF files
The function reads the file header, the cross-reference tables and the required global objects when
opening a PDF file. It checks also if the first page object is available. When it is possible to load these
objects without errors then the file is loaded in normal mode by using the cross-reference table to
fetch objects. If an error occurs during loading the global objects then the function tries to repair the
file by scanning the all the objects in the file to rebuild the cross-reference table.
However, PDF files can contain damages in the cross-reference table which cause not necessarily an
error when opening the file, e.g. when the damages affect only specific pages in the file. In such cases
it is possible to load a file explicitely in repair mode. This can be achieved with the flag
ptForceRepair. The flag must be combined with a binary or operator with the parameter PwdType,
e.g. (TPwdType)(ptOpen | ptForceRepair).
The ptForceRepair flag should only be set if it was not possible to load specific pages due to errors in
the file. Check first whether the file was not already loaded in repair mode with GetInRepairMode().
If the function returns false then load the file in repair mode and try to import it again. If the file
contains no fatal errors then it is often possible to repair the damages.
The repair mode is supported for PDF files with an uncompressed file structure only because PDF
files with a compressed object structure are organized in a manner that does not allow further repair
This function is implemented in an Ansi and Unicode compatible version. Unicode paths are
converted to UTF-8 on non-Windows operating systems.

Previous topic: Editing encrypted PDF files

Next topic: OpenOutputFileEncrypted

Web links on this page: