Examining the FDF Toolkit 
by Lauren Hightower

Listing One
<%
    Set objFDF = Server.CreateObject("FdfApp.FdfApp")
    Set FDF = objFDF.FDFCreate
%>


Listing Two
<%
    For Each vpItem In Request.Form
        FDF.FDFSetValue vpItem, UCase(Request.Form(vpItem)), False
    Next
    fpBalance = Request.Form("Liability") - Request.Form("Payments")
    FDF.FDFSetValue "Balance",fpBalance,False
%>

Listing Three
<%        
    FDF.FDFSetFile "c:\prj\pdfarticle\f4868.pdf"
    FDF.FDFSaveToFile "c:\prj\pdfarticle\temp.fdf"
%>

Listing Four
%FDF-1.2
%bcOS
1 0 obj
<< 
/FDF << /Fields 2 0 R /F (c:\\prj\\pdfarticle\\f4868.pdf)>> 
>> 
endobj

2 0 obj
[ 
<< /T (TaxPayerName)/V (JANE MARIE DOE)>> 
<< /T (TaxPayerAddress)/V (123 MAIN STREET)>> 
<< /T (TaxPayerCityStateZip)/V (ANYTOWN, CA  99097)>> 
<< /T (SSN_1)/V (111)>> 
<< /T (SSN_2)/V (11)>> 
<< /T (SpouseGiftGSTExtension)/V ()>> 
<< /T (SSN_3)/V (1111)>> 
<< /T (SpouseSSN_1)/V (999)>> 
<< /T (SpouseSSN_2)/V (99)>> 
<< /T (SpouseSSN_3)/V (9999)>> 
<< /T (Payments)/V (2000)>> 
<< /T (GiftGSTExtension)/V (X)>> 
<< /T (Payment)/V (5000)>> 
<< /T (Liability)/V (5000)>> 
<< /T (SpouseGSTPayment)/V (89)>> 
<< /T (GSTPayment)/V (3000)>> 
<< /T (Balance)/V (3000)>> 

]
endobj
trailer
<<
/Root 1 0 R 

>>
%%EOF

Listing Five
<%  
    Response.Write "<a href=temp.fdf>Click Here to see the PDF</a>"
%>

Listing Six
spCommand = c:\fdfmerge\fdfmerge.exe -l Log.txt -o 
            c:\prj\pdfarticle\temppdf.pdf 
            c:\prj\pdfarticle\f4868.pdf 
            c:\prj\pdfarticle\temp.fdf
vpShell = ExecCmd(spCommand)

Listing Seven
Public Function Generate4868(ByVal vhPDFFileName As Variant, 
                              ByVal vhFDFFileName As Variant) As Variant
Dim spPDFTemp As String
Dim vpShell As Variant
Dim spCommand As String
Dim opFileSys As Object

'====================================================
' GET A TEMPORARY NAME FOR THE GENERATED PDF DOCUMENT
'====================================================
    Set opFileSys = CreateObject("Scripting.FileSystemObject")
    spPDFTemp = opFileSys.GetTempName()
    spPDFTemp = Replace(spPDFTemp, ".tmp", ".pdf")
    spPDFTemp = "c:\prj\pdfArticle\" & spPDFTemp
'=====================================
' GENERATE THE PDF FILE USING FDFMERGE
'=====================================
   spCommand = "c:\fdfmerge\fdfmerge.exe -l Log.txt -o " & spPDFTemp & " " &_
   vhPDFFileName & " " & vhFDFFileName
   vpShell = ExecCmd(spCommand) ' Run FDFMerge.
'====================================
' READ THE BINARY FILE AND SEND IT
' TO THE USER
'====================================
    If vpShell = 0 Then
        Generate4868 = readBinFile(spPDFTemp)
        opFileSys.DeleteFile vhFDFFileName, True
        opFileSys.DeleteFile spPDFTemp, True
    Else
        Generate4868 = "There was an error in the generation."
    End If
'====================================
' CLEAN UP
'====================================
    Set opFileSys = Nothing
End Function

Listing Eight 
<%
Set oPDFGenerator = Server.CreateObject("pdfArticle.clsInterface") 
vPDFContent = oPDFGenerator.ReadPDF(TempPDF)
Response.BinaryWrite vPDFContent
%>


2

