Criar AcroForm - Criar PDF Preenchível em C# 
O seguinte trecho de código também funciona com a biblioteca Aspose.PDF.Drawing .
A classe Document  fornece uma coleção chamada Form  que ajuda você a gerenciar campos de formulário em um documento PDF.
Para adicionar um campo de formulário:
Crie o campo de formulário que você deseja adicionar. 
Chame o método Add da coleção Form . 
 
Adicionando TextBoxField 
O exemplo abaixo mostra como adicionar um TextBoxField .
  
       
      .NET Core 3.1 
      // For complete examples and data files, visit https://github.com/aspose-pdf/Aspose.PDF-for-.NET 
private  static  void  AddTextBoxFieldToPdf () 
{ 
    // The path to the documents directory 
     var  dataDir  =  RunExamples . GetDataDir_AsposePdf_Forms (); 
 
     // Open PDF document 
     using  ( var  document  =  new  Aspose . Pdf . Document ( dataDir  +  "TextField.pdf" )) 
     { 
         // Create a field 
         var  textBoxField  =  new  Aspose . Pdf . Forms . TextBoxField ( document . Pages [ 1 ],  new  Aspose . Pdf . Rectangle ( 100 ,  200 ,  300 ,  300 )); 
         textBoxField . PartialName  =  "textbox1" ; 
         textBoxField . Value  =  "Text Box" ; 
 
         // Configure border 
         var  border  =  new  Aspose . Pdf . Annotations . Border ( textBoxField ); 
         border . Width  =  5 ; 
         border . Dash  =  new  Aspose . Pdf . Annotations . Dash ( 1 ,  1 ); 
         textBoxField . Border  =  border ; 
 
         // Set color 
         textBoxField . Color  =  Aspose . Pdf . Color . FromRgb ( System . Drawing . Color . Green ); 
 
         // Add field to the document 
         document . Form . Add ( textBoxField ,  1 ); 
 
         // Save PDF document 
         document . Save ( dataDir  +  "TextBox_out.pdf" ); 
     } 
 } 
 
       
      .NET 8 
      // For complete examples and data files, visit https://github.com/aspose-pdf/Aspose.PDF-for-.NET 
private  static  void  AddTextBoxFieldToPdf () 
{ 
    // The path to the documents directory 
     var  dataDir  =  RunExamples . GetDataDir_AsposePdf_Forms (); 
 
     // Open PDF document 
     using  var  document  =  new  Aspose . Pdf . Document ( dataDir  +  "TextField.pdf" ); 
 
     // Create a field 
     var  textBoxField  =  new  Aspose . Pdf . Forms . TextBoxField ( document . Pages [ 1 ],  new  Aspose . Pdf . Rectangle ( 100 ,  200 ,  300 ,  300 )); 
     textBoxField . PartialName  =  "textbox1" ; 
     textBoxField . Value  =  "Text Box" ; 
 
     // Configure border 
     var  border  =  new  Aspose . Pdf . Annotations . Border ( textBoxField ); 
     border . Width  =  5 ; 
     border . Dash  =  new  Aspose . Pdf . Annotations . Dash ( 1 ,  1 ); 
     textBoxField . Border  =  border ; 
 
     // Set color 
     textBoxField . Color  =  Aspose . Pdf . Color . FromRgb ( System . Drawing . Color . Green ); 
 
     // Add field to the document 
     document . Form . Add ( textBoxField ,  1 ); 
 
     // Save PDF document 
     document . Save ( dataDir  +  "TextBox_out.pdf" ); 
 } 
 
 
Os seguintes trechos de código mostram como adicionar RadioButtonField  em um documento PDF.
  
       
      .NET Core 3.1 
      // For complete examples and data files, visit https://github.com/aspose-pdf/Aspose.PDF-for-.NET 
