←Select platform

FillFormFields Method

Summary

Fills the PDF form document.

Syntax

C#
C++/CLI
Python
public void FillFormFields( 
   IList<PDFFormField> fields, 
   string destinationFileName 
) 
public:  
   void FillFormFields( 
      IList<PDFFormField^>^ fields, 
      String^ destinationFileName 
   ) 
def FillFormFields(self,fields,destinationFileName): 

Parameters

fields

A List of PDFFormField to fill. This must not be null and a list of 1 or more items. An empty list (count is zero) will throw an exception.

destinationFileName

Name of the destination PDF document to be created. If the value of this parameter is null, then the filename set in FileName will be updated.

Remarks

You can use FillFormFields to fill PDF form documents.

LEADTOOLS supports loading all form fields from a PDF file. Due to the nature and complexity of PDF form fields, especially the prevalent use of PDF files that contain many custom and user-defined fields, LEADTOOLS reads the data as is and sets it in PDFFormField without any modification. Refer to the PDF Form Fields Demo for an example of parsing data to generate a live, editable PDF file.

Example

C#
Java
using Leadtools.WinForms; 
using Leadtools; 
using Leadtools.Codecs; 
using Leadtools.Controls; 
using Leadtools.Drawing; 
using Leadtools.ImageProcessing; 
using Leadtools.Pdf; 
using Leadtools.Svg; 
 
 
public void PDFFillFormFieldsExample(string fileName, string name, string value, int type) 
{ 
   PDFFile file = new PDFFile(fileName); 
   IList<PDFFormField> fields = new List<PDFFormField>(); 
   PDFFormField field = new PDFFormField(); 
   field.Name = name; 
   field.Contents = new List<String>(); 
   field.Contents.Add(value); 
   field.ContentType = type; 
 
   fields.Add(field); 
   file.FillFormFields(fields, null); 
} 
 
import java.io.ByteArrayInputStream; 
import java.io.File; 
import java.io.FileInputStream; 
import java.io.FileNotFoundException; 
import java.io.FileOutputStream; 
import java.io.FileReader; 
import java.io.IOException; 
import java.io.InputStream; 
import java.nio.file.Files; 
import java.nio.file.Paths; 
import java.nio.file.StandardCopyOption; 
import java.util.ArrayList; 
import java.util.Date; 
import java.util.List; 
import java.util.Scanner; 
 
import org.junit.*; 
import org.junit.runner.JUnitCore; 
import org.junit.runner.Result; 
import org.junit.runner.notification.Failure; 
import static org.junit.Assert.*; 
 
import leadtools.*; 
import leadtools.codecs.*; 
import leadtools.pdf.*; 
 
 
public void pdfFileFillFormFieldsExample() { 
 
   final String LEAD_VARS_IMAGES_DIR = "C:\\LEADTOOLS23\\Resources\\Images"; 
   String fileName = combine(LEAD_VARS_IMAGES_DIR, "InteractiveForm.pdf"); 
   String name = "leadtools"; 
   String value = "value"; 
   int type = 0; 
   PDFFile file = new PDFFile(fileName); 
   ArrayList<PDFFormField> fields = new ArrayList<PDFFormField>(); 
   PDFFormField field = new PDFFormField(); 
 
   field.setName(name); 
   field.getContents().add(value); 
   field.setContentType(type); 
 
   fields.add(field); 
   file.fillFormFields(fields, null); 
} 

Requirements

Target Platforms

See Also

PDFFile Class

PDFFile Members

Leadtools.Pdf Namespace

Help Version 23.0.2024.2.29
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2024 LEAD Technologies, Inc. All Rights Reserved.

Leadtools.Pdf Assembly
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.