ImageEn, unit iesettings

TIEGlobalSettings.OnPassword

TIEGlobalSettings.OnPassword


Declaration

property OnPassword: TIEPasswordEvent;


Description

Allows you to specify custom handling if a password is required when opening an encrypted PDF file using the PDFium PlugIn or an encrypted ZIP file using the SevenZip PlugIn (when no password or an invalid password has been specified).
If you specify a password, set Handled to true. To cancel, specify a blank password and set Handled to true.
If Handled = False (Default) then a built-in password prompt will be displayed (if AutoPromptForPassword is enabled).
FileType will be ioPDF or iomscZIP.


Examples

IEGlobalSettings().OnPassword := ImageEnPasswordEvent;

// Prompt the user for a password (This is the same as using IEGlobalSettings().AutoPromptForPassword)
procedure TMainForm.ImageEnPasswordEvent(Sender: TObject; const Filename: string; FileType: TIOFileType; var Password: String; var Handled: Boolean);
begin
  Password := InputBox( format( 'Specify a password for %s', [ ExtractFilename( Filename )]),
                        'Specify Password: ',
                        '' );
  Handled := True;
end;

// Return a password for a specified file
procedure TMainForm.ImageEnPasswordEvent(Sender: TObject; const Filename: string; FileType: TIOFileType; var Password: String; var Handled: Boolean);
begin
  if SameText( fCurrentFilename, Filename ) then
  begin
    Password := fCurrentPassword;
    Handled := True;
  end;
end;