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
Principles to Loading a PDF with Data with ASP.net
Rules: Make sure when posting FDF Data to a buffer, do not post any HTML along with FDF Data, using VB.net, ASP.net, and the FDF Toolkit .net component. Remove any header information by declaring "Response.Clear()" before posting any PDF or PDF data MIME content.
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.MimeFDF
' 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("lstForm_Field",New String() _{"lst_Value01","lst_Value02","lst_Value03","lst_Value04"},New String() _{"DisplayName_01","DisplayName_02","DisplayName_03","DisplayName_04"})
FDFDoc.FDFSetValues("lstForm_Field",New String(){"lst_Value02","lst_Value03")
'FDFDoc.FDFSetValue("lst_Form_Field","lst_Value02")
' SET PDF LOCATION
FDFDoc.FDFSetFile(URLPath & "PDFs/sample.pdf")
' WRITE THE FDF TO THE BUFFER
Response.BinaryWrite(FDFDoc.FDFSavetoBuf(FDFApp.FDFType.FDF, False))
' BROWSER READS THE FDF DATA AND ADOBE PLUG-IN MERGES PDF WITH FDF DATA
'
End Function
End Class
dde0d06b-8765-4d75-b5c1-9f1847647c59|0|.0
BASIC PDF PROGRAMMING PRINCIPLES - MICROSOFT .NET VERSION
Principles of Merging Adobe Acrobat PDF Form and data, and forcing the web browser to save the file with VB.net
Rules: Make sure when posting PDF Data to a buffer, do not post any HTML along with PDF Data. Remove any header information except for the declaration of the code behind or remove everything below the first line of the .ASPX web page. Also, PDF MIME has to be setup on the web server.
Notes: Flattening the pdf form can be set with the true or false switch in the FDFDoc.PDFMergeFDF2Buf function.
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
DownloadFile(Export_PDF_Flattened)
Catch Ex as Exception
Response.Write("Error: " & Ex.Message)
Response.End
End Try
End Sub
Sub DownloadFile(ByVal xFile As Byte())
Try
Dim FileName As String = "PDFFile.pdf"
If xFile.Length > 0 Then
Response.Clear()
Response.ContentType = "application/pdf"
'Response.ContentType = "application/octet-stream";
Response.AppendHeader("Content-Disposition", "attachment; filename=""" & FileName & """")
Response.BinaryWrite(xFile)
Response.Flush()
End If
Catch ex As Exception
Response.Write("Error: " & Ex.Message)
Response.End
End Try
End Sub
Public Function Export_PDF_Flattened() As Byte()
Try
Dim FDFApp As New FDFApp.FDFApp_Class
Dim FDFDoc As New FDFApp.FDFDoc_Class
FDFDoc = FDFApp.FDFCreate
FDFDoc = Load_FDF(FDFDoc)
FDFDoc.PDFData = FDFDoc.PDFMergeFDF2Buf(FDFDoc, True)
Return FDFDoc.PDFData
Catch ex As Exception
Response.Write("Error: " & Ex.Message)
Response.End
End Try
End Function
Public Function Load_FDF(FDFDoc As FDFApp.FDFDoc_Class) As FDFApp.FDFDoc_Class
' INITIALIZE THE COMPONENTS
FDFDoc = FDFApp.FDFCreate
Response.Clear()
Response.ContentType = FDFApp.MimePDF
' SET TEXT, CHECKBOX, AND OPTION FIELD VALUES
FDFDoc.FDFSetValue("txtForm_Field1","Field_Value1")
FDFDoc.FDFSetValue("chkForm_Field2","Field_Value2")
FDFDoc.FDFSetValue("optForm_Field3","Field_Value3")
' SET LIST FIELD NAME ,DISPLAY NAME, AND VALUES
FDFDoc.FDFSetOpt("lstForm_Field",New String() _{"lst_Value01","lst_Value02","lst_Value03","lst_Value04"},New String() _{"DisplayName_01","DisplayName_02","DisplayName_03","DisplayName_04"})
'FDFDoc.FDFSetValues("lstForm_Field",New String(){"lst_Value02","lst_Value03")
'FDFDoc.FDFSetValue("lstForm_Field","lst_Value02")
' SET PDF LOCATION
FDFDoc.FDFSetFile(URLPath & "PDFs/sample.pdf")
Return FDFDoc
End Function
End Class
a106141c-e1cf-4170-bd8f-6439391e6f88|0|.0