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

Free Support Forum - aspose.com

Repeating form section

Hi,

Is it possible to use Aspose.PDF to create a PDF with a form that has a repeating section?

I need to create a failure notification form with a few drop downs but there could be one or more failures so I need a button to duplicate the whole failure section as many times as required.

Can you give a code sample if this is possible?

Thanks,

Neil

Hi Neil,


Thanks for contacting support.

As per your requirement, you may consider using Table object and place form controls inside table cells and every time you need to repeat certain set of fields, you may consider creating copy of Table instance.

[C#]

Document doc = new Document();<o:p></o:p>

Page page = doc.Pages.Add();

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

table.ColumnWidths = "120 120 120";

page.Paragraphs.Add(table);

table.Border = new Aspose.Pdf.BorderInfo(Aspose.Pdf.BorderSide.All, Aspose.Pdf.Color.HotPink);

table.DefaultCellBorder = new Aspose.Pdf.BorderInfo(Aspose.Pdf.BorderSide.All, Aspose.Pdf.Color.Indigo);

Aspose.Pdf.Row r1 = table.Rows.Add();

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

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

Aspose.Pdf.Cell c3 = r1.Cells.Add();

RadioButtonField rf = new RadioButtonField(page);

rf.PartialName = "radio";

doc.Form.Add(rf, 1);

RadioButtonOptionField opt1 = new RadioButtonOptionField();

RadioButtonOptionField opt2 = new RadioButtonOptionField();

RadioButtonOptionField opt3 = new RadioButtonOptionField();

opt1.OptionName = "Item1";

opt2.OptionName = "Item2";

opt3.OptionName = "Item3";

opt1.Width = 15;

opt1.Height = 15;

opt2.Width = 15;

opt2.Height = 15;

opt3.Width = 15;

opt3.Height = 15;

rf.Add(opt1);

rf.Add(opt2);

rf.Add(opt3);

opt1.Border = new Border(opt1);

opt1.Border.Width = 1;

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

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

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

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

opt2.Border = new Border(opt1);

opt2.Border.Width = 1;

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

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

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

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

opt3.Border = new Border(opt1);

opt3.Border.Width = 1;

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

opt3.Characteristics.Border = System.Drawing.Color.Black;

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

opt3.Caption = new TextFragment("Item3");

c1.Paragraphs.Add(opt1);

c2.Paragraphs.Add(opt2);

c3.Paragraphs.Add(opt3);

doc.Save(“c:/pdftest/RadioButtonField.pdf”);

Thanks, I'll give it a try