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!
![]() |
Set Form Field Value problems |
Post Reply ![]() |
Author | |
Francesco_Halley ![]() Beginner ![]() Joined: 23 Feb 10 Status: Offline Points: 5 |
![]() ![]() ![]() ![]() ![]() 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
|
|
![]() |
|
Ingo ![]() Moderator Group ![]() ![]() Joined: 29 Oct 05 Status: Offline Points: 3524 |
![]() ![]() ![]() ![]() ![]() |
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 |
|
![]() |
|
Francesco_Halley ![]() Beginner ![]() Joined: 23 Feb 10 Status: Offline Points: 5 |
![]() ![]() ![]() ![]() ![]() |
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. 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
|
|
![]() |
|
Shotgun Tom ![]() Senior Member ![]() ![]() Joined: 14 Aug 09 Location: Phoenix, AZ Status: Offline Points: 53 |
![]() ![]() ![]() ![]() ![]() |
You can use the standard FormFieldCount to get your field count.
(function TQuickPDF0717.FormFieldCount: Integer;)
Tom
|
|
![]() |
|
Ingo ![]() Moderator Group ![]() ![]() Joined: 29 Oct 05 Status: Offline Points: 3524 |
![]() ![]() ![]() ![]() ![]() |
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 |
|
![]() |
|
Jack ![]() Team Player ![]() ![]() Joined: 03 Jun 09 Location: Lompoc, CA Status: Offline Points: 22 |
![]() ![]() ![]() ![]() ![]() |
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.
|
|
![]() |
|
Francesco_Halley ![]() Beginner ![]() Joined: 23 Feb 10 Status: Offline Points: 5 |
![]() ![]() ![]() ![]() ![]() |
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
|
|
![]() |
|
Ingo ![]() Moderator Group ![]() ![]() Joined: 29 Oct 05 Status: Offline Points: 3524 |
![]() ![]() ![]() ![]() ![]() |
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 |
|
![]() |
|
Francesco_Halley ![]() Beginner ![]() Joined: 23 Feb 10 Status: Offline Points: 5 |
![]() ![]() ![]() ![]() ![]() |
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 |
|
![]() |
|
Ingo ![]() Moderator Group ![]() ![]() Joined: 29 Oct 05 Status: Offline Points: 3524 |
![]() ![]() ![]() ![]() ![]() |
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 |
|
![]() |
|
Francesco_Halley ![]() Beginner ![]() Joined: 23 Feb 10 Status: Offline Points: 5 |
![]() ![]() ![]() ![]() ![]() |
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
|
|
![]() |
|
Ingo ![]() Moderator Group ![]() ![]() Joined: 29 Oct 05 Status: Offline Points: 3524 |
![]() ![]() ![]() ![]() ![]() |
There's no need for a workaround.
Both functions will give you the same result. Sure. Probably there's something mixed anywhere set.../get... |
|
![]() |
Post Reply ![]() |
|
Tweet
|
Forum Jump | Forum Permissions ![]() You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |
Copyright © 2017 Debenu. Debenu Quick PDF Library is a PDF SDK. All rights reserved. About — Contact — Blog — Support — Online Store