Print Page | Close Window

SetFormFieldValue

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=1096
Printed Date: 12 Dec 25 at 5:35PM
Software Version: Web Wiz Forums 11.01 - http://www.webwizforums.com


Topic: SetFormFieldValue
Posted By: HMArnold
Subject: SetFormFieldValue
Date Posted: 03 Jun 09 at 12:48AM
When I run the following code, I get a count of 19 fields available, but after I run it I get a new PDF but the fields have no data:
 
procedure TForm1.ScanButtonClick(Sender: TObject);
var Fields, x                             : integer;
    ExptFile                              : string;
    PDF                                   : TQuickPDF0712;
begin
  ExptFile := 'Test.pdf';
  PDF := TQuickPDF0712.Create;
  try
    if PDF.UnlockKey('xx') <> 1
      then Raise EInvalidOp.Create('invalid unlock code');
    if PDF.LoadFromFile(MasterPDF) <> 1
      then Raise EInvalidOp.Create('unable to open PDF file : '+MasterPDF);
    PDF.SetNeedAppearances(1);
    Fields := PDF.FormFieldCount;
    ListBox1.Items.Add('Form Fields : '+IntToStr(Fields));
    for x := 1 to Fields do
      begin
        if PDF.SetFormFieldValue (x,'Test '+IntToStr(x)) = 1 then ListBox1.Items.Add('ok');
        PDF.UpdateAppearanceStream(x);
      end;
    if PDF.SaveToFile(ExptFile) <> 1
      then Raise EInvalidOp.Create('unable to save PDF file : '+ExptFile);
    ListBox1.Items.Add('File saved : '+ExptFile);
    except Raise EInvalidOp.Create('PDF operation error');
  end;
end;
Does anyone have example code?
 
Thanks



Replies:
Posted By: Ingo
Date Posted: 03 Jun 09 at 6:17AM
Hi!

With your code the values are inside the formfields ... but not visible.
If you want to make formfield-content visible you have to change the content to text.
Please read about the function "FlattenFormField" that's what you need.

Cheers, Ingo



Posted By: HMArnold
Date Posted: 03 Jun 09 at 12:43PM

I saw that in an earlier post of your and had tried that with no effect.

After I checked the encyption status I saw the original PDF was protected, so I used the DecryptFile function first, and that allowed me to change the fields.
 
Thanks for your help!
 
Hank



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