Solved

Create a .fdf file with asp from database

Posted on 2004-09-14
10
1,225 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 44

Expert Comment

by:Karl Heinz Kremer
Comment Utility
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
Comment Utility
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
Comment Utility
It's case sensitive??

That's kinda lame!
0
 
LVL 44

Expert Comment

by:Karl Heinz Kremer
Comment Utility
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
Comment Utility
Works great, thanks a bunch!
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

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 was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

743 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