FDF files contain data associated with a PDF file. When a PDF contains form field objects, the content (or value) of these objects can be stored in a separate file for transmission to remote server for example.
Since the Version 3.0 of the PDFCreator and the PDF Converter, they support the import of data from FDF files through the Merge method. First the PDF is opened using one of the Open methods of CDINTF, PDFCreativeX or the .NET library. Then the Merge method is called on the FDF file to merge the data into the main PDF.
<Flags()>
Public Enum MERGEOPTIONS As Integer
No_Repeat = 0
Repeat = 1
Above = 2
Layered = 4
End Enum
Public Sub Sample()
' Constants for Activation codes
Const strLicenseTo As String = "Amyuni PDF Creator .NET Evaluation"
Const strActivationCode As String = "07EFCDAB0100010025C3B7B351579FF94C49112EAF7368612744C7237C2F6A215A53E83A9ECCFFE54C52063CB05338BDE555773D7B1B"
' Initialize library
' This should be done once
acPDFCreatorLib.Initialize()
' set license key This is needed only with licensed version
acPDFCreatorLib.SetLicenseKey(strLicenseTo, strActivationCode)
' Create new stream object
Dim fileRead As System.IO.Stream = System.IO.File.OpenRead("C:\temp\PDFDocument.pdf")
' Creating Document Object
Dim doc As New Amyuni.PDFCreator.IacDocument()
' Open stream
Dim Password As String = ""
doc.Open(fileRead, Password)
' Create new stream object
Dim fileRead2 As System.IO.Stream = System.IO.File.OpenRead("C:\temp\data.fdf")
' Creating Document Object
Dim doc2 As New Amyuni.PDFCreator.IacDocument()
' Open stream
Password = ""
doc2.Open(fileRead2, Password)
' Close the stream
fileRead2.Close()
' Insert the DATA from FDF file
doc.Merge(doc2, MERGEOPTIONS.No_Repeat)
' Create new stream object
Dim fileWrite As System.IO.Stream = System.IO.File.OpenWrite("C:\temp\Merged.pdf")
' Save stream
doc.Save(fileWrite, Amyuni.PDFCreator.IacFileSaveOption.acFileSaveView)
' Close the stream
fileRead.Close()
fileWrite.Close()
' terminate library to free resources
acPDFCreatorLib.Terminate()
End Sub
[Flags]
public enum MERGEOPTIONS
{
No_Repeat = 0,
Repeat = 1,
Above = 2,
Layered = 4
}
public void Sample()
{
// Constants for Activation codes
const string strLicenseTo = "Amyuni PDF Creator .NET Evaluation";
const string strActivationCode = "07EFCDAB0100010025C3B7B351579FF94C49112EAF7368612744C7237C2F6A215A53E83A9ECCFFE54C52063CB05338BDE555773D7B1B";
// Initialize library
// This should be done once
acPDFCreatorLib.Initialize();
// set license key This is needed only with licensed version
acPDFCreatorLib.SetLicenseKey(strLicenseTo, strActivationCode);
// Create new stream object
System.IO.FileStream fileRead = new System.IO.FileStream(@"C:\temp\PDFDocument.pdf",
System.IO.FileMode.Open,
System.IO.FileAccess.Read,
System.IO.FileShare.Read);
// Creating Document Object
Amyuni.PDFCreator.IacDocument doc = new Amyuni.PDFCreator.IacDocument();
// Open stream
String password = "";
doc.Open(fileRead, password);
// Close the stream
fileRead.Close();
// Create new stream object
System.IO.FileStream fileRead2 = new System.IO.FileStream(@"C:\temp\data.fdf",
System.IO.FileMode.Open,
System.IO.FileAccess.Read,
System.IO.FileShare.Read);
// Creating Document Object
Amyuni.PDFCreator.IacDocument doc2 = new Amyuni.PDFCreator.IacDocument();
// Open stream
String password2 = "";
doc2.Open(fileRead2, password);
// Insert the DATA from FDF file
doc.Merge(doc2, (int)MERGEOPTIONS.No_Repeat);
// Create new stream object
System.IO.FileStream fileWrite = new System.IO.FileStream(@"C:\temp\Merged.pdf",
System.IO.FileMode.Create,
System.IO.FileAccess.Write,
System.IO.FileShare.Read);
// Save stream
doc.Save(fileWrite, Amyuni.PDFCreator.IacFileSaveOption.acFileSaveView);
// Close the stream
fileRead2.Close();
fileWrite.Close();
// terminate library to free resources
acPDFCreatorLib.Terminate();
}