Xojo Conferences
MBSOct2019CologneDE

DynaPDF Manual - Page 522

Previous Page 521   Index   Next Page 523

Function Reference
Page 522 of 766
OpenImportFile
SI32 pdfOpenImportFile(
const PPDF* IPDF,
// Instance pointer
const char* FileName, // File path to PDF file
TPwdType PwdType,
// Kind of password see below
const char* Password) // Password to decrypt the file
typedef enum
{
ptOpen
= 0, // Open password
ptOwner
= 1, // Owner password
ptForceRepair = 2, // See description below
ptDontCopyBuf = 4
// Not meaningful with OpenImportFile()
}TPwdType;
The function opens an external PDF file so that it can be imported entirely or parts of it. After a PDF
file was opened, properties of it can be derived by several functions such as GetInDocInfo(),
GetInPageCount() and so on. To import specific pages from the file use the functions ImportPage() or
ImportPageEx(). The entire PDF file can be imported with the function ImportPDFFile() (see example
below).
The parameter PwdType specifies the kind of password that is supplied to the function to decrypt a
PDF file if necessary. If the file is not encrypted the parameter Password is ignored.
It is not required to close a PDF file explicitly before another one can be opened. However, if the file
is no longer needed then it should be closed with CloseImportFile().
Recommended settings to split PDF files
To improve processing speed when splitting large PDF files into smaller pieces, one or more PDF
files can be loaded permanent into memory. In this case the PDF files are not automatically closed
when CloseFile() or FreePDF() is called. In order to load a PDF file permanent into memory set the
property SetUseGlobalImpFiles() to true.
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 3.0.26.69 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.
 

Previous topic: How to keep multiple memory based PDF files open?

Next topic: Editing encrypted PDF files