Hi Sung,
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.
Hi Sung,
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.
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?
Hi Sung,
Any updates on this issue?
Hi Sung,
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.
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”)
Hi Sung,
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,
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,