private  static  void  AddRadioButtonToPdf () 
{ 
    // The path to the documents directory 
     var  dataDir  =  RunExamples . GetDataDir_AsposePdf_Forms (); 
 
     // Create PDF document 
     using  ( var  document  =  new  Aspose . Pdf . Document ()) 
     { 
         // Add page to PDF file 
         document . Pages . Add (); 
 
         // Instantiate RadioButtonField object with page number as argument 
         var  radio  =  new  Aspose . Pdf . Forms . RadioButtonField ( document . Pages [ 1 ]); 
 
         // Add first radio button option and also specify its origin using Rectangle object 
         radio . AddOption ( "Test" ,  new  Aspose . Pdf . Rectangle ( 0 ,  0 ,  20 ,  20 )); 
 
         // Add second radio button option 
         radio . AddOption ( "Test1" ,  new  Aspose . Pdf . Rectangle ( 20 ,  20 ,  40 ,  40 )); 
 
         // Add radio button to form object of Document object 
         document . Form . Add ( radio ); 
 
         // Save PDF document 
         document . Save ( dataDir  +  "RadioButton_out.pdf" ); 
     } 
 } 
 
       
      .NET 8 
      // For complete examples and data files, visit https://github.com/aspose-pdf/Aspose.PDF-for-.NET 
private  static  void  AddRadioButtonToPdf () 
{ 
    // The path to the documents directory 
     var  dataDir  =  RunExamples . GetDataDir_AsposePdf_Forms (); 
 
     // Create PDF document 
     using  var  document  =  new  Aspose . Pdf . Document (); 
 
     // Add page to PDF file 
     document . Pages . Add (); 
 
     // Instantiate RadioButtonField object with page number as argument 
     var  radio  =  new  Aspose . Pdf . Forms . RadioButtonField ( document . Pages [ 1 ]); 
 
     // Add first radio button option and also specify its origin using Rectangle object 
     radio . AddOption ( "Test" ,  new  Aspose . Pdf . Rectangle ( 0 ,  0 ,  20 ,  20 )); 
 
     // Add second radio button option 
     radio . AddOption ( "Test1" ,  new  Aspose . Pdf . Rectangle ( 20 ,  20 ,  40 ,  40 )); 
 
     // Add radio button to form object of Document object 
     document . Form . Add ( radio ); 
 
     // Save PDF document 
     document . Save ( dataDir  +  "RadioButton_out.pdf" ); 
 } 
 
 
TextBoxField  pode ser adicionado com algumas anotações de widget.
  
       
      .NET Core 3.1 
      // For complete examples and data files, please visit https://github.com/aspose-pdf/Aspose.PDF-for-.NET 
private  static  void  AddTextBoxFieldToPdf () 
{ 
    // The path to the documents directory 
     string  dataDir  =  RunExamples . GetDataDir_AsposePdf_Forms (); 
 
     // Create PDF document 
     using  ( var  document  =  new  Aspose . Pdf . Document ()) 
     { 
         // Add page to PDF file 
         var  page  =  document . Pages . Add (); 
 
         // Defining an array with rectangle data for widget annotations.  
         // The number of elements in the array determines the number of widget annotations to add. 
         var  rects  =  new  Aspose . Pdf . Rectangle [] 
         { 
             new  Aspose . Pdf . Rectangle ( 10 ,  600 ,  110 ,  620 ), 
             new  Aspose . Pdf . Rectangle ( 10 ,  630 ,  110 ,  650 ), 
             new  Aspose . Pdf . Rectangle ( 10 ,  660 ,  110 ,  680 ) 
         }; 
 
         // Defining an array with DefaultAppearance used to specify how widget annotations are displayed in the added field. 
         var  defaultAppearances  =  new  Aspose . Pdf . Annotations . DefaultAppearance [] 
         { 
             new  Aspose . Pdf . Annotations . DefaultAppearance ( "Arial" ,  10 ,  System . Drawing . Color . DarkBlue ), 
             new  Aspose . Pdf . Annotations . DefaultAppearance ( "Helvetica" ,  12 ,  System . Drawing . Color . DarkGreen ), 
             new  Aspose . Pdf . Annotations . DefaultAppearance ( Aspose . Pdf . Text . FontRepository . FindFont ( "TimesNewRoman" ),  14 ,  System . Drawing . Color . DarkMagenta ) 
         }; 
 
         // Create a field 
         var  textBoxField  =  new  Aspose . Pdf . Forms . TextBoxField ( page ,  rects ); 
 
         // Setting the appearances of widget annotations 
         short  i  =  0 ; 
         foreach  ( Aspose . Pdf . Annotations . WidgetAnnotation  wa  in  textBoxField ) 
         { 
             wa . DefaultAppearance  =  defaultAppearances [ i ++]; 
         } 
         textBoxField . Value  =  "Text" ; 
 
         // Add field to the document 
         document . Form . Add ( textBoxField ); 
 
         // Save PDF document 
         document . Save ( dataDir  +  "TextBox_out.pdf" ); 
     } 
 } 
 
       
      .NET 8 
      // For complete examples and data files, please visit https://github.com/aspose-pdf/Aspose.PDF-for-.NET 
