Code Samples - Document Converter Pro

Example 13: Encrypt an existing PDF file (AES 256 bits) - Delphi Copy 

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
   procedure TForm1.PDFEncryptClick(Sender: TObject);
   var
     DC   : Variant;
     RVal : Integer;
   begin
     try
       DC := CreateOleObject('Neevia.docConverter');

       DC.setParameter( 'PDFEncryption', 'true' );
       DC.setParameter( 'PDFEncryptionType', 'aes256' );

       DC.setParameter( 'PDFOwnerPassword', 'owner' );
       DC.setParameter( 'PDFUserPassword', 'open' );

       // p - disable document printing
       // e - disable extraction of text and graphics
       DC.setParameter( 'Permissions', 'pe' );

       RVal := DC.encryptPDF('c:\users\public\in.pdf', 'c:\users\public\out.pdf');
       If (RVal <> 0) Then
         ShowMessage('There was an error!!! Code: '+IntToStr(RVal))
       Else
         ShowMessage('Done !!!');
     finally
       DC:= Unassigned;
     end;
   end;