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 - Security settings for PDF forms
  FAQ FAQ  Forum Search   Register Register  Login Login

Security settings for PDF forms

 Post Reply Post Reply
Author
Message
galcott View Drop Down
Beginner
Beginner


Joined: 07 May 09
Status: Offline
Points: 5
Post Options Post Options   Thanks (0) Thanks(0)   Quote galcott Quote  Post ReplyReply Direct Link To This Post Topic: Security settings for PDF forms
    Posted: 07 May 09 at 10:03PM
I am testing the library now and I need to fill in some form fields in an existing PDF then save the file under another name. When I do this, the new file opens in Acrobat with a message saying that the extended features are no longer available, and the form fields are no longer available for input. I need them to be available and would like to know how to do this. Here is the test code I am using:

procedure TForm1.Button1Click(Sender: TObject);
var
  PDF: TQuickPDF0713;
  ep: integer;
begin
  PDF:=TQuickPDF0713.Create;
  PDF.LoadFromfile('c:\test1.pdf');
  PDF.SetFormFieldValue(1, '123');
  PDF.SetFormFieldValue(2, 'This is a test');
  ep:=PDF.EncodePermissions(1,1,1,1,1,1,1,1);
  PDF.Encrypt('','',1,e);
  PDF.SaveToFile('c:\test2.pdf');
end;

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: 08 May 09 at 1:35AM
Hi galcott!

Below you'll find the code i'm using to set formfield-values.
It'll work for you, too.

You should try your code with a "ep" instead of "e" in the Encrypt ;-)

Cheers, Ingo

    QP := TQuickPDF713.Create;
    try
       QP.UnlockKey('MyKey');
       QP.LoadFromFile(FileName);
       If ( QP.Encrypted > 0 ) then
            QP.Unencrypt;

       ffc := QP.FormFieldCount;
//     there are different ways to set formfields.
//     With the appearance-functionality we can set
//     a field value (and it is visible) but we can
//     still overwrite it because it is still a formfield.
//     With the flatten-functionality AFTER setting a field-
//     content the fields will be converted to normal text.
       if ffc > 0 then // Are there any formfields?
          begin

//           first version with setting via fieldindex 
             QP.SetNeedAppearances(1);
             QP.SetFormFieldValue( 1, 'my first value' );
             QP.UpdateAppearanceStream( StrToInt(Trim(FieldName)) );
//           if we use the next line it will be text and no longer fieldcontent
//           QP.FlattenFormField( 1 );

{
//           second version with setting via fieldname.
//           You can get the names via GetFormFieldTitle. 
             QP.SetNeedAppearances(1);
             QP.SetFormFieldValueByTitle( 'field1', 'my first value' );
             nresult := QP.FindFormFieldByTitle('field1');
             QP.UpdateAppearanceStream(nresult);
//           if we use the next line it will be text and no longer fieldcontent
//           QP.FlattenFormField( nresult );
}
          end;
    finally
       QP.SaveToFile(FileName);
       QP.Free;
    end;



Edited by Ingo - 08 May 09 at 1:36AM
Back to Top
galcott View Drop Down
Beginner
Beginner


Joined: 07 May 09
Status: Offline
Points: 5
Post Options Post Options   Thanks (0) Thanks(0)   Quote galcott Quote  Post ReplyReply Direct Link To This Post Posted: 08 May 09 at 2:11AM
I did have the correct variable in my code; I must have deleted a character when composing the message.

But this doesn't solve my problem. The message still comes up in Acrobat and the fields are no longer available to edit. On the security tab of the document properties page, filling of form fields is listed as not allowed. I need this to be allowed and I thought the EncodePermissions would do that, but it doesn't. So how can I accomplish this?

Glenn

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: 08 May 09 at 2:16AM
Is the pdf already encrypted before?
Then first unencrypt it.
Do you see the values you inserted in the fields?

Cheers, Ingo
Back to Top
galcott View Drop Down
Beginner
Beginner


Joined: 07 May 09
Status: Offline
Points: 5
Post Options Post Options   Thanks (0) Thanks(0)   Quote galcott Quote  Post ReplyReply Direct Link To This Post Posted: 11 May 09 at 8:41PM
I did unencrypt it, with no difference. I do see the values I inserted, but the form is no longer available to fill in.
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: 12 May 09 at 1:33AM
Hi!

Then you didn't do it like i've described before?
Is it always this way or only one special file?

Cheers, Ingo



Edited by Ingo - 12 May 09 at 1:35AM
Back to Top
galcott View Drop Down
Beginner
Beginner


Joined: 07 May 09
Status: Offline
Points: 5
Post Options Post Options   Thanks (0) Thanks(0)   Quote galcott Quote  Post ReplyReply Direct Link To This Post Posted: 12 May 09 at 10:58AM
I've tried 3 different files with the same result.

I was also trying another product (Gnostice PDF Toolkit) that has similar functionality, and had a similar problem. I contacted their support and they told me that it was an issue with "usage rights" which is a recently added feature of Adobe that they don't support yet. Is it the same issue with QuickPDF?

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: 12 May 09 at 2:06PM
So i think these files are all from the same producer.
Are they working with non-standard-security handlers?
That can be the reason (like gnostice told you already).
A missing special security handler you can only get from the producer of the document.
@All: In cases like this it's always better if you send sample-files. Cases having to do with access-rights and / or security handlers can be determined immediately.

Cheers, Ingo

Back to Top
galcott View Drop Down
Beginner
Beginner


Joined: 07 May 09
Status: Offline
Points: 5
Post Options Post Options   Thanks (0) Thanks(0)   Quote galcott Quote  Post ReplyReply Direct Link To This Post Posted: 12 May 09 at 4:15PM
The files are not from the same producer and I don't know anything about their security settings. Please download them from this link and let me know if you can find anything. Thanks.

http://www.galcott.com/pdf_files.zip

Glenn

Back to Top
Rowan View Drop Down
Moderator Group
Moderator Group
Avatar

Joined: 10 Jan 09
Status: Offline
Points: 398
Post Options Post Options   Thanks (0) Thanks(0)   Quote Rowan Quote  Post ReplyReply Direct Link To This Post Posted: 12 May 09 at 9:48PM
Hi Glenn,

The PDFs in your attachment have had extended usage rights added to them by Adobe LiveCycle Designer (or a similar Adobe related product). So when you use Quick PDF Library to modify the file (or any other non-Adobe product), it is corrupting the extended features in some way and then as a result Adobe Reader is showing you the error message about extended features no longer being available.

If you want to use Quick PDF Library with these PDFs then you will need to open the PDFs in Adobe Acrobat and choose File > Save a Copy... this will remove the extended features from the PDF and allow you to then modify the PDF without any further problems.

I have written a knowledge base article about Adobe Reader Extensions / Usage Rights that you might find useful.

Cheers,
- Rowan.
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