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!
![]() |
Fill Form Field by Name - strange name |
Post Reply ![]() |
Author | |
Rick_Dev ![]() Beginner ![]() ![]() Joined: 25 Jan 12 Status: Offline Points: 9 |
![]() ![]() ![]() ![]() ![]() Posted: 25 Jan 12 at 6:36PM |
Hello,
I'm trying to fill in an IRS tax form field. When I run through all fields in the document and get the names I see this is the field name I want to populate as returned by QuickPDFGetFormFieldTitle. topmostSubform[0].Page1[0].Pg1Header[0].EINAndName[0].f1_02_0_[0] I've tried calling QuickPDFSetFormFieldValueByTitle passing the entire string above and just 'f1_02_0_[0]'. Neither worked. Can I set the "context" in some way? I've tried doing Select Page but it didn't appear to make any difference. Any ideas? Thanks, Rick |
|
![]() |
|
AndrewC ![]() Moderator Group ![]() ![]() Joined: 08 Dec 10 Location: Geelong, Aust Status: Offline Points: 841 |
![]() ![]() ![]() ![]() ![]() |
FormFields with these types of names are XFA based form fields. There are various ways to fill there but there are no guarantees as Adobe don't make this process easy. 1. After LoadFromFile() call the following two functions and then fill the form with the standard formfield functions. QP.RemoveXFAEntries(0); QP.RemoveUsageRights(); 2. Fill the form using the XFA based form field functions. private void XFAFillAll_Click(object sender, EventArgs e) { QP.SetNeedAppearances(1); int c = QP.GetXFAFormFieldCount(); for (int i = 1; i <= c; i++) { string name = QP.GetXFAFormFieldName(i); string value = QP.GetXFAFormFieldValue(name); if (name.Contains("Button") || name.Contains("CheckBox")) QP.SetXFAFormFieldValue(name, "1"); else if (name.Contains("Date")) QP.SetXFAFormFieldValue(name, "18/03/2012"); else if (name.Contains("State")) QP.SetXFAFormFieldValue(name, "AK"); else if (name.Contains("Zip")) QP.SetXFAFormFieldValue(name, "12345"); else if (name.Contains("Amt")) QP.SetXFAFormFieldValue(name, "20000000"); else { // Remove everything up until the last '/' character int last = name.LastIndexOf('/'); string s = name.Substring(last + 1); QP.SetXFAFormFieldValue(name, "AAA"); } } QP.SaveToFile("out.pdf"); } Andrew. |
|
![]() |
|
Rick_Dev ![]() Beginner ![]() ![]() Joined: 25 Jan 12 Status: Offline Points: 9 |
![]() ![]() ![]() ![]() ![]() |
Thanks, Andrew.
That is interesting. I'm currently filling out the fields using QuickPDFSetFormFieldValue and it is working for the 5-6 fields I've tested (there are 600 in the document). I have not called RemoveXFAEntries. I'll do some more experimenting/testing. Thanks, Rick |
|
![]() |
|
Rick_Dev ![]() Beginner ![]() ![]() Joined: 25 Jan 12 Status: Offline Points: 9 |
![]() ![]() ![]() ![]() ![]() |
Well, I have an update.
Setting the XFA field with SetFormFieldValue appeared to work but it didn't really. When I look at the PDF file using PDF-Viewer from www.tracker-software.com everything appear fine. However, when I open it with Acrobat Reader I get an error "Expected a name object." Bummer. I then tried Andrew's suggestion to RemoveXFAEntries and RemoveUsageRights but then I don't get any values in my fields in the output PDF. I tried calling these methods both before and after I filled in the form values. Any suggestions? Thanks, Rick |
|
![]() |
|
Rick_Dev ![]() Beginner ![]() ![]() Joined: 25 Jan 12 Status: Offline Points: 9 |
![]() ![]() ![]() ![]() ![]() |
Update - problem resolved.
I had a bug in my code that caused it to fail after I upgraded to version 8.xx and tried Andrew's solution. Once I fixed the bug calling RemoveXFAEntries and RemoveUsageRights worked. The resulting PDF looks fine in both viewers I've tested. Thansk, Rick |
|
![]() |
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