Print Page | Close Window

Security settings for PDF forms

Printed From: Debenu Quick PDF Library - PDF SDK Community Forum
Category: For Users of the Library
Forum Name: I need help - I can help
Forum Description: Problems and solutions while programming with the Debenu Quick PDF Library and Debenu PDF Viewer SDK
URL: http://www.quickpdf.org/forum/forum_posts.asp?TID=1081
Printed Date: 12 May 24 at 4:29PM
Software Version: Web Wiz Forums 11.01 - http://www.webwizforums.com


Topic: Security settings for PDF forms
Posted By: galcott
Subject: Security settings for PDF forms
Date 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;




Replies:
Posted By: Ingo
Date 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;



Posted By: galcott
Date 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



Posted By: Ingo
Date 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


Posted By: galcott
Date 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.


Posted By: Ingo
Date 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



Posted By: galcott
Date 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?



Posted By: Ingo
Date 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



Posted By: galcott
Date 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



Posted By: Rowan
Date 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 http://www.quickpdflibrary.com/kb/index.php?sid=7403&lang=en&action=artikel&cat=3&id=38&artlang=en - Adobe Reader Extensions / Usage Rights that you might find useful.

Cheers,
- Rowan.



Print Page | Close Window

Forum Software by Web Wiz Forums® version 11.01 - http://www.webwizforums.com
Copyright ©2001-2014 Web Wiz Ltd. - http://www.webwiz.co.uk