Do you own a Debenu Quick PDF Library version 7, 8, 9, 10, 11, 12, 13 or iSEDQuickPDF license? Upgrade to Debenu Quick PDF Library 14 today!

Debenu Quick PDF Library - PDF SDK Community Forum Homepage
Forum Home Forum Home > For Users of the Library > I need help - I can help
  New Posts New Posts RSS Feed - I need to find if a PDF file is encrypted
  FAQ FAQ  Forum Search   Register Register  Login Login

I need to find if a PDF file is encrypted

 Post Reply Post Reply
Author
Message
SuperDave View Drop Down
Team Player
Team Player
Avatar

Joined: 10 Nov 05
Location: United Kingdom
Status: Offline
Points: 19
Post Options Post Options   Thanks (0) Thanks(0)   Quote SuperDave Quote  Post ReplyReply Direct Link To This Post Topic: I need to find if a PDF file is encrypted
    Posted: 22 Dec 05 at 5:04PM
Hi,
I am adding note annotations using QP.AddNoteAnnotation which works really well except if the file is encrypted the note comes out as garbage.
If I knew that a file is encrypted I could prevent the user from adding a note to it.
Anyone know of a function (even if it is not a QP function) that can find if a PDF is encrypted.
Thanks.
Back to Top
Ingo View Drop Down
Moderator Group
Moderator Group
Avatar

Joined: 29 Oct 05
Status: Offline
Points: 3524
Post Options Post Options   Thanks (0) Thanks(0)   Quote Ingo Quote  Post ReplyReply Direct Link To This Post Posted: 22 Dec 05 at 5:52PM
Hi Dave!
You can use the functions Encrypted and Unencrypt:

. . .

   try
      Save_Cursor   := Screen.Cursor;
      Screen.Cursor := crHourglass;    // Show hourglass cursor
      QP.UnlockKey('MyKey');
      QP.LoadFromFile(Edit1.text);
      If QP.Encrypted > 0 Then
        QP.Unencrypt;
//    doing anything here ...
   finally
      QP.Free;
   end;

. . .

If you need more details you can do something like this here:

. . .

       ecry.Text := IntToStr(QP.Encrypted);
       If ecry.Text = '0' Then
          ecry.Text := 'Nothing';
       If ecry.Text = '1' Then
          ecry.Text := 'Adobe Standard';
       If ecry.Text = '2' Then
          ecry.Text := 'Unknown';

. . .

All is in delphi.

To your problem: First looking if the file is encrypted, then unencrypt it and then you can do the annotation.



Edited by Ingo
Cheers,
Ingo

Back to Top
SuperDave View Drop Down
Team Player
Team Player
Avatar

Joined: 10 Nov 05
Location: United Kingdom
Status: Offline
Points: 19
Post Options Post Options   Thanks (0) Thanks(0)   Quote SuperDave Quote  Post ReplyReply Direct Link To This Post Posted: 22 Dec 05 at 6:56PM
Thanks Ingo!
Your help is really useful to me.
I now have notes adding to encrypted PDFs and have also managed to re-encrypt them using the encryptwithfingerprint function.
You're a Star Ingo.
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 11.01
Copyright ©2001-2014 Web Wiz Ltd.

Copyright © 2017 Debenu. Debenu Quick PDF Library is a PDF SDK. All rights reserved. AboutContactBlogSupportOnline Store