The file does not start with '% PDF-' when it includes the image using FPDF in Classic ASP


I've been stuck on this problem for a while, done lots of searches and tried various solutions that others reported to be working, and yet I'm still stuck. So any suggestion is hugely appreciated. Please let me know if I'm being unclear. Many thanks in advance!!

I'm trying to generate a PDF in Classic ASP (I know....) with FPDF v.1.01 (available from But I keep getting a message "File does not begin with '%PDF-'" when the PDF is populated. I've tried this in Firefox 7.0.1, IE9, which are the two browsers we use at work. If I remove this line from the code, then everything works as expected. So all I know is this line is the trouble maker (maybe?)


I have a file named report.asp. The organization of the files looks like this:


./rpt/fpdf/ - this directory contains all the files extracted from

and report.asp looks like this,which is pretty much taken directly from the example on site, except that I'm using my own jpg:

<%@LANGUAGE="javascript" CODEPAGE="65001"%>
<!--#include file="fpdf.asp" -->
var pdf=new FPDF();

pdf.Header=function Header()

pdf.Footer=function Footer()
    this.Cell(0,10,'Page '+ this.PageNo()+ '/{nb}',0,0,'C');

pdf.Cell(40,10,"Hello Word!");

I've tried the same thing in VBScript with


and function Header() and function Footer() placed in bgimg.mod, which was saved in


The code above is all report.asp contains - no HTML inside.

I am not sure, if you haven't solved the problem yet, but anyway I answer, because it could help to somebody else.

I had the same problem and I was browsing and looking long long time for solution.

Finally I found the solution. Go in fpdf.asp file, look for line with code:


You can change the code e.g. like this:


where "Temp/" is name of folder where temporary file during PDF file generation will be created and later deleted. The main trick is to assign "Modify" access rights to the folder Temp.

The error "File does not begin with '%PDF-'" appear because there are no access rights to create and then delete temporary files for your final PDF file. So you have an option to assign "Modify" access right to your root folder or transfer temporary files for PDF in folder Temp and assign "Modify" only to folder Temp (this is more secure).