Principles of Merging PDF and Data with VB.net, and the FDF Toolkit .net component.
Rules: Make sure when posting PDF Data to a buffer, do not post any HTML along with PDF Data. Remove any header information by declaring "Response.Clear()" before posting any PDF or PDF data MIME content.
Notes: Flattening the pdf form can be set with the true or false switch in the FDFDoc.PDFMergeFDF2Buf function using the FDF Toolkit .net component.
Imports FDFApp
Imports FDFApp.FDFApp_Class
Imports FDFApp.FDFDoc_Class
Public Class loadform
Inherits System.Web.UI.Page
Private URLPath as String = ""
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
URLPath = Request.Url.ToString
Try
Load_FDF()
Catch Ex as Exception
Response.Write("Error: " & Ex.Message)
Response.End
End Try
End Sub
Public Function Load_FDF()
' DECLARE THE COMPONENTS
Dim FDFApp As New FDFApp.FDFApp_Class
Dim FDFDoc As New FDFApp.FDFDoc_Class
' INITIALIZE THE COMPONENTS
FDFDoc = FDFApp.FDFCreate
Response.Clear()
Response.ContentType = FDFApp.MimePDF
' SET TEXT FIELD VALUES
FDFDoc.FDFSetValue("txtForm_Field1","Field_Value")
FDFDoc.FDFSetValue("txtForm_Field2","Field_Value")
FDFDoc.FDFSetValue("txtForm_Field3","Field_Value")
' SET OPTION OR LIST FIELD NAMES AND VALUES
FDFDoc.FDFSetOpt("optForm_Field",New String() _{"Opt_Value01","Opt_Value02","Opt_Value03","Opt_Value04"},New String() _{"DisplayName_01","DisplayName_02","DisplayName_03","DisplayName_04"})
FDFDoc.FDFSetValues("optForm_Field",New String(){"Opt_Value02","Opt_Value03")
'FDFDoc.FDFSetValue("optForm_Field","Opt_Value02")
' SET PDF LOCATION
FDFDoc.FDFSetFile(URLPath & "PDFs/sample.pdf")
' MERGE PDF WITH FDF DATA AND FLATTEN
FDFDoc.PDFData = FDFDoc.PDFMergeFDF2Buf(FDFDoc, True) ' WRITE THE FDF TO THE BUFFER
Response.BinaryWrite(FDFDoc.PDFData)
' BROWSER READS THE PDF DOCUMENT AND ADOBE PLUG-IN OPENS
'
End Function
End Class
a7ca5a5f-c8d5-4abd-9286-738b7a59741f|0|.0