Programmatically Insert Editable Textbox in PDF
Textbox is one type of form fields in PDF, which allows users to enter data into PDF without any editing software. It is commonly used in a document to obtain information of the readers. This article presents how to insert editable textbox in a PDF programmatically using free PDF API in C#. This PDF library provides a class of PdfTextBoxField , initialize a new object of the class and set it properties like Bounds , BounderWidth , then you can add the textbox to PDF document by Form.Fields.Add () method. Using the code //Create a new object of PdfDoument, insert a page PdfDocument doc = new PdfDocument (); PdfPageBase page = doc.Pages.Add ( PdfPageSize .A4, new PdfMargins ()); //Set font, brush PdfFont font = new PdfFont ( PdfFontFamily .TimesRoman, 12f, PdfFontStyle .Bold); PdfBrush brush = PdfBrushes .Black; float x = 50; float y = 50; float tempX = 0; //Draw sting in Pdf string text = "Phone Number: " ; page.Canvas.DrawString(text, font,