Forms Extension™
Develop and support static and dynamic XFA forms and AcroForms
forms within your PDFs with this add-on module
for the Adobe PDF Library SDK.
Forms Extension: Starting at $1,999/year when licensed
with Adobe PDF Library
Product Benefits
Improve efficiency with consistent forms support across any PDF software by:
- Flattening dynamic and static XFA and AcroForms
- Converting XFA to AcroForm
Maintain consistency by filling forms with the same data file formats as Adobe Acrobat, using XDP, XML, XFDF or FDF
Platforms Supported
- Windows 32-bit and 64-bit
Need a Command-Line Tool Instead?

Get Free Trial
C++
C#
Java
C++
#include
#include "InitializeLibrary.h"
#include "APDFLDoc.h"
//Header that includes Forms Extension methods
#include "DLExtrasCalls.h"
#define INPUT_DIR "../../../../Resources/Sample_Input/"
#define DEF_INPUT_XFA "DynamicXFA.pdf"
#define DEF_OUTPUT_ACROFORMS "AcroForms-out.pdf"
int main(int argc, char** argv)
{
//Initialize the Forms Extension for APDFL dependencies
APDFLib libInit(NULL, kPDFLInitFormsExtension);
ASErrorCode errCode = 0;
if (libInit.isValid() == false)
{
errCode = libInit.getInitError();
std::cout << "Initialization failed with code " << errCode << std::endl;
return errCode;
}
//Verify the Forms Extension dependencies loaded correctly
if (!IsFormsExtensionSupported())
{
std::cout << "Forms Extension dependencies were not properly loaded!" << std::endl;
return -1;
}
std::string csInputFileName(argc > 1 ? argv[1] : INPUT_DIR DEF_INPUT_XFA);
std::string csOutputFileNameAcroForms(argc > 2 ? argv[2] : DEF_OUTPUT_ACROFORMS);
DURING
//Must be set to true to prevent default legacy behavior of PDFL
PDPrefSetAllowOpeningXFA(true);
//XFA document
APDFLDoc documentXFA(csInputFileName.c_str(), true);
ASUns32 pagesOutput = 0;
PDDocConvertXFAFieldsToAcroFormFields(documentXFA.getPDDoc(), &pagesOutput);
std::cout << "XFA document was converted into an AcroForms document with " << pagesOutput << " pages." << std::endl;
documentXFA.saveDoc(csOutputFileNameAcroForms.c_str(), PDSaveFull | PDSaveLinearized);
HANDLER
errCode = ERRORCODE;
libInit.displayError(errCode);
END_HANDLER
return errCode; //APDFLib's destructor terminates the library.
}
C#
using System;
using System.Collections.Generic;
using System.Text;
using Datalogics.PDFL;
namespace ConvertXFAToAcroForms
{
class ConvertXFAToAcroForms
{
static void Main(string[] args)
{
Console.WriteLine("ConvertXFAToAcroForms Sample:");
using (Library lib = new Library(LibraryFlags.InitFormsExtension))
{
if (!lib.IsFormsExtensionAvailable())
{
System.Console.Out.WriteLine("Forms Plugins were not properly loaded!");
return;
}
lib.AllowOpeningXFA = true;
Console.WriteLine("Initialized the library.");
String sInput = Library.ResourceDirectory + "Sample_Input/DynamicXFA.pdf";
String sOutput = "../ConvertXFAToAcroForms-out.pdf";
if (args.Length > 0)
{
sInput = args[0];
}
if (args.Length > 1)
{
sOutput = args[1];
}
using (Document doc = new Document(sInput))
{
UInt32 pagesOutput = doc.ConvertXFAFieldsToAcroFormFields();
Console.WriteLine("XFA document was converted into an AcroForms document with {0} pages.", pagesOutput);
doc.Save(SaveFlags.Full | SaveFlags.Linearized, sOutput);
}
}
}
}
}
Java
package com.datalogics.pdfl.samples.Forms.ConvertXFAToAcroForms;
import com.datalogics.PDFL.*;
import java.util.EnumSet;
public class ConvertXFAToAcroForms
{
public static void main(String[] args) throws Throwable {
System.out.println("ConvertXFAToAcroForms sample:");
Library lib = new Library(EnumSet.of(LibraryFlags.INIT_FORMS_EXTENSION));
try
{
if (!lib.isFormsExtensionAvailable())
{
System.out.println("Forms Plugins were not properly loaded!");
return;
}
//Must be set to true to prevent default legacy behavior of PDFL
lib.setAllowOpeningXFA(true);
System.out.println("Initialized the library.");
//XFA document
String sInput = Library.getResourceDirectory() + "Sample_Input/DynamicXFA.pdf";
String sOutput = "../ConvertXFAToAcroForms-out.pdf";
if (args.length > 0)
{
sInput = args[0];
}
if (args.length > 1)
{
sOutput = args[1];
}
Document doc = new Document(sInput);
long pagesOutput = doc.convertXFAFieldsToAcroFormFields();
System.out.println("XFA document was converted into AcroForms document with " + pagesOutput + " pages.");
doc.save(EnumSet.of(SaveFlags.FULL, SaveFlags.LINEARIZED), sOutput);
doc.delete();
}
finally {
lib.delete();
}
}
}