We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Facades Creates a Hidden Radio Button

I am running into similar problem as:
https://forum.aspose.com/t/114456

I tried running a slightly modified version of:
http://www.aspose.com/docs/display/pdfnet/Add+Form+Field+in+an+Existing+PDF+file+(Facades)
to generate the pdf. I opened up the pdf using the Adobe acrobat and went to edit the fields in the pdf.
Trying to do so made the acrobat crash, and when it didn't crash, it didn't show the field list that I normally see. It also generated an extra field.

How do I go about not generating this extra field?

I have also included a sample C# file I wrote using Window Forms Application.
I am using .net 3.5 and Aspose.Pdf 9.2.1.0

Hi Sung,


Thanks for your inquiry. Please use new DOM approach to create radio buttons, it is more efficient and reliable. I am unable to notice any extra field and acrobat crash at the time of edit. Please check following code snippet for the purpose, hopefully it will help you to accomplish the task.

string outFile =
myDir + “Form_out.pdf”;<o:p></o:p>

Document doc = new Document();

Page page = doc.Pages.Add();

//Instantiate a table object

Aspose.Pdf.Table tab1 = new Aspose.Pdf.Table();

//Add the table in paragraphs collection of the desired section

page.Paragraphs.Add(tab1);

//Set with column widths of the table

tab1.ColumnWidths = "100 100";

//Create rows in the table and then cells in the rows

RadioButtonField rf = new RadioButtonField(page);

rf.PartialName = "radio";

doc.Form.Add(rf, 1);

RadioButtonOptionField opt1 = new RadioButtonOptionField();

RadioButtonOptionField opt2 = new RadioButtonOptionField();

opt1.OptionName = "Item1";

opt2.OptionName = "Item2";

opt1.Width = 12;

opt1.Height = 12;

opt2.Width = 12;

opt2.Height = 12;

rf.Add(opt1);

rf.Add(opt2);

opt1.Caption = new TextFragment("Item10");

opt1.Border = new Border(opt1);

opt1.Border.Width = 1;

opt1.Border.Style = Aspose.Pdf.InteractiveFeatures.Annotations.BorderStyle.Solid;

opt1.Characteristics.Border = System.Drawing.Color.Yellow;

opt1.DefaultAppearance.TextColor = System.Drawing.Color.Red;

opt2.Caption = new TextFragment("Item11");

opt2.Border = new Border(opt1);

opt2.Border.Width = 1;

opt2.Border.Style = Aspose.Pdf.InteractiveFeatures.Annotations.BorderStyle.Solid;

opt2.Characteristics.Border = System.Drawing.Color.Yellow;

opt2.DefaultAppearance.TextColor = System.Drawing.Color.Red;

Aspose.Pdf.Row row = tab1.Rows.Add();

Aspose.Pdf.Cell c1 = row.Cells.Add();

c1.Paragraphs.Add(opt1);

Aspose.Pdf.Cell c2 = row.Cells.Add();

c2.Paragraphs.Add(opt2);

doc.Save(outFile);

Please feel free to contact us for any further assistance.


Best Regards,

Thanks Tilal, I forgot to mention that the extra field is invisible, unless you click on it. I will attach a screenshot of the field.


To reproduce the crashing in the Acrobat, you need to go to Tools => Forms tab => Edit then when the form is in edit mode, try dragging around the generated radio buttons. That will most likely crash the Acrobat. It only happens when there are generated radio buttons present. I have also noticed this problem with the pdf generated by your code.

Hi Sung,


Please use new DOM approach for adding radio buttons, it does not add an additional button.

Moreover, we have notice the Adobe Acrobat crash issue and log it as PDFNEWNET-37128 in our issue tracking system for further investigation and resolution. We will notify you as soon as it is resolved.

We are sorry for the inconvenience caused.

Best Regards,

Can you explain to the me the differences between each of the name properties in the RadioButtonField class (AlternativeName, FullName, MappingName, Name, PartialName, OptionName)? The documentation isn’t very clear on this. I tried following your example but it doesn’t generate the exact name that I assigned to the field. It generates “radio1” instead of the exact value “radio” that was assigned via the PartialName property.


Also, is there a generator’s IsHtmlTagSupported equivalent in the DOM approach?

Thanks!
Hi Sung,

Thanks for your feedback.

SJeong:
Also, is there a generator's IsHtmlTagSupported equivalent in the DOM approach?

I am afraid currently Aspose.Pdf for .NET does not support the feature to read HTML string and place the contents inside PDF document as IsHtmlTagSupported feature in old generator. For the sake of implementation, we already have logged this requirement as PDFNEWNET-35804 in our issue tracking system. The development team is looking into the details of this requirement and will keep you posted on the status of correction.

We are sorry for this inconvenience.

Best Regards,

How do I get the name of the RadioButtonField to be exactly what I assigned?

I tried running the code below on the code that you provided after using different name properties of the RadioButtonField, and none of them kept the exact name that I assigned them.

