Asp classic asp fpdf尝试输出分配给变量的图像

Asp classic asp fpdf尝试输出分配给变量的图像,asp-classic,fpdf,Asp Classic,Fpdf,这是我用来在标题中显示图像的代码。我的问题是我想为图像使用一个变量,当我输入变量名而不是图像名时,我得到一个错误: Microsoft JScript运行时错误“800a138f” “undefined”为null或不是对象 /EKtestdb/fpdf/fpdf/includes/Basics.asp,第121行 this.Header=function Header() { this.SetY (10) this.SetFont ("Times","",10)

这是我用来在标题中显示图像的代码。我的问题是我想为图像使用一个变量,当我输入变量名而不是图像名时,我得到一个错误:

Microsoft JScript运行时错误“800a138f”

“undefined”为null或不是对象

/EKtestdb/fpdf/fpdf/includes/Basics.asp,第121行

    this.Header=function Header() 
  { 
  this.SetY (10) 
  this.SetFont ("Times","",10) 
  //this.Cell (45,5, "HEADER", 0, 0, "L") 
  this.SetFont ("Times","b",14) 
  //this.Cell (190,5, this.title, 0, 0, "C") 
  this.Cell (190,20, this.title, 0, 0) 
  this.SetFont ("Times","",10) 
  this.Image('logoSM1.jpg',165,3,33) 
  this.Image( techpic ,165,3,33)
这是basics.asp第121行的代码:

this.strrpos=function strrpos(s,ch){ 
 res = s.lastIndexOf(ch) 
 if (res>0-1){return res}else{return false} 
} 
this.strpos=function strpos(s,ch,start){ 
 if (arguments.length<3){start=0} 
 res = s.indexOf(ch,start); 
 if (res>-1){return res}else{return false} 
}

但是如果使用变量而不是图像名称,有人能帮我吗?

我正在更新我的答案,因为我没有意识到您同时使用JScript和VBscript。您不需要添加,因为您的所有代码都已经在Jscript端

我不知道您为什么会遇到这个问题,但是查看您添加的代码,我没有看到LoadModels(),fpdf的文档说如果您使用vbscript页面,您需要LoadModels()

我也不确定这是否重要,但也许您可以添加一个开始和结束单引号:

this.Image( "'" + techpic + "'" ,165,3,33);

我还注意到,
this.Header=function Header()
下的所有代码后面都没有分号,这是JSCript所必需的。

我遇到的问题是变量声明,我不知道为什么,但我必须在pdf.asp文件的第一部分声明变量,以便在头中输出一个变量。对于页脚中的输出,情况并非如此,我仍然不确定为什么这里有一个fpdf.asp代码示例:

this.Header=function Header()
        {
        this.SetY (10);
        this.SetFont ("Times","b",14);
        this.Cell (190,20, this.title, 0, 0);
        this.SetFont ("Times","",10);
        //this.Image('logoSM1.jpg',165,3,33);
        this.Image( techpic2 ,165,3,33);
        }
    this.Footer=function Footer()
        {
        this.SetY (-15)
        this.SetFont ("Times","i",10)
        this.Cell (190, 5, "", 0, 1)
        this.Cell (190, 0, "", 1, 1)
        this.Cell (45, 5, EmployeeName + " - " + EmployeeNo, 0, 0, "L")
        this.Cell (100, 5, this.PageNo() + "/{nb}", 0, 0, "C")
        this.Cell (45, 5, "", 0, 0, "R")            
        }
strSQL = "SELECT * FROM employee_course_vendortraining_view "  

objRS.Open strSQL, objConn

%>

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

<%

Set pdf=CreateJsObject("FPDF")

pdf.CreatePDF()

pdf.SetPath("fpdf/")

'------pdf.SetFont "Arial","",16

pdf.Open()

pdf.AddPage()


if (objRS.EOF) then

else

    Do Until objRS.EOF = True

    EmployeeNo = objRS("EmployeeNo")
    EmployeeName = objRS("EmployeeName")
     techpic2 = objRS("techpic2") 
在上面的代码中,页脚将正确检索EmployeeName和output的值,但在页眉中不会检索techpic2的值。在techpic2上方的一行中,成功显示了图像。以下是pdf.asp代码示例:

this.Header=function Header()
        {
        this.SetY (10);
        this.SetFont ("Times","b",14);
        this.Cell (190,20, this.title, 0, 0);
        this.SetFont ("Times","",10);
        //this.Image('logoSM1.jpg',165,3,33);
        this.Image( techpic2 ,165,3,33);
        }
    this.Footer=function Footer()
        {
        this.SetY (-15)
        this.SetFont ("Times","i",10)
        this.Cell (190, 5, "", 0, 1)
        this.Cell (190, 0, "", 1, 1)
        this.Cell (45, 5, EmployeeName + " - " + EmployeeNo, 0, 0, "L")
        this.Cell (100, 5, this.PageNo() + "/{nb}", 0, 0, "C")
        this.Cell (45, 5, "", 0, 0, "R")            
        }
strSQL = "SELECT * FROM employee_course_vendortraining_view "  

objRS.Open strSQL, objConn

%>

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

<%

Set pdf=CreateJsObject("FPDF")

pdf.CreatePDF()

pdf.SetPath("fpdf/")

'------pdf.SetFont "Arial","",16

pdf.Open()

pdf.AddPage()


if (objRS.EOF) then

else

    Do Until objRS.EOF = True

    EmployeeNo = objRS("EmployeeNo")
    EmployeeName = objRS("EmployeeName")
     techpic2 = objRS("techpic2") 
strSQL=“从员工课程供应商培训视图中选择*”
打开strSQL,objConn
%>

我无法让它工作是的变量是一个ASP变量,我尝试了上面的代码,但它无法工作。它给了我一条消息:FPDF错误:图像文件没有扩展名,没有指定类型:这是ASP代码的一个示例。如果需要查看更多信息,请告诉我:Set pdf=CreateJsObject(“FPDF”)pdf.CreatePDF()pdf.SetPath(“FPDF/”)'----pdf.SetFont“Arial”,16 pdf.Open()pdf.AddPage()Dim techpic techpic=“logoSM1.jpg”if(objRS.EOF)然后else直到objRS.EOF=True EmployeeNo=objRS(“EmployeeNo”)@bluffo我更新了我的答案,因为我以为你在混合javascript和vbscript,但实际上它是JScript,所以你不需要。我注意到也没有分号,我添加了分号,没有图像,加载速度会更快,但是这次我仍然无法让图像正常工作错误消息不同:FPDF错误:图像文件没有扩展名,没有指定类型:“未定义”如果您需要,我可以发布更多代码示例。谢谢您的帮助。我试图在另一个论坛发布此问题,他们说我使用了错误的论坛。Microsoft JScript运行时错误“800a138f”“未定义”为空或不是对象/EKtestdb/fpdf/fpdf/includes/Basics.asp,第行121@bluffo这有点像是在黑暗中拍摄的,但是试试这个.Image(eval(techpic),165,3,33)或者这个.Image(eval('techpic'),165,3,33)好的,我终于让它工作了问题在于我的Dim techpic声明出于某种原因,我不得不将它上移到选择和变量=objRS之前的第一个asp部分,我不知道为什么,但至少现在它工作了。谢谢瓦利德的回复,你帮助我解决了问题,对于其他有问题的人,我希望这能帮助你。