//Create a new PDF document var document = new PdfDocument(); //Add a new page to the document var page = document.AddPage(); //Create a new text field and set its properties var field = new PdfTextField("myTextField"); field.Bounds = new PdfRectangle(50, 700, 200, 750); field.Text = "Enter your name"; //Add the text field to the PDF document var form = document.AcroForm; form.Fields.Add(field); //Save the PDF document document.Save("myDocument.pdf");
//Create a new PDF document var document = new PdfDocument(); //Add a new page to the document var page = document.AddPage(); //Create a new checkbox field and set its properties var field = new PdfCheckBoxField("myCheckbox"); field.Bounds = new PdfRectangle(50, 700, 200, 750); field.Checked = true; field.ExportValue = "Yes"; //Add the checkbox field to the PDF document var form = document.AcroForm; form.Fields.Add(field); //Save the PDF document document.Save("myDocument.pdf");The PdfAcroForm AddField method is part of the PDFsharp package library, which is an open-source library for creating and modifying PDF files using C#.