private  static  void  AddTextBoxFieldToPdf () 
{ 
    // The path to the documents directory 
     string  dataDir  =  RunExamples . GetDataDir_AsposePdf_Forms (); 
 
     // Create PDF document 
     using  var  document  =  new  Aspose . Pdf . Document (); 
 
     // Add page to PDF file 
     var  page  =  document . Pages . Add (); 
 
     // Defining an array with rectangle data for widget annotations.  
     // The number of elements in the array determines the number of widget annotations to add. 
     var  rects  =  new  Aspose . Pdf . Rectangle [] 
     { 
         new  Aspose . Pdf . Rectangle ( 10 ,  600 ,  110 ,  620 ), 
         new  Aspose . Pdf . Rectangle ( 10 ,  630 ,  110 ,  650 ), 
         new  Aspose . Pdf . Rectangle ( 10 ,  660 ,  110 ,  680 ) 
     }; 
 
     // Defining an array with DefaultAppearance used to specify how widget annotations are displayed in the added field. 
     var  defaultAppearances  =  new  Aspose . Pdf . Annotations . DefaultAppearance [] 
     { 
         new  Aspose . Pdf . Annotations . DefaultAppearance ( "Arial" ,  10 ,  System . Drawing . Color . DarkBlue ), 
         new  Aspose . Pdf . Annotations . DefaultAppearance ( "Helvetica" ,  12 ,  System . Drawing . Color . DarkGreen ), 
         new  Aspose . Pdf . Annotations . DefaultAppearance ( Aspose . Pdf . Text . FontRepository . FindFont ( "TimesNewRoman" ),  14 ,  System . Drawing . Color . DarkMagenta ) 
     }; 
 
     // Create a field 
     var  textBoxField  =  new  Aspose . Pdf . Forms . TextBoxField ( page ,  rects ); 
 
     // Setting the appearances of widget annotations 
     short  i  =  0 ; 
     foreach  ( Aspose . Pdf . Annotations . WidgetAnnotation  wa  in  textBoxField ) 
     { 
         wa . DefaultAppearance  =  defaultAppearances [ i ++]; 
     } 
     textBoxField . Value  =  "Text" ; 
 
     // Add field to the document 
     document . Form . Add ( textBoxField ); 
 
     // Save PDF document 
     document . Save ( dataDir  +  "TextBox_out.pdf" ); 
 } 
 
 
O seguinte trecho de código mostra os passos para adicionar RadioButtonField com três opções e colocá-los dentro de células de tabela.
  
 
O seguinte trecho de código mostra como adicionar uma legenda que será associada ao RadioButtonField:
  
 
Outra variante para adicionar Checkboxes agrupados 
Os seguintes trechos de código mostram como adicionar campos de checkbox agrupados em um documento PDF.
  
       
      .NET Core 3.1 
      // For complete examples and data files, visit https://github.com/aspose-pdf/Aspose.PDF-for-.NET 
