PDF .NET Library  .NET PDF Component Library. PDF creator, PDF maker.
Home Products Code Library Online Demos Support Buy About Us  
Code Library

How to create tables with Acroform elements

The code sample below creates an AcroForm. The controls and labels are placed in table cells.

c# sample:

PDFDocument doc = new PDFDocument("sample.pdf");

Table table = new Table(2);

table.DisplayHeader = true;

table.column(0).header.SetValue("Control Type");

table.column(1).header.SetValue("Control");

table.column(0).width = 130;

table.addRow(2);

table.cell(0,0).SetValue("PDFEdit");

PDFEdit edit = table.cell(0, 1).SetAcroformElement(PDFControlType.PDFEdit,"txt1", 300, 20) as PDFEdit;

edit.Text = "PDF Technologies";

table.cell(1, 0).SetValue("PDFButton");

PDFButton button = table.cell(1, 1).SetAcroformElement(PDFControlType.PDFButton,"button1", 100, 30) as PDFButton;

button.Caption = "Send";

button.HighlightMode = HighlightMode.Invert;

PDFSubmitFormAction act = doc.CreatePDFSubmitFormAction("mailto:admin@acme.com", PDFSubmitType.XFDF);

button.OnMouseUp = act;

doc.CurrentPage.Body.DrawTable(table);

doc.AutoLaunch = true;

if(!doc.Save())

Console.WriteLine(doc.Error);

Back to PDF Code Library