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 - Set Form Field Value problems
  FAQ FAQ  Forum Search   Register Register  Login Login

Set Form Field Value problems

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


Joined: 23 Feb 10
Status: Offline
Points: 5
Post Options Post Options   Thanks (0) Thanks(0)   Quote Francesco_Halley Quote  Post ReplyReply Direct Link To This Post Topic: Set Form Field Value problems
    Posted: 23 Feb 10 at 10:50AM
Hi,
i have a pre-built pdf file which contains text fields.
Now i want to fill these fields with my information.
I use DAOpenFile to open the pdf file.
I use DAGetFormFieldCount to get the number of the fields.
I use DAGetFormFieldTitle to get the name of the filed.
But, when i use SetFormFieldValue method to replace the old value, it doesn't work.
I think i can't use direct access functions together with standard functions.
But i didn't find a whole of functions (DA or standard) that allows me to reach my goal.
So, do you know a method which can help me?
 
Thank you very much
 
Francesco Passarini
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: 23 Feb 10 at 1:43PM
Hi Francesco!

Again: It doesn't matter what you wanna do or not... DON'T MIX DA- and non-DA-functions.
At the "general section" i've posted a message for "the first steps"... It's all there what you need.
ffc := QP.FormFieldCount;
// . . .      
for i := 1 to ffc do
    begin
// . . .
//     get a value ...
       nffv := QP.GetFormFieldValue(i);
// . . .
//     set a value ...
       QP.SetFormFieldValue( i, FieldValue );

Cheers and welcome here,
Ingo

Back to Top
Francesco_Halley View Drop Down
Beginner
Beginner


Joined: 23 Feb 10
Status: Offline
Points: 5
Post Options Post Options   Thanks (0) Thanks(0)   Quote Francesco_Halley Quote  Post ReplyReply Direct Link To This Post Posted: 23 Feb 10 at 2:08PM

Hi Ingo,

I wanna explain better my mistake. I need to merge some data (saved on a text file) with a pdf which contains text fields. If i use DA functions i can't use the SetFormFieldFunction, while if i use the standard instructions i can't use the the GetFromFieldCount. I need to know the number of fields because i want to flatten them at the end of the operations, and FlattenFormField method need the index of the field. 

So i found this solution: i used the DAOpenFunction to open the pdf file. Once obtained the Field Count, i closed the direct link and i loaded the file using standard options.
Then i filled the fields using a loop, flattening each one at the end.

This is my sample code:
 
int file_handle = QP.DAOpenFile("file.pdf","");  
int num_fields = QP.DAGetFormFieldCount(file_handle);   
QP.DACloseFile(file_handle);
// ...
int new_file = QP.LoadFromFile("file.pdf");
// ...
for(i=0; i<num_fields; i++)
{
 field_name = QP.GetFormFieldTitle(i);
 if(field_name.compare("...")==0)
 {
  int app = QP.SetFormFieldValue(i,"new value");       
  QP.FlattenFormField(i);         
  break;           
 }
}
 
thank you again Ingo
 
Francesco
Back to Top
Shotgun Tom View Drop Down
Senior Member
Senior Member
Avatar

Joined: 14 Aug 09
Location: Phoenix, AZ
Status: Offline
Points: 53
Post Options Post Options   Thanks (0) Thanks(0)   Quote Shotgun Tom Quote  Post ReplyReply Direct Link To This Post Posted: 23 Feb 10 at 4:53PM
You can use the standard FormFieldCount to get your field count.
 
 (function TQuickPDF0717.FormFieldCount: Integer;)
 
Tom
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: 23 Feb 10 at 7:22PM
Hi!

I agree with Tom:
I can't understand why you're using the DA-functions?
The same functions without "DA" are available in the lib.

Cheers, Ingo
Back to Top
Jack View Drop Down
Team Player
Team Player
Avatar

Joined: 03 Jun 09
Location: Lompoc, CA
Status: Offline
Points: 22
Post Options Post Options   Thanks (0) Thanks(0)   Quote Jack Quote  Post ReplyReply Direct Link To This Post Posted: 23 Feb 10 at 10:28PM
I have been doing something similar for a while.  My data comes from SQL queries.  I don't use any DA functions.  It works kind of cool.  I don't know C++ very well, but from what I see of your code, it looks like it should work.
Back to Top
Francesco_Halley View Drop Down
Beginner
Beginner


Joined: 23 Feb 10
Status: Offline
Points: 5
Post Options Post Options   Thanks (0) Thanks(0)   Quote Francesco_Halley Quote  Post ReplyReply Direct Link To This Post Posted: 25 Feb 10 at 11:04AM

Hi guys,

i tried this code:
int new_file = QP.LoadFromFile("C:\\dir\\form_file.pdf");
int num_fields = QP.FormFieldCount();
 
but QP.FormFieldCount(); give me back value 0.
What did i forget?
Any post will be helpful for me.
Thank you very much
 
Francesco
 

 

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: 25 Feb 10 at 11:50AM
Hi!

You did the create first and then the unlock-function?
What's possible:
It's not a real form.
What's the returning value from "new_file"? "1"? If it's "0" then there's already the error.

Cheers, Ingo

Back to Top
Francesco_Halley View Drop Down
Beginner
Beginner


Joined: 23 Feb 10
Status: Offline
Points: 5
Post Options Post Options   Thanks (0) Thanks(0)   Quote Francesco_Halley Quote  Post ReplyReply Direct Link To This Post Posted: 25 Feb 10 at 11:56AM

Sorry, i saw it was a my problem. But now the FormFieldCount() function gives me back twice value of the fields (96 instead of 48), and not all fields turn flattened. I'll put a new post when i'll able to solve the problem.

Francesco
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: 25 Feb 10 at 1:05PM
So the form-creation already went wrong 48 unvisible fields... 48 visible fields... something like that?

Cheers, Ingo


Edited by Ingo - 25 Feb 10 at 1:06PM
Back to Top
Francesco_Halley View Drop Down
Beginner
Beginner


Joined: 23 Feb 10
Status: Offline
Points: 5
Post Options Post Options   Thanks (0) Thanks(0)   Quote Francesco_Halley Quote  Post ReplyReply Direct Link To This Post Posted: 25 Feb 10 at 1:57PM
Hi Ingo,
i dont know if there are hidden fields. When i opened the file using DA access
DAGetFormFieldCount returned me back 48, now, using FormFieldCount, 96.
But i found a solution to my problem without using the field count:
 
int new_file = QP.LoadFromFile("form_file.pdf"); 
ifstream values_file;
values_file.open("new_data_file.txt", ios::in);       
 string line, field_name;
while(getline(values_file,line))            {
 string fn = getFieldName_byFile(line);  //read the name of the field to edit       
 string fv = getFieldValue_byFile(line);  //read the new field value from file       
   
 QP.SetFormFieldValueByTitle(fn,fv);
 int id_field = QP.FindFormFieldByTitle(fn);
 if(id_field != 0)
  QP.FlattenFormField(id_field);
}
 
Thank you
 
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: 25 Feb 10 at 3:28PM
There's no need for a workaround.
Both functions will give you the same result. Sure.
Probably there's something mixed anywhere set.../get...

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