• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1314
  • Last Modified:

Create a .fdf file with asp from database

I need to have the user print data from an ASP app I'm creating, it has to be in landscape form etc, I got it working from a webpage, but it just doesn't look very good when printed, html just doesn't print very well..  I'd like to be able to create a ASP page that creates a .fdf file populated from the DB that the app uses, then redirect to the pdf page that is populated from the fdf file.. Not sure if I can write over the fdf every time or if I need to create a new one each time.. if it writes over it each time, what if two users try to print a different document around the same time?  If anyone has an asp page that creates this fdf file please help me do this!  Thanks.
0
H2Omike
Asked:
H2Omike
  • 6
  • 4
1 Solution
 
H2OmikeAuthor Commented:
I've installed the fdf toolkit and have this .asp page:

<%@ Language=VBScript %>
<!--#INCLUDE file="DB_Connect_User.asp" -->

<%
Dim Num
Num = Request.QueryString("num")
Dim UserID
UserID = Session("SessID")
response.buffer = true

strsql = "SELECT * FROM [Reqs] where ReqNum = '" & Num & "'"

            set rsReqs = Server.CreateObject("ADODB.Recordset")
            rsReqs.Open strsql, connDB, 1, 2
            
response.buffer = true

'ADOBE SYSTEMS INCORPORATED
'Copyright [1999] - [2001] Adobe Systems Incorporated
'All Rights Reserved

'NOTICE:  Adobe permits you to use, modify, and distribute
'this file in accordance with the terms of the Adobe license
'agreement accompanying it.  If you have received this file
'from a source other than Adobe, then your use, modification,
'or distribution of it requires the prior written permission of Adobe.

Set FdfAcX = Server.CreateObject("FdfApp.FdfApp")

Set outputFDF = FdfAcX.FDFCreate      
            
outputFDF.FDFSetValue "ReqNum", rsReqs("ReqNum"), False
outputFDF.FDFSetValue "UID", UserID, False       
outputFDF.FDFSetValue "DateEntered", rsReqs("DateEntered"), False       
outputFDF.FDFSetValue "DueDate", rsReqs("DueDate"), False
If rsReqs("Vendor2") = "" Then
outputFDF.FDFSetValue "Vendor", rsReqs("Vendor1"), False
Else
outputFDF.FDFSetValue "Vendor", rsReqs("Vendor2"), False
End If

outputFDF.FDFSetFile "http://req.etwd.com/PDF/requisition2.pdf"            

Response.ContentType = "application/vnd.fdf"
Response.BinaryWrite outputFDF.FDFSaveToBuf

outputFDF.FDFClose
Response.Redirect("http://req.etwd.com/PDF/requisition2.pdf")
%>

When it runs it just redirects me to the form (requisition2.pdf) and doesn't fill it in, can someone please tell me what I'm doing wrong!  
0
 
Karl Heinz KremerCommented:
Let me first say that I have zero experience with ASP, and almost zero experience with the FDFToolkit (I create FDF files from scratch, the format is pretty simple, and does not really warrant the overhead of the toolkit). So, now that we have the disclaimer out of the way, let's try to solve your problem :-)

Are you viewing the PDF file in Acrobat (or Reader) on the client? Is it configured so that it does not display the PDF document in the browser? The merging of FDF and PDF only works if you display the PDF in the browser.

Do you want to print from the server, or should the printing be initiated on the client? If you want to print from the server, you should use a program that can merge FDF and PDF data. One cheap example is http://www.pdfeverywhere.com/pdfform.html - it's in public beta, and free for now. You could of course also do this on the server, and just download the PDF to the client.
0
 
H2OmikeAuthor Commented:
I'm viewing the pdf in the browser on the client..

They were going to print from thier machines..

Just to test, how do I open a pdf while loading it with data from an fdf?  just open the fdf?  I'm very new to pdf/fdf developement, maybe between the two of us we can get this figured out..
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
Karl Heinz KremerCommented:
Yes, just open the FDF. This will have a /F dictionary entry that points to the PDF file, and Acrobat (or Reader) should load the PDF file (which it does) and initialize the fields (which it does not).

What happens if you save both files to a local disk, edit the FDF file and replace the URL to the PDF file with just the file name? Then drag&drop the FDF file into Reader or Acrobat. Does it initialize the fields?

As I said, I don't know ASP, but try to remove the redirect statement. This looks like trouble...
0
 
H2OmikeAuthor Commented:
The redirect was messing it up, it's populating it now, but I'm getting a couple format errors, both numbers:

I have them formatted as numbers on the form, but in the DB they are text.. do I have to change that?  

0
 
Karl Heinz KremerCommented:
What type of format errors? Where are these reported (or, do you just end up with the wrong data)? Can you give examples for this?
0
 
H2OmikeAuthor Commented:
Sorry,,

Adobe Acrobat errors:

"The Value entered does not match the format of the field [gtot]"
click okay
"The Value entered does not match the format of the field [Price1]"
click okay
"The Value entered does not match the format of the field [Price2]"
click okay
etc etc..

after I click okay it populated the rest of the fields, except a couple fields that I'm not getting errors for like "Delivery" and "comments", and all the fields that I get errors for do not populate.
0
 
H2OmikeAuthor Commented:
It's case sensitive??

That's kinda lame!
0
 
Karl Heinz KremerCommented:
It looks like you've configured format options for these fields. Do you expect your users to change these fields, or should they only print the file? If they are not supposed to change anything, make the fields read-only and remove your format configuration.
0
 
H2OmikeAuthor Commented:
Works great, thanks a bunch!
0

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

  • 6
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now