private  static  void  AddGroupedCheckBoxFieldsToPdf () 
{ 
    // The path to the documents directory 
     var  dataDir  =  RunExamples . GetDataDir_AsposePdf_Forms (); 
 
     // Create PDF document 
     using  ( var  document  =  new  Aspose . Pdf . Document ()) 
     { 
         // Add page to PDF file 
         var  page  =  document . Pages . Add (); 
 
         var  radioButtonField  =  new  Aspose . Pdf . Forms . RadioButtonField ( page ); 
 
         // Add radio button options and specify its position using Rectangle 
         var  opt1  =  new  Aspose . Pdf . Forms . RadioButtonOptionField ( page ,  new  Aspose . Pdf . Rectangle ( 50 ,  500 ,  70 ,  520 )); 
         var  opt2  =  new  Aspose . Pdf . Forms . RadioButtonOptionField ( page ,  new  Aspose . Pdf . Rectangle ( 100 ,  500 ,  120 ,  520 )); 
 
         // Set option names for identification 
         opt1 . OptionName  =  "Option1" ; 
         opt2 . OptionName  =  "Option2" ; 
 
         // Set the style of the radio buttons 
         opt1 . Style  =  Aspose . Pdf . Forms . BoxStyle . Square ; 
         opt2 . Style  =  Aspose . Pdf . Forms . BoxStyle . Cross ; 
 
         // Configure the border of the first radio button 
         opt1 . Border  =  new  Aspose . Pdf . Annotations . Border ( opt1 ); 
         opt1 . Border . Style  =  Aspose . Pdf . Annotations . BorderStyle . Dashed ; 
         opt1 . Border . Width  =  1 ; 
         opt1 . Characteristics . Border  =  System . Drawing . Color . Blue ; 
 
         // Configure the border of the second radio button 
         opt2 . Border  =  new  Aspose . Pdf . Annotations . Border ( opt2 ); 
         opt2 . Border . Style  =  Aspose . Pdf . Annotations . BorderStyle . Solid ; 
         opt2 . Border . Width  =  1 ; 
         opt2 . Characteristics . Border  =  System . Drawing . Color . Black ; 
 
         radioButtonField . Add ( opt1 ); 
         radioButtonField . Add ( opt2 ); 
 
         // Add radio button field to the form object of the document 
         document . Form . Add ( radioButtonField ); 
 
         // Save PDF document 
         document . Save ( dataDir  +  "GroupedCheckboxFields_out.pdf" ); 
     } 
 } 
 
       
      .NET 8 
      // For complete examples and data files, visit https://github.com/aspose-pdf/Aspose.PDF-for-.NET 
