CloseMemDecrypt Method

Closes the handle to the PDF file without any
encryption-based security applied. All write operations to the PDF
are finalized and all internal memory structures are released. Use
this method if you want your output PDF to be decrypted.

Function CloseMemDecrypt() As Variant

byte[] CloseMemDecrypt()

byte[] CloseMemDecrypt() throws
PDFProcessorException

Parameters

N/A.

Return Values

If the file handle is open and was obtained by calling OpenMem, the decrypted output
PDF is returned.

Otherwise, if the file handle was obtained by calling OpenFile, or has already been
previously closed, an empty array of size zero is returned.

While CloseMemDecrypt will always properly close the file handle
regardless of how the handle was originally obtained, suggested
practice is to call CloseMemDecrypt when the file handle was
retrieved using OpenMem
and modifications have been made to the PDF. This way you get the
decrypted modified PDF stream back.

In all other cases, such as when the file handle was retrieved
using OpenFile or the
PDF was only queried but not modified, calling CloseDecrypt will suffice.

Remarks

Note 1:

If you want a decrypted output PDF, be sure to call CloseDecrypt or CloseMemDecrypt when you
are finished modifying your PDF. If you do not close the file
handle, the PDF will not be fully written out and is considered
invalid. Additionally, memory used internally by the file handle
will not be deallocated; in some languages and frameworks this will
manifest as a memory leak, and in others it could result in
unpredictable garbage collection since EasyPDF SDK is unmanaged
code. Always be sure to call CloseDecrypt or CloseMemDecrypt when you
want to write out a decrypted PDF.

Once the file handle is closed, no further calls on any of the
handle's methods are allowed, except that Close, CloseMem,
CloseEncrypt, CloseMemEncrypt, CloseDecrypt, or CloseMemDecrypt may be
called repeatedly. Thus, if you are using the try-catch-finally
idiom, you may safely call Close or its
variants in the finally block regardless of earlier handle
closes.

Note, however, that only the first call to Close, CloseMem,
CloseEncrypt, CloseMemEncrypt, CloseDecrypt, or CloseMemEncrypt actually
closes the file handle, and it does so regardless of success or
failure. If the first call to Close or
its variants fails for some reason, then the file handle is closed,
its internal memory is freed, and an exception is thrown. Any call
to Close or its variants other than the
first call will be ignored (it will not do anything but will not
produce an error either).

Note 2:

If your original input PDF was not encrypted, it is still safe
to call CloseDecrypt or CloseMemDecrypt. In this situation, the
behavior would be the same as if you had simply called Close or CloseMem.