Aspose.Pdf.Facades.Form pdfForm = new Aspose.Pdf.Facades.Form(“RadioButtons2.pdf”);
foreach (String names in pdfForm.FieldNames) {
System.Diagnostics.Debug.WriteLine(names);
System.Diagnostics.Debug.WriteLine(pdfForm.GetField(names));
}

Desired Name: radio
Results:
Name : field_11
MappingName : field_11
AlternateName: field_11
PartialName: radio1

Hi Sung,


We are sorry for the delayed response. We are looking into it and will update you soon.

Best Regards,

Any updates on this issue?

Hi Sung,


Thanks for your patience.

My fellow worker is working on replicating the above stated problem and will get back to you soon. We are sorry for this delay and inconvenience.

Hi Sung,


SJeong:
How do I get the name of the RadioButtonField to be exactly what I assigned?
I tried running the code below on the code that you provided after using different name properties of the RadioButtonField, and none of them kept the exact name that I assigned them.


Thanks for your patience. I have tested the scenario using code shared above but unable to replicate the issue. I find the PartialName same as I assigned in code. We will appreciate if you please share your sample source code and output PDF document. So we will look into it and provide you information accordingly.

Moreover, please find details about the RadioButton name related properties.

PartialName:
PartialName is a name of the field.

FullName:
FullName is read-only property which returns name with parent fields for example if field1 is belongs to group of the fields group1 then partial name of the field is “field1” and of the group is “group1” and full name of the field is “group1.field1” i.e. it is fully qualified name , unique name of the field.

OptionName:
OptionName is name of the option in RadioButton. It is applicable only for options fields

Name:
Name is used for annotations. The annotation name, a text string uniquely identifying it among all the annotations on its page.
it is not for fields

AlternativeName:
An alternate field name that shall be used in place of the actual field name wherever the field shall be identified in the user interface (such as in error or status messages referring to the field). This text is also useful when extracting the document’s contents in support of accessibility to users with disabilities or for other purposes

MappingName:
MappingName is name of the field used in form export/import. The mapping name that shall be used when exporting interactive form field data from the document.

Please feel free to contact us for any further assistance.

Best Regards,

Thank you for the detailed reply. Looks like what I want to use is PartialName property to assign names to my RadioButtonField. But, I can’t seem to figure out why it is appending numbers at the end of my PartialName. Is there an option to turn that off? (eg: my RadioButtonField should be called “first”, instead it is being named “first1”)


I have included a sample C# file I wrote using Window Forms Application, generated PDF, and a screen shot of the field property in Acrobat.
I am using .net 3.5 and Aspose.Pdf 9.3.0.0

Hi Sung,


Thanks for sharing your source code. Please note you are adding same radio button in PDF page twice, so it is adding 1 in last button. Please remove highlighted code from addRadioField() method it will fix the issue.


public static void
addRadioField(Page page, Document doc, RadioButtonField
rf)<o:p></o:p>

{

// create table and append it to the page

Aspose.Pdf.Table tab1 = new Aspose.Pdf.Table();

page.Paragraphs.Add(tab1);

//add the RadioButtonField to the form

doc.Form.Add(rf, 1);

RadioButtonOptionField opt1 = new RadioButtonOptionField();

RadioButtonOptionField opt2 = new RadioButtonOptionField();

opt1.OptionName = "Item1";

opt2.OptionName = "Item2";

opt1.Value = "Item1";

opt2.Value = "Item2";

opt1.Width = 12;

opt1.Height = 12;

opt2.Width = 12;

opt2.Height = 12;

// add options to the RadioButtonField

rf.Add(opt1);

rf.Add(opt2);

// set text on options

opt1.Caption = new TextFragment("Item 1");

opt2.Caption = new TextFragment("Item 2");

// create new row, cell, and add the options to each cell

Aspose.Pdf.Row row = tab1.Rows.Add();

Aspose.Pdf.Cell c1 = row.Cells.Add();

c1.Paragraphs.Add(opt1);

Aspose.Pdf.Cell c2 = row.Cells.Add();

c2.Paragraphs.Add(opt2);

//page.Paragraphs.Add(rf);

}

Please feel free to contact us for any further assistance.


Best Regards,

Awesome! I was able to verify that was the issue. It’s working on my end as well. Thanks for the help.

Hi Sung,


Thanks for your feedback. It is good to know that you have managed to resolve the issue.

Please keep using our APIs and feel free to ask any question or concern. We will be more than happy to extend our support.

Best Regards,

The issues you have found earlier (filed as PDFNEWNET-35804;PDFNEWNET-37128) have been fixed in Aspose.Pdf for .NET 9.5.0.


This message was posted using Notification2Forum from Downloads module by Aspose Notifier.

Hi Sung,


Thanks for your patience. As stated above PDFNEWNET-35804 is also resolved and now you can add HTML string in new/existing document using new DOM approach. Please check following documentation link for the purpose. It will help you to accomplish your requirements.


Please feel free to contact us for any further assistance.

Best Regards,