private  static  void  AddGroupedCheckBoxFieldsToPdf () 
{ 
    // The path to the documents directory 
     var  dataDir  =  RunExamples . GetDataDir_AsposePdf_Forms (); 
 
     // Create PDF document 
     using  var  document  =  new  Aspose . Pdf . Document (); 
 
     // Add page to PDF file 
     var  page  =  document . Pages . Add (); 
 
     var  radioButtonField  =  new  Aspose . Pdf . Forms . RadioButtonField ( page ); 
 
     // Add radio button options and specify its position using Rectangle 
     var  opt1  =  new  Aspose . Pdf . Forms . RadioButtonOptionField ( page ,  new  Aspose . Pdf . Rectangle ( 50 ,  500 ,  70 ,  520 )); 
     var  opt2  =  new  Aspose . Pdf . Forms . RadioButtonOptionField ( page ,  new  Aspose . Pdf . Rectangle ( 100 ,  500 ,  120 ,  520 )); 
 
     // Set option names for identification 
     opt1 . OptionName  =  "Option1" ; 
     opt2 . OptionName  =  "Option2" ; 
 
     // Set the style of the radio buttons 
     opt1 . Style  =  Aspose . Pdf . Forms . BoxStyle . Square ; 
     opt2 . Style  =  Aspose . Pdf . Forms . BoxStyle . Cross ; 
 
     // Configure the border of the first radio button 
     opt1 . Border  =  new  Aspose . Pdf . Annotations . Border ( opt1 ); 
     opt1 . Border . Style  =  Aspose . Pdf . Annotations . BorderStyle . Dashed ; 
     opt1 . Border . Width  =  1 ; 
     opt1 . Characteristics . Border  =  System . Drawing . Color . Blue ; 
 
     // Configure the border of the second radio button 
     opt2 . Border  =  new  Aspose . Pdf . Annotations . Border ( opt2 ); 
     opt2 . Border . Style  =  Aspose . Pdf . Annotations . BorderStyle . Solid ; 
     opt2 . Border . Width  =  1 ; 
     opt2 . Characteristics . Border  =  System . Drawing . Color . Black ; 
 
     radioButtonField . Add ( opt1 ); 
     radioButtonField . Add ( opt2 ); 
 
     // Add radio button field to the form object of the document 
     document . Form . Add ( radioButtonField ); 
 
     // Save PDF document 
     document . Save ( dataDir  +  "GroupedCheckboxFields_out.pdf" ); 
 } 
 
 
Adicionando campo ComboBox 
Os seguintes trechos de código mostram como adicionar um campo ComboBox em um documento PDF.
  
       
      .NET Core 3.1 
      // For complete examples and data files, visit https://github.com/aspose-pdf/Aspose.PDF-for-.NET 
private  static  void  AddComboBoxToPdf () 
{ 
    // The path to the documents directory 
     var  dataDir  =  RunExamples . GetDataDir_AsposePdf_Forms (); 
 
     // Create PDF document 
     using  ( var  document  =  new  Aspose . Pdf . Document ()) 
     { 
         // Add page to PDF file 
         document . Pages . Add (); 
 
         // Instantiate ComboBox Field object 
         var  combo  =  new  Aspose . Pdf . Forms . ComboBoxField ( document . Pages [ 1 ],  new  Aspose . Pdf . Rectangle ( 100 ,  600 ,  150 ,  616 )); 
 
         // Add options to ComboBox 
         combo . AddOption ( "Red" ); 
         combo . AddOption ( "Yellow" ); 
         combo . AddOption ( "Green" ); 
         combo . AddOption ( "Blue" ); 
 
         // Add combo box object to form fields collection of document object 
         document . Form . Add ( combo ); 
 
         // Save PDF document 
         document . Save ( dataDir  +  "ComboBox_out.pdf" ); 
     } 
 } 
 
       
      .NET 8 
      // For complete examples and data files, visit https://github.com/aspose-pdf/Aspose.PDF-for-.NET 
private  static  void  AddComboBoxToPdf () 
{ 
    // The path to the documents directory 
     var  dataDir  =  RunExamples . GetDataDir_AsposePdf_Forms (); 
 
     // Create PDF document 
     using  var  document  =  new  Aspose . Pdf . Document (); 
 
     // Add page to PDF file 
     document . Pages . Add (); 
 
     // Instantiate ComboBox Field object 
     var  combo  =  new  Aspose . Pdf . Forms . ComboBoxField ( document . Pages [ 1 ],  new  Aspose . Pdf . Rectangle ( 100 ,  600 ,  150 ,  616 )); 
 
     // Add options to ComboBox 
     combo . AddOption ( "Red" ); 
     combo . AddOption ( "Yellow" ); 
     combo . AddOption ( "Green" ); 
     combo . AddOption ( "Blue" ); 
 
     // Add combo box object to form fields collection of document object 
     document . Form . Add ( combo ); 
 
     // Save PDF document 
     document . Save ( dataDir  +  "ComboBox_out.pdf" ); 
 } 
 
 
