views:

80

answers:

2

Hi I'm attempting to use the ASPFPDF class to output an image on a pdf using the very simple code below:

<!--#include file="fpdf.asp"-->
<%
 Dim pages

 Dim pdf
 Set pdf=CreateJsObject("FPDF")

 pdf.CreatePDF "P", "mm", "A4"

 pdf.SetPath "fpdf/"

 pdf.Open()
 pdf.AddPage("P")

 pdf.Image "invoiceheader.jpg"
 pdf.Output ()
%>

When run, this script should open the pdf but with Adobe Reader I get a "File does not begin with %pdf" message. I've tried using other readers with similar results.

If I remove the image line and output some text (e.g. pdf.Cell 40,5,"Date",0,1,"R"), everything works perfectly.

Anyone got any ideas before I go mad!

Thank you.

+1  A: 

I don't know AspFPdf, but don't you need to specify a folder where the image is to be found ? Did you try ?

pdf.Image "fpdf/invoiceheader.jpg"

As I said, I don't know the component, just my thoughts (although you have propably tried this yourself).

[EDIT] Look at the website of Asp Fpdf and saw the following in the documentation:

file 
Path or URL of the image. 

Asp fPdf : Image parameter

Anyway: thanks for pointing me in the direction of this component (even though this was not your intention). I can use this too ;-)

Edelcom
Thanks for your help Edelcom - I originally has the path specified in the image, but have now moved the image to the same folder to try and make it work!
JezB
@jezB: Still you have to be able to specify the path here too. Did you tree the ./ or .\ or the complete path on the server c:\inetroot\whatever\images\yourimage.gif ?
Edelcom
A: 

The answer to the above question is that the FPDF seems to need to be on a fully qualified domain - I was running on a machine with using a custom hosts file to point the URL at the development server. As soon as I moved the code to the live server, everything worked!

I don't fully understand why, but this might help someone else...

JezB