DynaPDF Manual - Page 574

Previous Page 573   Index   Next Page 575

Function Reference
Page 574 of 839
The function opens an external PDF file like OpenImportFile() but accepts a file buffer as input.
The function supports the additional flag ptDontCopyBuf to specify whether the import buffer
should be copied to an internal buffer or not.
If the flag ptDontCopyBuf is absent then DynaPDF creates a copy of the input buffer before it will be
accessed. The original buffer should be released immediately after the function returns in this case.
The internal copy of the file buffer will be released when CloseImportFile() is called, when loading
another PDF file, or when the PDF file in memory is closed.
If the flag ptDontCopyBuf is set, then the function works directly with the source buffer without
creating a copy of it. This reduces the memory usage and improves the processing speed due to the
unnecessary copy action. However, the caller must make sure that the buffer exist until
CloseImportFile() is called. When finish, call first CloseImportFile() and then release the input
How to keep multiple memory based PDF files open?
It is also possible to hold more than one memory based PDF file simultaneously 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 flag reduces also the memory usage and
should normally be set by default.
Be careful with the flag ptDontCopyBuf when loading more than one PDF file into memory. Do not
delete the buffer before all required parts of the PDF file were imported!
Since memory based PDF files have no file name, an existing instance can only be re-opened with
ReOpenImportFile(). The function requires the file handle that OpenImportBuffer() returned. To
reduce the memory usage, memory based PDF files should be closed as soon as possible. A specific
file instance can be closed with CloseImportFileEx().
The flag ptForceRepair can be used to explicitely load a PDF file in repair mode. The usage of is
described at OpenImportFile().
Return values:
If the function succeeds the return value is zero or the file handle if the flag if2UseProxy is set (a
value greater or equal zero). If the function fails the return value is a negative error code. See also

Previous topic: NewPDF, Thread-safety, OpenImportBuffer

Next topic: OpenImportFile, Recommended settings to split PDF files, How to keep multiple PDF files open?