Adicionando CheckboxField 
O seguinte trecho de código mostra como adicionar CheckboxField em um documento PDF.
  
       
      .NET Core 3.1 
      // For complete examples and data files, visit https://github.com/aspose-pdf/Aspose.PDF-for-.NET 
private  static  void  AddCheckBoxFieldToPdf () 
{ 
    // The path to the documents directory 
     var  dataDir  =  RunExamples . GetDataDir_AsposePdf_Forms (); 
 
     // Create PDF document 
     using  ( var  document  =  new  Aspose . Pdf . Document ()) 
     { 
         // Add page to PDF file 
         var  page  =  document . Pages . Add (); 
 
         // Create a field 
         var  checkboxField  =  new  Aspose . Pdf . Forms . CheckboxField ( page ,  new  Aspose . Pdf . Rectangle ( 50 ,  620 ,  100 ,  650 )); 
         checkboxField . Characteristics . Background  =  System . Drawing . Color . Aqua ; 
         checkboxField . Style  =  Aspose . Pdf . Forms . BoxStyle . Circle ; 
 
         // Add field to the form 
         document . Form . Add ( checkboxField ); 
 
         // Save PDF document 
         document . Save ( dataDir  +  "CheckboxField_out.pdf" ); 
     } 
 } 
 
       
      .NET 8 
      // For complete examples and data files, visit https://github.com/aspose-pdf/Aspose.PDF-for-.NET 
private  static  void  AddCheckBoxFieldToPdf () 
{ 
    // The path to the documents directory 
     var  dataDir  =  RunExamples . GetDataDir_AsposePdf_Forms (); 
 
     // Create PDF document 
     using  var  document  =  new  Aspose . Pdf . Document (); 
 
     // Add page to PDF file 
     var  page  =  document . Pages . Add (); 
 
     // Create a field 
     var  checkboxField  =  new  Aspose . Pdf . Forms . CheckboxField ( page ,  new  Aspose . Pdf . Rectangle ( 50 ,  620 ,  100 ,  650 )); 
     checkboxField . Characteristics . Background  =  System . Drawing . Color . Aqua ; 
     checkboxField . Style  =  Aspose . Pdf . Forms . BoxStyle . Circle ; 
 
     // Add field to the form 
     document . Form . Add ( checkboxField ); 
 
     // Save PDF document 
     document . Save ( dataDir  +  "CheckboxField_out.pdf" ); 
 } 
 
 
Adicionando ListBoxField 
O seguinte trecho de código mostra como adicionar ListBoxField em um documento PDF.
  
       
      .NET Core 3.1 
      // For complete examples and data files, visit https://github.com/aspose-pdf/Aspose.PDF-for-.NET 
private  static  void  AddListBoxFieldToPdf () 
{ 
    // The path to the documents directory 
     var  dataDir  =  RunExamples . GetDataDir_AsposePdf_Forms (); 
 
     // Create PDF document 
     using  ( var  document  =  new  Aspose . Pdf . Document ()) 
     { 
         // Add page to PDF file 
         var  page  =  document . Pages . Add (); 
 
         // Create a field 
         var  listBoxField  =  new  Aspose . Pdf . Forms . ListBoxField ( page ,  new  Aspose . Pdf . Rectangle ( 50 ,  650 ,  100 ,  700 )); 
         listBoxField . PartialName  =  "list" ; 
         listBoxField . AddOption ( "Red" ); 
         listBoxField . AddOption ( "Green" ); 
         listBoxField . AddOption ( "Blue" ); 
         // Add field to the form 
         document . Form . Add ( listBoxField ); 
 
         // Save PDF document 
         document . Save ( dataDir  +  "ListBoxField_out.pdf" ); 
     } 
 } 
 
       
      .NET 8 
      // For complete examples and data files, visit https://github.com/aspose-pdf/Aspose.PDF-for-.NET 
