Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Create a .fdf file with asp from database

Posted on 2004-09-14
10
Medium Priority
?
1,308 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 44

Accepted Solution

by:
Karl Heinz Kremer earned 2000 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
 
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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
Screencast - Getting to Know the Pipeline

916 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