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

DynaPDF Manual - Page 512

Previous Page 511   Index   Next Page 513

Function Reference
Page 512 of 750
After the file or files were fully processed, set the property back to false before closing the last PDF
file in memory or call FreePDF() so that all open import files can be released. For an example take a
look into the description of SetUseGlobalImpFiles().
How to keep multiple PDF files open?
Since DynaPDF it is possible to hold more than one PDF file open to improve the resource
handling when pages from different PDF files cannot be imported in one pass.
A parser instance contains a duplicate array to determine whether a PDF object must be imported or
not. When the parser will be deleted, e.g. when CloseImportFile() was called, then there is no more a
way to determine whether an object was already imported if the same PDF file will be opened again
to import additional pages or objects of it. This yields often to double resources since already
imported objects can no longer be shared.
To avoid this issue, it is possible to hold more than one parser instance in memory. This is the case if
the flag if2UseProxy is set and if CloseImportFile() was not called before opening the next PDF file
(the flag can be set with SetImportFlags2()).
The function returns the file or parser handle in this case, a value greater or equal zero. This handle
can be used to close or re-open a specific parser instance with CloseImportFileEx() or
CloseImportFile() closes the last open import file as usual and deletes the corresponding parser
A parser instance requires about 280 KB memory depending on the number of objects in it. The
memory usage grows a little bit when pages will be imported. Therefore, it is recommended to close
instances when no longer needed to reduce the memory usage.
In most cases it should be possible to hold any number of PDF files open that fits into the 4 GB
output limit of the resulting PDF file. However, PDF files which contain only one page should be
closed immediatly after the contents was imported.
OpenImportFile() checks whether an existing instance can be used before it creates a new one.
Therefore, it is safe to open the same PDF file arbitrary often. More efficient to re-open existing
parser instances is to call ReOpenImportFile() with the file handle that OpenImportFile() returned.
DynaPDF makes sure that no more than 6 file handles are opened simultaneously during import.
Maximal 12 files are kept opened simultaneously if SetUseGlobalImpFiles() was set to true. This
ensures that mutliple PDF files can be efficiently imported and written to disk without using too
many system resources. The overhead to re-open additional files is minimal.
Editing encrypted PDF files
If your application should allow the modification of encrypted PDF files, you may check the access
permissions to grant user rights, if the file was opened with the open password instead of the owner
password (see also GetUserRights()).

Previous topic: Recommended settings to split PDF files

Next topic: Damaged PDF files