繁体   English   中英

FPDF最多显示一张图片

[英]FPDF not showing more than one image

下面是一个工作正常的小片段,它向我展示了一个PDF文件,但仅包含我设置的最后一张图像。

我的代码有什么问题? 我没有找到仅针对PHP的ASP FPDF文档。 任何帮助都非常感谢。 谢谢!

<%@language=vbscript%>
<!--#include file="fpdf.asp"-->
<%Response.ContentType="application/pdf"%>

<%
imgCat = "..\fc_img\cat.jpg"
imgDog = "..\fc_img\dog.jpg"
Set pdf=CreateJsObject("FPDF")
pdf.CreatePDF "L", "mm", "A4"
pdf.SetPath("fpdf/")
pdf.Open()

pdf.AddPage()

pdf.SetTitle "Life is a b1tch"
pdf.Image imgDog , 10, 10, 20, 20
pdf.Image imgCat , 40, 40, 20, 20

pdf.Close()
pdf.Output()
%>

经过研究后,我得出的结论是,ASP组件版本的FPDF有一个导致此行为的错误。

FPDF库-PDF Generator网站论坛- [ASP] Pb avec PDF de 2页上有一个有趣的线程,它描述了您的确切问题,并得出结论:FPDF组件的ASP版本存在一个导致此问题的错误。

也许如果您向我们展示您的 fpdf.asp包含文件,我们也许可以提供更多帮助, 因为该线程中提到的OP

“我解决了。我不知道如何,但是我解决了。”

建议可以修复。


编辑:

我认为这可能是您使用的ASP FPDF已有10多年的历史了,而且似乎没有得到维护。

/****************************************************************************
*                                                                           *
* Software              : FPDF for Asp                                      *
* Version               : 1.01 beta                                         *
* Date                  : 2003/11/15                                        *
* Author                : Lorenzo Abbati                                    *
* License               : Freeware                                          *
* Site                  : http://www.aspxnet.it                             *
*                                                                           *
*****************************************************************************
*                                                                           *
* Author (PHP Class)    : Olivier Plathey                                   *
* Site (PHP Class)      : http://www.fpdf.org                               *
*                                                                           *
*****************************************************************************
*                                                                           *
* You may use and modify this software as you wish.                         *
*                                                                           *
****************************************************************************/

最新下载似乎是v1.01

引用的网站http://www.aspxnet.it似乎没有任何用处。


过去,当涉及到经典ASP时,我发现Persits Software inc开发的AspPDF在动态构建PDF时具有无价之宝。 它不是像ASP FPDF一样免费的,但它确实可以工作并且会不断更新和支持。 可能是值得一试而不是试图通过挖fpdf.asp找到原因.Image错误。


更新:

认为问题与this._out和缓冲区的构建方式有关,因为这将解释为什么输出一个图像而不输出另一个图像的原因。 例如,如果缓冲区get被重置。 不幸的是,解决此问题的唯一方法是挖掘源代码。

this.Image=function Image(xfile , xx , xy , xw , xh , xtype , xlink)
{
  if (arguments.length<5){xh=0};
  if (arguments.length<6){xtype=""};
  if (arguments.length<7){xlink=""};

  if(!lib.isset(this.images[xfile]))
  {
    if(xtype=="")
    {
      xpos=lib.strrpos(xfile,".");
      if(!xpos)this.Error("Image file has no extension and no type was specified: " + xfile);
      xtype=lib.substr(xfile,xpos+1);
    }
    xtype=xtype.toLowerCase();
    if(xtype=="jpg" || xtype=="jpeg") xinfo=this._parsejpg(xfile);
    else this.Error("Unsupported image file type: " + xtype);

    xinfo["i"]=lib.count(this.images)+1;
    this.images[xfile]=xinfo;
  }
  else
    xinfo=this.images[xfile];

  if(xw==0)xw=xh*xinfo["w"]/xinfo["h"];
  if(xh==0)xh=xw*xinfo["h"]/xinfo["w"];

  this._out(lib.sprintf("q %.2f 0 0 %.2f %.2f %.2f cm /I%d Do Q",xw*this.k,xh*this.k,xx*this.k,(this.h-(xy+xh))*this.k,xinfo["i"]));
  if(xlink)this.Link(xx,xy,xw,xh,xlink);
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM