Flattening Checkboxes

Flattening Checkboxes

Forum member · Jun 8, 2006
I need help flattening a form. I'm using the techniques in the "Replace Acro Form Fields with Text" section of http://www.DynamicPDF.com/Support/NET_Help_Library_06_03/Form%20Flattening.html Here's my problem. This works: ----------------------- I have a single checkbox named "AirConditioning" with an export value of "Yes" Before flattening the field, I check the value. If it's "Yes" then I set a string variable to "X", otherwise the variable is set to "" I then call the CreateLabel function and pass in the variable to "check" the box. This doesn't: ----------------------- I have two checkboxes, both named "TurnSignal" One has an export value of "Left", the other "Right" On the form, "Left" can be checked or "Right" can be checked or neither can be checked, but both can never be checked at the same time. (No javascript, it's just the way it works in Acrobat/Reader) As above, I check the value of the field, save it in a variable, then try the CreateLabel function, but I get an error: "Object reference not set to an instance of an object." The field's FullName and Name properties are the same. The XFDF file has just one entry for the field (no child elements) How can I get the Label to be positioned over the correct checkbox?

Re: Flattening Checkboxes

Support · Jun 8, 2006
Hello, The reason you are getting the error is because most likely you are not accessing the child field when trying to check the checkboxes. Since you have the checkboxes with the same name, they will have parent child relationship. So in your case the parent will be TurnSignal with two children named TurnSignal. So in order to check the checkboxes you will have to use the code below: C# Code: pdoc.Form.Fields["TurnSignal"].ChildFields[0].CreateLabel(.....); pdoc.Form.Fields["TurnSignal"].ChildFields[1].CreateLabel(.....); VB.NET Code: pdoc.Form.Fields("TurnSignal").ChildFields(0).CreateLabel(.....) pdoc.Form.Fields("TurnSignal").ChildFields(1).CreateLabel(.....) Thanks, ceTe Software Support Team

Re: Flattening Checkboxes

Forum member · Jun 8, 2006
OK, I'm getting closer... pdoc.Form.Fields("TurnSignal").ChildFields(0).CreateLabel(.....) pdoc.Form.Fields("TurnSignal").ChildFields(1).CreateLabel(.....) Which one is "Left" and which one is "Right"? If I look at the FullName of each ChildField, it returns "TurnSignal", so I can't say pdoc.Form.Fields("TurnSignal").ChildFields("Left").CreateLabel(.....) Thanks for the help!

Re: Flattening Checkboxes

Support · Jun 8, 2006
Hello, Since both your checkboxes have the same name, you will have to reference them using their indexes, i.e. 0 and 1. There is no way using our product, you can find out which checkbox has what export value. You will have to know this beforehand. Yes, the full name values returned for both the checkboxes will be same and will return only "TurnSignal". But if you use your PDF as template and run the FormFieldReader example, you will see three instances of "TurnSignal" where one will be parent and other two will be its children. Thanks, ceTe Software Support Team

Re: Flattening Checkboxes

Forum member · Apr 4, 2007
I am having trouble making this work. When I try to get the original page number of the checkbox, I get a null reference exception. Greg

Re: Flattening Checkboxes

Support · Apr 4, 2007
Hello Greg, The likely reason you are getting this error is because you are using the wrong field name to reference the form field. If the checkboxes on the PDF have the same name i.e. Field1, then the field name to use when referencing them would be “Field1.ChildFields[0]” and “Field1.ChildFields[1]”. The parent child relationship is how the fields are organized in the PDF document itself when they have the same name; this is not something our product is adding. If you still continue getting the error, please send over the PDF document to our [^a|mailto:support@cete.com|Support Team^] and they can take a look at it. Thanks, ceTe Software Support Team

Re: Flattening Checkboxes

Forum member · Apr 4, 2007
I am getting the same error even when there is only one checkbox field in the document with that name. I've been corresponding with support, but we're not making progress. :-) Greg

Re: Flattening Checkboxes

Support · Apr 4, 2007
Hello Greg, Can you please send the PDF document to our [^a|mailto:support@cete.com|Support Team^] and they can take a look at it? Thanks, ceTe Software Support Team