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. PdfDocument pdf = new PdfDocument(@"Sample Data\form.pdf"); PdfTextBox emailTextBox = pdf.GetControl("email") as PdfTextBox; Debug.Assert(emailTextBox != null); emailTextBox.Text = "support@bitmiracle.com"; const string pathToFile = "FindControlByName.pdf"; pdf.Save(pathToFile); pdf.Dispose(); 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. Dim 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" Const pathToFile As String = "FindControlByName.pdf" pdf.Save(pathToFile) pdf.Dispose() Process.Start(pathToFile) End Sub End Class End Namespace