private  static  void  AddListBoxFieldToPdf () 
{ 
    // The path to the documents directory 
     var  dataDir  =  RunExamples . GetDataDir_AsposePdf_Forms (); 
 
     // Create PDF document 
     using  var  document  =  new  Aspose . Pdf . Document (); 
 
     // Add page to PDF file 
     var  page  =  document . Pages . Add (); 
 
     // Create a field 
     var  listBoxField  =  new  Aspose . Pdf . Forms . ListBoxField ( page ,  new  Aspose . Pdf . Rectangle ( 50 ,  650 ,  100 ,  700 )); 
     listBoxField . PartialName  =  "list" ; 
     listBoxField . AddOption ( "Red" ); 
     listBoxField . AddOption ( "Green" ); 
     listBoxField . AddOption ( "Blue" ); 
     // Add field to the form 
     document . Form . Add ( listBoxField ); 
 
     // Save PDF document 
     document . Save ( dataDir  +  "ListBoxField_out.pdf" ); 
 } 
 
 
Usando SignatureField 
O seguinte trecho de código mostra como assinar um documento PDF usando SignatureField.
  
       
      .NET Core 3.1 
      private  static  void  SignPdfBySignatureField () 
{ 
    // The path to the documents directory 
     var  dataDir  =  RunExamples . GetDataDir_AsposePdf_Forms (); 
 
     // Create PDF document 
     using  ( var  document  =  new  Aspose . Pdf . Document ( dataDir  +  "TextField.pdf" )) 
     { 
         // Add page to PDF file	 
         var  page  =  document . Pages . Add (); 
 
         // Create a field 
         var  signatureField  =  new  Aspose . Pdf . Forms . SignatureField ( page ,  new  Aspose . Pdf . Rectangle ( 100 ,  700 ,  200 ,  800 )); 
         document . Form . Add ( signatureField ); 
 
         var  pkcs  =  new  Aspose . Pdf . Forms . PKCS7 ( "test1.pfx" ,  "test1" ); 
         pkcs . Date  =  new  DateTime (); 
         pkcs . ContactInfo  =  "Test" ; 
         pkcs . Location  =  "TestLocation" ; 
         pkcs . Reason  =  "Verify" ; 
         pkcs . ShowProperties  =  false ; 
         signatureField . Sign ( pkcs ); 
 
         // Save PDF document 
         document . Save ( dataDir  +  "SignatureField_out.pdf" ); 
     } 
 } 
 
       
      .NET 8 
      private  static  void  SignPdfBySignatureField () 
{ 
    // The path to the documents directory 
     var  dataDir  =  RunExamples . GetDataDir_AsposePdf_Forms (); 
 
     // Create PDF document 
     using  var  document  =  new  Aspose . Pdf . Document ( dataDir  +  "TextField.pdf" ); 
 
     // Add page to PDF file 
     var  page  =  document . Pages . Add (); 
 
     // Create a field 
     var  signatureField  =  new  Aspose . Pdf . Forms . SignatureField ( page ,  new  Aspose . Pdf . Rectangle ( 100 ,  700 ,  200 ,  800 )); 
     document . Form . Add ( signatureField ); 
 
     var  pkcs  =  new  Aspose . Pdf . Forms . PKCS7 ( "test1.pfx" ,  "test1" ); 
     pkcs . Date  =  new  DateTime (); 
     pkcs . ContactInfo  =  "Test" ; 
     pkcs . Location  =  "TestLocation" ; 
     pkcs . Reason  =  "Verify" ; 
     pkcs . ShowProperties  =  false ; 
     signatureField . Sign ( pkcs ); 
 
     // Save PDF document 
     document . Save ( dataDir  +  "SignatureField_out.pdf" ); 
 } 
 
 
A classe Document fornece uma coleção chamada Form que gerencia campos de formulário em um documento PDF. Para adicionar um tooltip a um campo de formulário, use a classe Field AlternateName. O Adobe Acrobat usa o ’nome alternativo’ como um tooltip de campo.
Os trechos de código que seguem mostram como adicionar um tooltip a um campo de formulário, primeiro usando C# e depois Visual Basic.