ImageEn for Delphi and C++ Builder ImageEn for Delphi and C++ Builder

 

ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 Encrypted PDF-files

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

View 
UserName:
Password:
Format  Bold Italicized Underline  Align Left Centered Align Right  Horizontal Rule  Insert Hyperlink   Browse for an image to attach to your post Browse for a zip to attach to your post Insert Code  Insert Quote Insert List
   
Message 

 

Emoji
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Black Eye [B)]
Frown [:(] Shocked [:0] Angry [:(!] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
jenswahl Posted - Dec 29 2022 : 05:39:16
Hello,

is there any way to check if a PDF file needs a password or not? Unfortunately I was not been able to find anything in the help and demos.
We can pass the password in LoadFromFilePDF. But I would like to have the possibility to query the password before (input by the user).

Kind Regards,

Jens



www.inntalsoftware.de/en/
2   L A T E S T    R E P L I E S    (Newest First)
jenswahl Posted - Jan 04 2023 : 01:42:35
Thank you Nigel for the code. I will try it.

Kind Regards,

Jens

www.inntalsoftware.de/en/
xequte Posted - Jan 03 2023 : 21:57:05
Hi Jens

You can use:

// Determine if a file is password protected
function PdfFileIsPasswordProtected(const Filename: string): Boolean;
var
  iev: TImageEnView;
begin
  Result := False;
  try
    iev := TImageEnView.Create(nil);
    try
      iev.PdfViewer.Enabled := True;
      iev.IO.LoadFromFilePDF( Filename, -1, -1, '' );
    finally
      iev.Free;
    end;
  except
    on e: Exception do
      if e.Message = RsPdfErrorPassword then  // Defined in iexPdfiumCore = 'Invalid password'
        Result := True;
  end;
end;


Nigel
Xequte Software
www.imageen.com