【发布时间】:2011-12-13 23:03:52
【问题描述】:
我已经被这个问题困扰了一段时间,进行了大量搜索并尝试了其他人报告的各种解决方案,但我仍然被卡住了。因此,非常感谢任何建议。如果我不清楚,请告诉我。非常感谢提前!
我正在尝试使用 FPDF v.1.01(可从 http://www.aspxnet.it/public/Default.asp?page=172 获得)在 Classic ASP(我知道....)中生成 PDF。但是当填充 PDF 时,我不断收到一条消息“文件不以 '%PDF-' 开头”。我在 Firefox 7.0.1、IE9 中尝试过这个,这是我们在工作中使用的两个浏览器。如果我从代码中删除这一行,那么一切都会按预期工作。所以我只知道这条线是麻烦制造者(也许?)
this.Image('bg_logo_small.jpg',10,8,213,46);
我有一个名为report.asp 的文件。文件的组织如下所示:
./rpt/report.asp
./rpt/fpdf.asp
./rpt/bg_logo_small.jpg
./rpt/fpdf/ - this directory contains all the files extracted from fpdf1.01.zip
./rpt/fpdf/extends/
./rpt/fpdf/fonts/
./rpt/fpdf/includes/
./rpt/fpdf/models/
report.asp 看起来像这样,几乎直接取自 aspxnet.it 网站上的示例,只是我使用的是我自己的 jpg:
<%@LANGUAGE="javascript" CODEPAGE="65001"%>
<!--#include file="fpdf.asp" -->
<%
var pdf=new FPDF();
pdf.Header=function Header()
{
this.Image('bg_logo_small.jpg',10,8,213,46);
this.SetFont('Arial','B',15);
this.Cell(80);
this.Cell(30,10,'Title',1,0,'C');
this.Ln(20);
}
pdf.Footer=function Footer()
{
this.SetY(-15);
this.SetFont('Arial','I',8);
this.Cell(0,10,'Page '+ this.PageNo()+ '/{nb}',0,0,'C');
}
pdf.CreatePDF();
pdf.SetPath("fpdf/");
pdf.SetFont("Arial","",16);
pdf.Open();
pdf.AddPage();
pdf.Cell(40,10,"Hello Word!");
pdf.Close();
pdf.Output();
%>
我在 VBScript 中尝试过同样的事情
pdf.LoadModels("bgimg")
以及函数Header()和函数Footer()放在bgimg.mod中,保存在
./rpt/fpdf/models/
上面的代码都是report.asp包含的——里面没有HTML。
【问题讨论】:
标签: image pdf asp-classic fpdf