BCL easyPDF SDK
easyPDF SDK Usermanual
PDF Creator Programming API  |  Download Free Trial  |  Contact Us to Purchase

CloseDecrypt 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.

Sub CloseDecrypt()

void CloseDecrypt()

void CloseDecrypt() throws PDFProcessorException

Parameters

N/A.

Return Values

N/A.

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 CloseMemDecrypt 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.

Example Usage in VBScript

Set oProcessor = CreateObject("easyPDF.PDFProcessor.8")
Set oProcessorHandle = oProcessor.OpenFile("C:\test\input.pdf", "C:\test\output.pdf", "ownerPassword")
oProcessorHandle.AddHyperlink 0, _
                              0, _
                              50, _
                              80, _
                              370, _
                              100, _
                              "http://www.bcltechnologies.com/", _
                              PRC_BORDERSTYLE_DASHLINE_MEDIUM, _
                              RGB(255, 0, 0)
oProcessorHandle.AddStamp "C:\test\image.jpg", _
                          0, _
                          PRC_STAMP_HPOS_CENTER, _
                          PRC_STAMP_VPOS_CENTER, _
                          PRC_STAMP_ZORDER_TOP, _
                          0, _
                          0, _
                          0, _
                          100
oProcessorHandle.CloseDecrypt

Example Usage in VB.NET

Dim oProcessor As PDFProcessor = Nothing
Dim oProcessorHandle As PDFProcessorHandle = Nothing
Try
   oProcessor = New PDFProcessor
   oProcessorHandle = oProcessor.OpenFile("C:\test\input.pdf", "C:\test\output.pdf", "ownerPassword")
   oProcessorHandle.AddHyperlink(0, _
                                 0, _
                                 50, _
                                 80, _
                                 370, _
                                 100, _
                                 "http://www.bcltechnologies.com", _
                                 prcAnnotBorderStyle.PRC_BORDERSTYLE_DASHLINE_MEDIUM, _
                                 0)
   oProcessorHandle.AddStamp("C:\test\image.jpg", _
                             0, _
                             prcStampHPosition.PRC_STAMP_HPOS_CENTER, _
                             prcStampVPosition.PRC_STAMP_VPOS_CENTER, _
                             prcStampZOrder.PRC_STAMP_ZORDER_TOP, _
                             0, _
                             0, _
                             0, _
                             100)

   oProcessorHandle.CloseDecrypt()
Catch ex As System.Runtime.InteropServices.COMException


   MessageBox.Show(ex.Message)
Finally
      oProcessorHandle.Close()
End Try

Example Usage in C#

PDFProcessor oProcessor = null;
PDFProcessorHandle oProcessorHandle = null;
try
{
   oProcessor = new PDFProcessor();
   oProcessorHandle = oProcessor.OpenFile(@"C:\test\input.pdf", @"C:\test\output.pdf", "ownerPassword");
   oProcessorHandle.AddHyperlink(0, 
                                 0, 
                                 50, 
                                 80, 
                                 370, 
                                 100, 
                                 "http://www.bcltechnologies.com", 
                                 prcAnnotBorderStyle.PRC_BORDERSTYLE_DASHLINE_MEDIUM, 
                                 0);
   oProcessorHandle.AddStamp(@"C:\test\image.jpg", 
                             0, 
                             prcStampHPosition.PRC_STAMP_HPOS_CENTER, 
                             prcStampVPosition.PRC_STAMP_VPOS_CENTER, 
                             prcStampZOrder.PRC_STAMP_ZORDER_TOP, 
                             0, 
                             0, 
                             0, 
                             100);

   oProcessorHandle.CloseDecrypt();
}
catch(System.Runtime.InteropServices.COMException ex)
{
   MessageBox.Show(ex.Message);
}
finally
{
oProcessorHandle.Close();
}