This sample shows how to access an existing PDF control with given name using PdfDocument.GetControl method.
You can access document controls using their PDF names in any PDF document with a form.
using System.Diagnostics; namespace BitMiracle.Docotic.Pdf.Samples { public static class FindControlByName { public static void Main() { // NOTE: // When used in trial mode, the library imposes some restrictions. // Please visit http://bitmiracle.com/pdf-library/trial-restrictions.aspx // for more information. const string pathToFile = "FindControlByName.pdf"; using (PdfDocument pdf = new PdfDocument(@"Sample Data\form.pdf")) { PdfTextBox emailTextBox = pdf.GetControl("email") as PdfTextBox; Debug.Assert(emailTextBox != null); emailTextBox.Text = "support@bitmiracle.com"; pdf.Save(pathToFile); } Process.Start(pathToFile); } } }
Imports System.Diagnostics Imports BitMiracle.Docotic.Pdf Namespace BitMiracle.Docotic.Pdf.Samples Public NotInheritable Class FindControlByName Public Shared Sub Main() ' NOTE: ' When used in trial mode, the library imposes some restrictions. ' Please visit http://bitmiracle.com/pdf-library/trial-restrictions.aspx ' for more information. Const pathToFile As String = "FindControlByName.pdf" Using pdf As New PdfDocument("Sample Data\form.pdf") Dim emailTextBox As PdfTextBox = TryCast(pdf.GetControl("email"), PdfTextBox) Debug.Assert(emailTextBox IsNot Nothing) emailTextBox.Text = "support@bitmiracle.com" pdf.Save(pathToFile) End Using Process.Start(pathToFile) End Sub End Class End Namespace