Solved

Create a .fdf file with asp from database

Posted on 2004-09-14
10
1,230 Views
Last Modified: 2012-05-05
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
Comment
Question by:H2Omike
  • 6
  • 4
10 Comments
 

Author Comment

by:H2Omike
ID: 12059622
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
 
LVL 44

Expert Comment

by:Karl Heinz Kremer
ID: 12059678
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
 

Author Comment

by:H2Omike
ID: 12059746
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
 
LVL 44

Accepted Solution

by:
Karl Heinz Kremer earned 500 total points
ID: 12059823
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
 

Author Comment

by:H2Omike
ID: 12059905
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 44

Expert Comment

by:Karl Heinz Kremer
ID: 12059947
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
 

Author Comment

by:H2Omike
ID: 12059996
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
 

Author Comment

by:H2Omike
ID: 12060037
It's case sensitive??

That's kinda lame!
0
 
LVL 44

Expert Comment

by:Karl Heinz Kremer
ID: 12060041
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
 

Author Comment

by:H2Omike
ID: 12060103
Works great, thanks a bunch!
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:  The Exchange of information …
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…
Both in life and business – not all partnerships are created equal. As the demand for cloud services increases, so do the number of self-proclaimed cloud partners. Asking the right questions up front in the partnership, will enable both parties …

910 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now