Ir para conteúdo

Arquivado

Este tópico foi arquivado e está fechado para novas respostas.

Fells

[Resolvido] Gerando PDF via ASP

Recommended Posts

Seguinte galera.. eu encontrei o codigo abaixo na internet:

 

<%
' Cria uma instância do controle
Set aspPdf = Server.CreateObject("Persits.Pdf")
' Cria um documento em branco
Set Doc = aspPdf.CreateDocument
' Importa a URL da Internet
Doc.ImportFromUrl "http://www.google.com.br/"
' Salva o documento.
ArquivoPDF = Doc.Save( Server.MapPath("importa_url.pdf"), False )
' Tira os objetos da memória
Set Doc = Nothing
Set aspPdf = Nothing
Response.Write "Arquivo criado com sucesso : " & ArquivoPDF
%>

 

Pelo que entendi e vi ele importa uma URL de um site e gera um documento PDF com a tela capturada do mesmo.

 

Mas eu tenho algumas duvidas quanto ao código e gostaria da ajuda de vcs.

1º - o que seria esse Persits.Pdf, é um complemento? Eu devo baixar? Como funciona?

Pois obviamente que se eu rodar o código ele não vai fazer nada.

 

2º - a parte do Server.MapPath("importa_url.pdf") .. nunca consegui entender isso.

Eh aqui que eu indico o caminho a ser salvo o documento?

Supondo que eu tenha vários servidores e preciso salvar os documentos no I:\Intranet_Homologa\Manutencao\ASV.

Como especifico isso?

 

Bom por enquanto acho que eh isso rsrs

 

Agradeço desde ja galera.

Abraço

Compartilhar este post


Link para o post
Compartilhar em outros sites

ele é um componente e você precisa baixá-lo,instalá-lo, masi detalhes aqui

 

Você pode usar esta classe free,não precisa de nenhum COM+, não é preciso registrar nenhum componente (DLL) no servidor, basta fazer um include do FPDF no códgio e criar seu PDF igual no exemplo em anexo, abaixo temos um exemplo simples do código que gera o PDF.

 

<%@language=vbscript%>
<!--#include file="fpdf.asp"-->
<%
Set pdf=CreateJsObject("FPDF")
pdf.CreatePDF()
pdf.SetPath("fpdf/")
pdf.SetFont "Arial","",16
pdf.Open()
pdf.AddPage()
pdf.Cell 40,10,"Hello Word!"
pdf.Close()
pdf.Output()
%>

 

fpdf.asp

<!--#include file="fpdf/includes/Basics.asp"-->
<script language="jscript" runat="server">


function FPDF()
{
this.Version = "0.01 beta"
var PATH;
var lib=new clib()
var page;
var n;
var offsets;
var buffer;
var pages;
var state;
var compress;
var DefOrientation;
var CurOrientation;
var OrientationChanges;
var fwPt;
var fhPt;
var fw;
var fh;
var wPt;
var hPt;
var k;
var w;
var h;
var x;
var y;
var lMargin;
var tMargin;
var rMargin;
var bMargin;
var cMargin;
var hasBinary = false;
var lasth;
var LineWidth;
var CoreFonts;
var fonts;
var FontFiles;
var diffs;
var images;
var PageLinks;
var links;
var FontFamily;
var FontStyle;
var underline;
var CurrentFont;
var FontSizePt;
var FontSize;
var DrawColor;
var FillColor;
var TextColor;
var ColorFlag;
var ws;
var AutoPageBreak;
var PageBreakTrigger;
var InFooter;
var ZoomMode;
var LayoutMode;
var title;
var subject;
var author;
var keywords;
var creator;
var AliasNbPages;

this.Interlinea=0;

this.SetPath=function SetPath(value){
	this.PATH = value
	if (this.PATH.charAt(this.PATH.length-1)!="/"){this.PATH+="/"}
	this.FONTPATH = this.PATH + "fonts/"
	this.EXTENDSPATH = this.PATH + "extends/"
	this.MODELSPATH = this.PATH + "models/"
}

this.CreatePDF=function CreatePDF(xorientation , xunit , xformat)
	{
	if (arguments.length<1) {xorientation="P"};
	if (arguments.length<2) {xunit="mm"};
	if (arguments.length<3) {xformat="A4"};
	this.SetPath("./fpdf/")
	this.page=0;
	this.n=2;
	this.AliasNbPages="{nb}"
	this.buffer="";
	this.pages=new Array();
	this.offsets=new Array();
	this.OrientationChanges=new Array();
	this.state=0;
	this.fonts=new Array();
	this.FontFiles=new Array();
	this.diffs=new Array();
	this.images=new Array();
	this.links=new Array();
	this.PageLinks=new Array();
	this.InFooter=false;
	this.title="";
	this.subject="";
	this.author="";
	this.keywords="";
	this.creator="";
	this.FontFamily="";
	this.FontStyle="";
	this.FontSizePt=12;
	this.underline=false;
	this.DrawColor="0 G";
	this.FillColor="0 g";
	this.TextColor="0 g";
	this.ColorFlag=false;
	this.ws=0;
	this.PageLinks=new Array();
	this.CurrentFont=new Array();
	this.CoreFonts=new Array();
	this.CoreFonts["courier"]="Courier";
	this.CoreFonts["courierB"]="Courier-Bold";
	this.CoreFonts["courierI"]="Courier-Oblique";
	this.CoreFonts["courierBI"]="Courier-BoldOblique";
	this.CoreFonts["helvetica"]="Helvetica";
	this.CoreFonts["helveticaB"]="Helvetica-Bold";
	this.CoreFonts["helveticaI"]="Helvetica-Oblique";
	this.CoreFonts["helveticaBI"]="Helvetica-BoldOblique";
	this.CoreFonts["times"]="Times-Roman";
	this.CoreFonts["timesB"]="Times-Bold";
	this.CoreFonts["timesI"]="Times-Italic";
	this.CoreFonts["timesBI"]="Times-BoldItalic";
	this.CoreFonts["symbol"]="Symbol";
	this.CoreFonts["zapfdingbats"]="ZapfDingbats";
	if(xunit=="pt")this.k=1;
	else if(xunit=="mm")this.k=72/25.4;
	else if(xunit=="cm")this.k=72/2.54;
	else if(xunit=="in")this.k=72;
	else
	this.Error("Incorrect unit: " + xunit);
	if(xformat.constructor==String)
		{
		xformat=xformat.toLowerCase();
		if(xformat=="a3")xformat=new Array(841.89,1190.55);
		else if(xformat=="a4")xformat=new Array(595.28,841.89);
		else if(xformat=="a5")xformat=new Array(420.94,595.28);
		else if(xformat=="letter")xformat=new Array(612,792);
		else if(xformat=="legal")xformat=new Array(612,1008);
		else
		this.Error("Unknown page format: " + xformat);
		 this.fwPt=xformat[0];
		 this.fhPt=xformat[1];
		}
	else
		{
		 this.fwPt=xformat[0]*this.k;
		 this.fhPt=xformat[1]*this.k;
		}
	 this.fw=this.fwPt/this.k;
	 this.fh=this.fhPt/this.k;
	xorientation=xorientation.toLowerCase();
	if(xorientation=="p" || xorientation=="portrait")
		{
		 this.DefOrientation="P";
		 this.wPt=this.fwPt;
		 this.hPt=this.fhPt;
		}
	else if(xorientation=="l" || xorientation=="landscape")
		{
		 this.DefOrientation="L";
		 this.wPt=this.fhPt;
		 this.hPt=this.fwPt;
		}
	else this.Error("Incorrect orientation: " + xorientation);
	 this.CurOrientation=this.DefOrientation;
	 this.w=this.wPt/this.k;
	 this.h=this.hPt/this.k;
	xmargin=28.35/this.k;
	 this.SetMargins(xmargin,xmargin);
	 this.cMargin=xmargin/10;
	 this.LineWidth=.567/this.k;
	 this.SetAutoPageBreak(true,xmargin);
	 this.SetDisplayMode("fullwidth");
	 this.SetCompression(true);
	}

this.SetMargins=function SetMargins(xleft , xtop , xright)
	{
		if (arguments.length<3) {xright=-1};
		this.lMargin=xleft;
		this.tMargin=xtop;
		if(xright==-1)xright=xleft;
		this.rMargin=xright;
	}
	this.SetLeftMargin=function SetLeftMargin(xmargin){this.lMargin=xmargin;if(this.page>0 && this.x<xmargin)this.x=xmargin;}
	this.SetTopMargin=function SetTopMargin(xmargin){this.tMargin=xmargin;}
	this.SetRightMargin=function SetRightMargin(xmargin){this.rMargin=xmargin;}
	this.SetAutoPageBreak=function SetAutoPageBreak(xauto , xmargin)
	{
	if (arguments.length<2) {xmargin=0};

	 this.AutoPageBreak=xauto;
	 this.bMargin=xmargin;
	 this.PageBreakTrigger=this.h-xmargin;
	}
this.SetDisplayMode=function SetDisplayMode(xzoom , xlayout)
	{
	if (arguments.length<2) {xlayout="continuous"};

	if(xzoom=="fullpage" || xzoom=="fullwidth" || xzoom=="real" || xzoom=="default" || !is_string(xzoom))this.ZoomMode=xzoom;
	else if(xzoom=="zoom")this.ZoomMode=xlayout;
	else
	this.Error("Incorrect zoom display mode: " + xzoom);
	if(xlayout=="single" || xlayout=="continuous" || xlayout=="two" || xlayout=="default")this.LayoutMode=xlayout;
	else if(xzoom!="zoom")this.Error("Incorrect layout display mode: " + xlayout);
	}
this.SetCompression=function SetCompression(xcompress)
	{
	if(lib.function_exists("gzcompress"))this.compress=xcompress;
	else
		this.compress=false;
	}
this.AcceptPageBreak=function AcceptPageBreak(){return this.AutoPageBreak;}
this.Header=function Header(){}
this.Footer=function Footer(){}
this.PageNo=function PageNo(){return this.page;}
this.SetTitle=function SetTitle(xtitle) {this.title=xtitle;}
this.SetSubject=function SetSubject(xsubject){this.subject=xsubject;}
this.SetAuthor=function SetAuthor(xauthor){this.author=xauthor;}
this.SetKeywords=function SetKeywords(xkeywords){this.keywords=xkeywords;}
this.SetCreator=function SetCreator(xcreator){this.creator=xcreator;}
this.Error=function Error(xmsg)
	{
	Response.Write("<B>FPDF error: </B>" + xmsg);
	Response.End
	}
this.Open=function Open(){this._begindoc();}
this.Close=function Close()
	{
	if(this.page==0)this.AddPage();
	 this.InFooter=true;
	 this.Footer();
	 this.InFooter=false;
	 this._endpage();
	 this._enddoc();
	}
this.AddPage=function AddPage(xorientation)
	{
	if (arguments.length<1) {xorientation=""};
	xfamily=this.FontFamily;
	xstyle=this.FontStyle + (this.underline?"U":"");
	xsize=this.FontSizePt;
	xlw=this.LineWidth;
	xdc=this.DrawColor;
	xfc=this.FillColor;
	xtc=this.TextColor;
	xcf=this.ColorFlag;
	if(this.page>0)
		{
		 this.InFooter=true;
		 this.Footer();
		 this.InFooter=false;
		 this._endpage();
		}
	 this._beginpage(xorientation);
	 this._out("2 J");
	 this.LineWidth=xlw;
	 this._out(lib.sprintf("%.2f w",xlw*this.k));
	if(xfamily)this.SetFont(xfamily,xstyle,xsize);
	 this.DrawColor=xdc;
	if(xdc!="0 G")this._out(xdc);
	 this.FillColor=xfc;
	if(xfc!="0 g")this._out(xfc);
	 this.TextColor=xtc;
	 this.ColorFlag=xcf;
	 this.Header();
	if(this.LineWidth!=xlw)
		{
		 this.LineWidth=xlw;
		 this._out(lib.sprintf("%.2f w",xlw*this.k));
		}
	if(xfamily)this.SetFont(xfamily,xstyle,xsize);
	if(this.DrawColor!=xdc)
		{
		 this.DrawColor=xdc;
		 this._out(xdc);
		}
	if(this.FillColor!=xfc)
		{
		 this.FillColor=xfc;
		 this._out(xfc);
		}
	 this.TextColor=xtc;
	 this.ColorFlag=xcf;
}

this.SetDrawColor=function SetDrawColor(xr , xg , xb)
	{
	if (arguments.length<2) {xg=-1};
	if (arguments.length<3) {xb=-1};

	if((xr==0 && xg==0 && xb==0) || xg==-1)this.DrawColor=lib.sprintf("%.3f G",xr/255);
	else this.DrawColor=lib.sprintf("%.3f %.3f %.3f RG",xr/255,xg/255,xb/255);
	if(this.page>0)this._out(this.DrawColor);
	}

this.SetFillColor=function SetFillColor(xr , xg , xb)
	{
	if (arguments.length<2) {xg=-1};
	if (arguments.length<3) {xb=-1};
	if((xr==0 && xg==0 && xb==0) || xg==-1)this.FillColor=lib.sprintf("%.3f g",xr/255);
	else {this.FillColor=lib.sprintf("%.3f %.3f %.3f rg",xr/255,xg/255,xb/255)};
	 this.ColorFlag=(this.FillColor!=this.TextColor);
	if(this.page>0)this._out(this.FillColor);
	}

this.SetTextColor=function SetTextColor(xr , xg , xb)
	{
	if (arguments.length<2) {xg=-1};
	if (arguments.length<3) {xb=-1};
	if((xr==0 && xg==0 && xb==0) || xg==-1)this.TextColor=lib.sprintf("%.3f g",xr/255);
	else this.TextColor=lib.sprintf("%.3f %.3f %.3f rg",xr/255,xg/255,xb/255);
	this.ColorFlag=(this.FillColor!=this.TextColor);
	}

this.GetStringWidth=function GetStringWidth(xs)
	{
	xcw=this.CurrentFont["cw"];
	xw=0;
	xl=lib.strlen(xs);
	for(xi=0;xi<xl;xi++)xw = xw + (xcw[xs.charAt(xi)]);
	return xw*(this.FontSize)/1000;
	}

this.SetLineWidth=function SetLineWidth(xwidth)
	{
	 this.LineWidth=xwidth;
	if(this.page>0)this._out(lib.sprintf("%.2f w",xwidth*this.k));
	}

this.SetLineStyle=function SetLineStyle(xwidth,xcap,xjoin,xdash,xphase){
	if (arguments.length<1){xwidth=1}
	if (arguments.length<2){xcap=''}
	if (arguments.length<3){xjoin=''}
	if (arguments.length<4){xdash=''}
	if (arguments.length<5){xphase=0}
	xstring = "";
	if (xwidth>0){
		xstring+= xwidth + " w";
	}
	xca = lib.newArray("butt",0,"round",1,"square",2);
	if (xca[xcap]){
		xstring+= " "+xca[xcap]+" J";
	}
	xja = lib.newArray("miter",0,"round",1,"bevel",2);
	if (xja[xjoin]){
		xstring+= " "+xja[xjoin]+" j";
	}
	if (lib.is_array(xdash)){
		xstring+= " [";
		for(xlen in xdash){
		xlen=xdash[xlen]
		xstring+=" "+xlen;
		}
		xstring+= " ] "+xphase+' d';
	}
	xstring += "\n"+xstring;
	this._out(xstring)
}

this.Line=function Line(xx1 , xy1 , xx2 , xy2)
	{
	 this._out(lib.sprintf("%.2f %.2f m %.2f %.2f l S",xx1*this.k,(this.h-xy1)*this.k,xx2*this.k,(this.h-xy2)*this.k));
	}

this.Rect=function Rect(xx , xy , xw , xh , xstyle)
	{
	if (arguments.length<5) {xstyle=""};
	if(xstyle=="F")xop="f";
	else if(xstyle=="FD" || xstyle=="DF")xop="B";
	else
	xop="S";
	 this._out(lib.sprintf("%.2f %.2f %.2f %.2f re %s",xx*this.k,(this.h-xy)*this.k,xw*this.k,-xh*this.k,xop));
	}

this.AddFont=function AddFont(xfamily , xstyle, xfile)
	{
	if (arguments.length<2) {xstyle=""};
	if (arguments.length<3) {xfile=""};
	xfamily=xfamily.toLowerCase();
	if(xfamily=="arial")xfamily="helvetica";
	xstyle=xstyle.toUpperCase();
	if(xstyle=="IB")xstyle="BI";
	if(this.fonts[xfamily + xstyle])this.Error("Font already added: " + xfamily + " " + xstyle);
	if(xfile=="")xfile=lib.str_replace(" ","",xfamily) + xstyle.toLowerCase() + ".js";
	xfile=this.FONTPATH + xfile;
	eval(lib.readtextfile(xfile));
	if(!lib.isset(xname))this.Error("Could not include font definition file");
	xi=lib.count(this.fonts)+1;
	this.fonts[xfamily + xstyle]=lib.newArray("i" , xi,"type" , xtype,"name" , xname,"desc" , xdesc,"up" , xup,"ut" , xut,"cw" , xcw,"enc" , xenc,"file" , xfile);
	if(xdiff)
		{
		xd=0;
		xnb=lib.count(this.diffs);
		for(xi=1;xi<=xnb;xi++)
		if(this.diffs[xi]==xdiff)
			{
			xd=xi;
			break;
			}
			if(xd==0)
				{
				xd=xnb+1;
				this.diffs[xd]=xdiff;
				}
		 this.fonts[xfamily + xstyle]["diff"]=xd;
		}
	if(xfile)
		{
		if(xtype=="TrueType")this.FontFiles[xfile]=lib.newArray("length1" , xoriginalsize);
		else this.FontFiles[xfile]=lib.newArray("length1" , xsize1,"length2" , xsize2);
		}
	}

this.SetFont=function SetFont(xfamily , xstyle , xsize)
	{
	if (arguments.length<2) {xstyle=""};
	if (arguments.length<3) {xsize=0};
	var xfpdf_charwidths=new Array();
	xfamily=xfamily.toLowerCase();
	if(xfamily=="")xfamily=this.FontFamily;
	if(xfamily=="arial")xfamily="helvetica";
	else if(xfamily=="symbol" || xfamily=="zapfdingbats")xstyle="";

	xstyle=xstyle.toUpperCase();
	if(lib.is_int(lib.strpos(xstyle,"U")))
		{
		this.underline=true;
		xstyle=lib.str_replace("U","",xstyle);
		}
	else this.underline=false;

	if(xstyle=="IB")xstyle="BI";
	if(xsize==0)xsize=this.FontSizePt;
	if(this.FontFamily==xfamily && this.FontStyle==xstyle && this.FontSizePt==xsize)return;
	xfontkey=xfamily + xstyle;
	if(!this.fonts[xfontkey])
		{
		if(this.CoreFonts[xfontkey])
			{
			if(!xfpdf_charwidths[xfontkey])
				{
				xfile=xfamily;
				if(xfamily=="times" || xfamily=="helvetica")xfile+=xstyle.toLowerCase();
				xfile=this.FONTPATH + xfile +".js";
				eval(lib.readtextfile(xfile));
				if(!lib.isset(xfpdf_charwidths[xfontkey]))this.Error("Could not include font metric file");
				}
			xi=lib.count(this.fonts)+1;
			 this.fonts[xfontkey]=lib.newArray("i" , xi,"type" , "core","name" , this.CoreFonts[xfontkey],"up" , -100,"ut" , 50,"cw" , xfpdf_charwidths[xfontkey]);
			}
		else
			this.Error("Undefined font: " + xfamily + " " + xstyle);
		}
	 this.FontFamily=xfamily;
	 this.FontStyle=xstyle;
	 this.FontSizePt=xsize;
	 this.FontSize=(xsize)/this.k;
	 this.CurrentFont=this.fonts[xfontkey];
	if(this.page>0)this._out(lib.sprintf("BT /F%d %.2f Tf ET",this.CurrentFont["i"],this.FontSizePt));
	}

this.SetFontSize=function SetFontSize(xsize)
	{
	if(this.FontSizePt==xsize)return;
	 this.FontSizePt=xsize;
	 this.FontSize=(xsize)/this.k;
	if(this.page>0)this._out(lib.sprintf("BT /F%d %.2f Tf ET",this.CurrentFont["i"],this.FontSizePt));
	}

this.AddLink=function AddLink()
	{
	xn=lib.count(this.links)+1;
	 this.links[xn]=new Array(0,0);
	return xn;
	}

this.SetLink=function SetLink(xlink , xy , xpage)
	{
	if (arguments.length<2) {xy=0};
	if (arguments.length<3) {xpage=-1};

	if(xy==-1)xy=this.y;
	if(xpage==-1)xpage=this.page;
	 this.links[xlink]=new Array(xpage,xy);
	}

this.Link=function Link(xx , xy , xw , xh , xlink)
	{
	 if (!lib.is_array(this.PageLinks[this.page]))this.PageLinks[this.page]=new Array()
	 this.PageLinks[this.page][lib.count(this.PageLinks[this.page])]=new Array(xx*this.k,this.hPt-xy*this.k,xw*this.k,xh*this.k,xlink);
	}

this.Text=function Text(xx , xy , xtxt)
	{
	xtxt=lib.str_replace(")","\\)",lib.str_replace("(","\\(",lib.str_replace("\\","\\\\",xtxt)));
	xs=lib.sprintf("BT %.2f %.2f Td (%s) Tj ET",xx*this.k,(this.h-xy)*this.k,xtxt);
	if(this.underline && xtxt!="")xs+=" " + this._dounderline(xx,xy,xtxt);
	if(this.ColorFlag)xs="q " + this.TextColor + " " + xs + " Q";
	 this._out(xs);
	}

this.Cell=function Cell(xw , xh , xtxt , xborder , xln , xalign , xfill , xlink)
	{
	if (arguments.length<2) {xh=0};
	if (arguments.length<3) {xtxt=""};
	if (arguments.length<4) {xborder=0};
	if (arguments.length<5) {xln=0};
	if (arguments.length<6) {xalign=""};
	if (arguments.length<7) {xfill=0};
	if (arguments.length<8) {xlink=""};
	xk=this.k;
	if((this.y)+(xh)>this.PageBreakTrigger && !this.InFooter && this.AcceptPageBreak())
		{
		xx=this.x;
		xws=this.ws;
		if(xws>0)
			{
			 this.ws=0;
			 this._out("0 Tw");
			}
		 this.AddPage(this.CurOrientation);
		 this.x=xx;
		if(xws>0)
			{
			 this.ws=xws;
			 this._out(lib.sprintf("%.3f Tw",xws*xk));
			}
		}
	if(xw==0)xw=this.w-this.rMargin-this.x;
	xs="";
	if(xfill==1 || xborder==1)
		{
		if(xfill==1)xop=(xborder==1)?"B":"f";
		else xop="S";
		xs=lib.sprintf("%.2f %.2f %.2f %.2f re %s ",this.x*xk,(this.h-this.y)*xk,xw*xk,-xh*xk,xop);
		}
	if(lib.is_string(xborder))
		{
		xx=this.x;
		xy=this.y;
		if(lib.is_int(lib.strpos(xborder,"L")))xs+=lib.sprintf("%.2f %.2f m %.2f %.2f l S ",xx*xk,(this.h-xy)*xk,xx*xk,(this.h-(xy+xh))*xk);
		if(lib.is_int(lib.strpos(xborder,"T")))xs+=lib.sprintf("%.2f %.2f m %.2f %.2f l S ",xx*xk,(this.h-xy)*xk,(xx+xw)*xk,(this.h-xy)*xk);
		if(lib.is_int(lib.strpos(xborder,"R")))xs+=lib.sprintf("%.2f %.2f m %.2f %.2f l S ",(xx+xw)*xk,(this.h-xy)*xk,(xx+xw)*xk,(this.h-(xy+xh))*xk);
		if(lib.is_int(lib.strpos(xborder,"B")))xs+=lib.sprintf("%.2f %.2f m %.2f %.2f l S ",xx*xk,(this.h-(xy+xh))*xk,(xx+xw)*xk,(this.h-(xy+xh))*xk);
		}
	if(xtxt!="")
		{
		if(xalign=="R"){xdx=(xw)-(this.cMargin)-(this.GetStringWidth(xtxt))};
		else
		{
		if(xalign=="C") {
			xdx=((xw)-(this.GetStringWidth(xtxt)))/2
		};
		else {xdx=(this.cMargin);}
		}
		xtxt=lib.str_replace(")","\\)",lib.str_replace("(","\\(",lib.str_replace("\\","\\\\",xtxt)));
		if(this.ColorFlag)xs+="q " + this.TextColor + " ";
		xs+=lib.sprintf("BT %.2f %.2f Td (%s) Tj ET",(this.x+xdx)*xk,(this.h-(this.y+ .5*xh+.3*this.FontSize))*xk,xtxt);
		if(this.underline)xs+=" " + this._dounderline(this.x+xdx,this.y+ .5*xh+.3*this.FontSize,xtxt);
		if(this.ColorFlag)xs+=" Q";
		if(xlink)this.Link((this.x)+(xdx),(this.y) + .5*(xh)- + .5*(this.FontSize),this.GetStringWidth(xtxt),(this.FontSize),xlink);
		}
	if(xs!="")this._out(xs);
	this.lasth=xh;
	if(xln>0)
		{
		this.y= this.y + xh ;
		if(xln==1)this.x=this.lMargin;
		}
	else{this.x = this.x + (xw);}
	}

this.MultiCell=function MultiCell(xw , xh , xtxt , xborder , xalign , xfill)
	{
	var xi;
	var xnb;
	var xs;
	var xsep;
	var xi;
	var xj;
	var xl;
	var xns;
	var xnl;
	var xcw;
	var ws;
	if (arguments.length<4) {xborder=0};
	if (arguments.length<5) {xalign="J"};
	if (arguments.length<6) {xfill=0};

	xcw=this.CurrentFont["cw"];
	if(xw==0)xw=this.w-this.rMargin-this.x;
	xwmax=(xw-2*this.cMargin)*1000/this.FontSize;
	xs=lib.str_replace("\r","",xtxt);
	xnb=lib.strlen(xs);
	if(xnb>0 && xs.charAt(xnb-1)=="\n")xnb--;
	xb=0;
	if(xborder)
		{
		if(xborder==1)
			{

			xborder="LTRB";
			xb="LRT";
			xb2="LR";
			}
		else

			{
			xb2="";
			if(lib.is_int(lib.strpos(xborder,"L"))){xb2+="L"};
			if(lib.is_int(lib.strpos(xborder,"R"))){xb2+="R"};
			xb=(lib.is_int(lib.strpos(xborder,"T"))?xb2 + "T":xb2);
			}
		}
	xsep=-1;
	xi=0;
	xj=0;
	xl=0;
	xns=0;
	xnl=1;
	while(xi<xnb)
		{
		xc=xs.charAt(xi);
		if(xc=="\n")
			{
			if(this.ws>0)
				{
				 this.ws=0;
				 this._out("0 Tw");
				}
			 this.Cell(xw,xh,lib.substr(xs,xj,xi-xj),xb,2,xalign,xfill);
			 if (this.Interlinea>0)this.Ln(this.Interlinea);
			xi++;
			xsep=-1;
			xj=xi;
			xl=0;
			xns=0;
			xnl++;
			if(xborder && xnl==2)xb=xb2;
			continue;
			}
		if(xc==" ")
			{
			xsep=xi;
			xls=xl;
			xns++;
			}
		xl+=(xcw[xc])
		if(xl>xwmax)
			{
			if(xsep==-1)
				{
				if(xi==xj)xi++;
				if(this.ws>0)
					{
					 this.ws=0;
					 this._out("0 Tw");
					}
				 this.Cell(xw,xh,lib.substr(xs,xj,xi-xj),xb,2,xalign,xfill);
				 if (this.Interlinea>0)this.Ln(this.Interlinea);
				}
			else

				{
				if(xalign=="J")
					{
					 this.ws=(xns>1)?((xwmax)-(xls))/1000*(this.FontSize)/((xns)-1):0;
					 this._out(lib.sprintf("%.3f Tw",(this.ws)*this.k));
					}

				 this.Cell(xw,xh,lib.substr(xs,xj,xsep-xj),xb,2,xalign,xfill);
				 if (this.Interlinea>0)this.Ln(this.Interlinea);
				 xi=xsep+1;
				}
			xsep=-1;
			xj=xi;
			xl=0;
			xns=0;
			xnl++;
			if(xborder && xnl==2){xb=xb2;};
			}
		else
			xi++;
		}
	if(this.ws>0)
		{
		 this.ws=0;
		 this._out("0 Tw");
		}
	if(xborder && lib.is_int(lib.strpos(xborder,"B")))xb+="B";
	 this.Cell(xw,xh,lib.substr(xs,xj,xi),xb,2,xalign,xfill);
	 if (this.Interlinea>0)this.Ln(this.Interlinea);
	 this.x=this.lMargin;
	}

this.Write=function Write(xh , xtxt , xlink)
	{
	var xi;
	if (arguments.length<3) {xlink=""};

	xcw=this.CurrentFont["cw"];
	xw=(this.w)-(this.rMargin)-(this.x);
	xwmax=(xw-2*this.cMargin)*1000/this.FontSize;
	xs=lib.str_replace("\r","",xtxt);
	xnb=lib.strlen(xs);
	xsep=-1;
	xi=0;
	xj=0;
	xl=0;
	xnl=1;
	while(xi<xnb)
		{
		xc=xs.charAt(xi)
		if(xc=="\n")
			{
			this.Cell(xw,xh,lib.substr(xs,xj,xi-xj),0,2,"",0,xlink);
			xi++;
			xsep=-1;
			xj=xi;
			xl=0;
			if(xnl==1)
				{
				 this.x=this.lMargin;
				xw=this.w-this.rMargin-this.x;
				xwmax=(xw-2*this.cMargin)*1000/this.FontSize;
				}
			xnl++;
			continue;
			}
		if(xc==" ")
			{
			xsep=xi;
			xls=xl;
			}

		xl+=(xcw[xs.charAt(xc)]);
		if(xl>xwmax)
			{
			if(xsep==-1)
				{
				if(this.x>this.lMargin)
					{
					 this.x=this.lMargin;
					 this.y+=xh;
					xw=this.w-this.rMargin-this.x;
					xwmax=(xw-2*this.cMargin)*1000/this.FontSize;
					xi++;
					xnl++;
					continue;
					}
				if(xi==xj)xi++;
				 this.Cell(xw,xh,lib.substr(xs,xj,xi-xj),0,2,"",0,xlink);
				}
			else

				{
				 this.Cell(xw,xh,lib.substr(xs,xj,xsep-xj),0,2,"",0,xlink);
				xi=xsep+1;
				}
			xsep=-1;
			xj=xi;
			xl=0;
			if(xnl==1)
				{
				 this.x=this.lMargin;
				xw=this.w-this.rMargin-this.x;
				xwmax=(xw-2*this.cMargin)*1000/this.FontSize;
				}
			xnl++;
			}
		else {xi++}
		}
	if(xi!=xj)this.Cell(xl/1000*this.FontSize,xh,lib.substr(xs,xj,xi),0,0,"",0,xlink);
	}

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);
	}

this.Ln=function Ln(xh)
	{
	if (arguments.length<1) {xh=""};

	 this.x=this.lMargin;
	if(lib.is_string(xh))this.y+=this.lasth;
	else
		this.y+=xh;
	}
this.GetX=function GetX(){return this.x;}
this.SetX=function SetX(xx)
	{
	if(xx>=0)this.x=xx;
	else
		this.x=this.w+xx;
	}
this.GetY=function GetY(){return this.y;}
this.SetY=function SetY(xy)
	{
	this.x=this.lMargin;
	if(xy>=0)this.y=xy;
	else
		this.y=this.h+xy;
	}
this.SetXY=function SetXY(xx , xy)
	{
	 this.SetY(xy);
	 this.SetX(xx);
	}
this.Output=function Output(xfile , xdownload , Overwrite)
	{
	if (arguments.length<3) {
	Overwrite=true;
		if (arguments.length<2) {
			xdownload=false;
			if (arguments.length<1){xfile=""};
		}
	}
	;
	if(this.state<3)this.Close();
	if(xfile==""){
		if(xdownload){
					Response.ContentType = "application/octet-stream";
					Response.AddHeader("Content-disposition", "attachment; filename=" + xfile);
				}
				else
				{
					Response.ContentType = "application/pdf"
					Response.AddHeader("Content-Disposition","inline");
				}
		if (!this.hasBinary){
			Response.Write(this.buffer)}
		else{
			xfile=Server.MapPath(lib.fso.GetTempName())
			xf=lib.fopen(xfile,"wb");
			if(xf.number)this.Error("Unable to create output file: " + xfile);
			lib.fwrite(xf,this.buffer);
			lib.fclose(xf);
			outB = Server.CreateObject("ADODB.Stream")
			outB.Type = 1
			outB.Open()
			outB.LoadFromFile (xfile)
			Response.BinaryWrite(outB.Read())
			outB.Close()
			lib.fso.DeleteFile(xfile);
			}
	}
		else

			{
			xf=lib.fopen(xfile,"wb");
			if(xf.number)this.Error("Unable to create output file: " + xfile);
			lib.fwrite(xf,this.buffer);
			lib.fclose(xf);
			}
	}

this.clearBuffer=function clearBuffer(){this.buffer='';}

this._begindoc=function _begindoc()
	{
	 this.state=1;
	 this._out("%PDF-1.3");
	}

this._putpages=function _putpages()
	{
	xnb=this.page;
	if(!lib.empty(this.AliasNbPages))
		{
		for(xn=1;xn<=xnb;xn++)this.pages[xn]=lib.str_replace(this.AliasNbPages,xnb,this.pages[xn]);
		}
	if(this.DefOrientation=="P")
		{
		xwPt=this.fwPt;
		xhPt=this.fhPt;
		}
	else

		{
		xwPt=this.fhPt;
		xhPt=this.fwPt;
		}
	xfilter=(this.compress)?"/Filter /FlateDecode ":
	"";
	for(xn=1;xn<=xnb;xn++)
		{
		 this._newobj();
		 this._out("<</Type /Page");
		 this._out("/Parent 1 0 R");
		if(lib.isset(this.OrientationChanges[xn]))this._out(lib.sprintf("/MediaBox [0 0 %.2f %.2f]",xhPt,xwPt));
		 this._out("/Resources 2 0 R");
		if(this.PageLinks[xn])
			{
			xannots="/Annots [";
			for(xpl in this.PageLinks[xn])
				{
				xpl = this.PageLinks[xn][xpl]
				xrect=lib.sprintf("%.2f %.2f %.2f %.2f",xpl[0],xpl[1],xpl[0]+xpl[2],xpl[1]-xpl[3]);
				xannots+="<</Type /Annot /Subtype /Link /Rect [" + xrect + "] /Border [0 0 0] ";
				if(lib.is_string(xpl[4]))xannots+="/A <</S /URI /URI " + this._textstring(xpl[4]) + ">>>>";
				else
					{
					xl=this.links[xpl[4]];
					xh=(this.OrientationChanges[xl.charAt(0)]?xwPt:xhPt);
					xannots+=lib.sprintf("/Dest [%d 0 R /XYZ 0 %.2f null]>>",1+2*xl[0],xh-xl[1]*this.k);
					}
				}
			 this._out(xannots + "]");
			}
		 this._out("/Contents " + (this.n+1) + " 0 R>>");
		 this._out("endobj");
		 xp=(this.compress)?this.gzcompress(this.pages[xn]):
		 this.pages[xn];
		 this._newobj();
		 this._out("<<" + xfilter + "/Length " + lib.strlen(xp) + ">>");
		 this._putstream(xp);
		 this._out("endobj");
		}
	 this.offsets[1]=lib.strlen(this.buffer);
	 this._out("1 0 obj");
	 this._out("<</Type /Pages");
	xkids="/Kids [";
	for(xi=0;xi<xnb;xi++)xkids+=(3+2*xi) + " 0 R ";
	 this._out(xkids + "]");
	 this._out("/Count " + xnb);
	 this._out(lib.sprintf("/MediaBox [0 0 %.2f %.2f]",xwPt,xhPt));
	 this._out(">>");
	 this._out("endobj");
	}

this._putfonts=function _putfonts()
	{
	xnf=this.n;
	for(xdiff in this.diffs)
		{
		xdiff = this.diffs[xdiff]
		this._newobj();
		this._out("<</Type /Encoding /BaseEncoding /WinAnsiEncoding /Differences [" + xdiff + "]>>");
		this._out("endobj");
		}
	for(xfile  in this.FontFiles)
		{
		xinfo = this.FontFiles[xfile]
		this._newobj();
		this.FontFiles[xfile]["n"]=this.n;
		xfile=this.FONTPATH + xfile;
		xsize=lib.filesize(xfile);
		if(!xsize)this.Error("Font file not found");
		this._out("<</Length " + xsize);
		if(lib.substr(xfile,-2)==".z")this._out("/Filter /FlateDecode");
		this._out("/Length1 " + xinfo["length1"]);
		if(lib.isset(xinfo["length2"]))this._out("/Length2 " + xinfo["length2"] + " /Length3 0");
		this._out(">>");
		this.hasBinary = true
		this._putstream(lib.readbinfile(xfile),-1);
		this._out("endobj");
		}
	for(xk  in this.fonts)
		{
		 xfont = this.fonts[xk]
		 this._newobj();
		 this.fonts[xk]["n"]=this.n;
		xname=xfont["name"];
		 this._out("<</Type /Font");
		 this._out("/BaseFont /" + xname);
		if(xfont["type"]=="core")
			{
			 this._out("/Subtype /Type1");
			if(xname!="Symbol" && xname!="ZapfDingbats")this._out("/Encoding /WinAnsiEncoding");
			}
		else

			{
			 this._out("/Subtype /" + xfont["type"]);
			 this._out("/FirstChar 32");
			 this._out("/LastChar 255");
			 this._out("/Widths " + (this.n+1) + " 0 R");
			 this._out("/FontDescriptor " + (this.n+2) + " 0 R");
			if(xfont["enc"])
				{
				//debug(xfont["diff"])
				if(xfont["diff"])this._out("/Encoding " + (xnf+xfont["diff"]) + " 0 R");
				else this._out("/Encoding /WinAnsiEncoding");
				}
			}
		 this._out(">>");
		 this._out("endobj");
		if(xfont["type"]!="core")
			{
			this._newobj();
			xcw=xfont["cw"];
			xs="[";

			for(xi=32;xi<=255;xi++)
			{
				xs+= xcw[string.fromCharCode(xi)] + " ";
			}
			this._out(xs + "]");
			this._out("endobj");
			this._newobj();
			xs="<</Type /FontDescriptor /FontName /" + xname;
			for(xk  in xfont["desc"])
			{
			xv=xfont["desc"][xk];
			xs += " /" + xk + " " +xv;
			}
			xfile=xfont["file"];
			if(xfile)xs+=" /FontFile" + (xfont["type"]=="Type1"?"":"2") + " " + this.FontFiles[xfile]["n"] + " 0 R";
			 this._out(xs + ">>");
			 this._out("endobj");
			}
		}
	}


this._putimages=function _putimages()
	{
	xfilter=(this.compress)?"/Filter /FlateDecode ":"";
	for(xfile  in this.images)
		{
		 xinfo = this.images[xfile]

		 this._newobj();
		 this.images[xfile]["n"]=this.n;
		 this._out("<</Type /XObject");
		 this._out("/Subtype /Image");
		 this._out("/Width " + xinfo["w"]);
		 this._out("/Height " + xinfo["h"]);
		if(xinfo["cs"]=="Indexed")
			{
			this._out("/ColorSpace [/indexed /DeviceRGB " + (lib.strlen(xinfo["pal"])/3-1) + " " + (this.n+1) + " 0 R]");
			}
		else
			{
			 this._out("/ColorSpace /" + xinfo["cs"]);
			if(xinfo["cs"]=="DeviceCMYK")this._out("/Decode [1 0 1 0 1 0 1 0]");
			}

		 this._out("/BitsPerComponent " + xinfo["bpc"]);
		 this._out("/Filter /" + xinfo["f"]);
		if(lib.isset(xinfo["parms"]))this._out(xinfo["parms"]);
		if(lib.isset(xinfo["trns"]) && lib.is_array(xinfo["trns"]))
			{
			xtrns="";
			for(xi=0;xi<lib.count(xinfo["trns"]);xi++)xtrns+=xinfo["trns"][xi] + " " + xinfo["trns"][xi] + " ";
			 this._out("/Mask [" + xtrns + "]");
			}
		 this._out("/Length " + xinfo["size"] + ">>");
		 this._putstream(xinfo["data"]);
		 this.hasBinary = true;
		 this._out("endobj");
		if(xinfo["cs"]=="Indexed")
			{
			 this._newobj();
			xpal=(this.compress)?gzcompress(xinfo["pal"]):
			xinfo["pal"];
			 this._out("<<" + xfilter + "/Length " + lib.strlen(xpal) + ">>");
			 this._putstream(xpal);
			 this._out("endobj");
			}
		}
	}

this._putresources=function _putresources()
	{
	this._putfonts();
	this._putimages();
	this.offsets[2]=lib.strlen(this.buffer);
	this._out("2 0 obj");
	this._out("<</ProcSet [/PDF /Text /ImageB /ImageC /ImageI]");
	this._out("/Font <<");
	for(xfont in this.fonts)
	{
	xfont = this.fonts[xfont]
	this._out('/F'+ xfont['i'] + ' ' + xfont['n'] + ' 0 R');
	}
	this._out(">>");
	if(lib.count(this.images))
		{
		 this._out("/XObject <<");
		for(ximage in this.images)
		 ximage = this.images[ximage]
		 this._out("/I" + ximage["i"] + " " + ximage["n"] +" 0 R");
		 this._out(">>");
		}
	 this._out(">>");
	 this._out("endobj");
	}

this._putinfo=function _putinfo()
	{
	 this._out("/Producer " + this._textstring("FPDF for ASP v." + this.Version + " by Lorenzo Abbati [www.aspxnet.it]"));
	if(!lib.empty(this.title))this._out("/Title " + this._textstring(this.title));
	if(!lib.empty(this.subject))this._out("/Subject " + this._textstring(this.subject));
	if(!lib.empty(this.author))this._out("/Author " + this._textstring(this.author));
	if(!lib.empty(this.keywords))this._out("/Keywords " + this._textstring(this.keywords));
	if(!lib.empty(this.creator))this._out("/Creator " + this._textstring(this.creator));
	 this._out("/CreationDate " + this._textstring("D:" + lib.date("YmdHis")));
	}

this._putcatalog=function _putcatalog()
	{
	 this._out("/Type /Catalog");
	 this._out("/Pages 1 0 R");
	if(this.ZoomMode=="fullpage")this._out("/OpenAction [3 0 R /Fit]");
	else if(this.ZoomMode=="fullwidth")this._out("/OpenAction [3 0 R /FitH null]");
	else if(this.ZoomMode=="real")this._out("/OpenAction [3 0 R /XYZ null null 1]");
	else if(!is_string(this.ZoomMode))this._out("/OpenAction [3 0 R /XYZ null null " + (this.ZoomMode/100) + "]");
	if(this.LayoutMode=="single")this._out("/PageLayout /SinglePage");
	else if(this.LayoutMode=="continuous")this._out("/PageLayout /OneColumn");
	else if(this.LayoutMode=="two")this._out("/PageLayout /TwoColumnLeft");
	}

this._puttrailer=function _puttrailer()
	{
	 this._out("/Size " + (this.n+1));
	 this._out("/Root " + this.n + " 0 R");
	 this._out("/Info " + (this.n-1) + " 0 R");
	}

this._enddoc=function _enddoc()
	{
	 this._putpages();
	 this._putresources();
	 this._newobj();
	 this._out("<<");
	 this._putinfo();
	 this._out(">>");
	 this._out("endobj");
	 this._newobj();
	 this._out("<<");
	 this._putcatalog();
	 this._out(">>");
	 this._out("endobj");
	xo=lib.strlen(this.buffer);
	 this._out("xref");
	 this._out("0 " + (this.n+1));
	 this._out("0000000000 65535 f ");
	for(xi=1;xi<=this.n;xi++)this._out(lib.sprintf("%010d 00000 n ",this.offsets[xi]));
	 this._out("trailer");
	 this._out("<<");
	 this._puttrailer();
	 this._out(">>");
	 this._out("startxref");
	 this._out(xo);
	 this._out("%%EOF");
	 this.state=3;
	}

this._beginpage=function _beginpage(xorientation)
	{
	 this.page++;
	 this.pages[this.page]="";
	 this.state=2;
	 this.x=this.lMargin;
	 this.y=this.tMargin;
	 this.lasth=0;
	 this.FontFamily="";
	if(!xorientation)xorientation=this.DefOrientation;
	else
		{
		//xorientation=lib.strtoupper(xorientation)
		if(xorientation!=this.DefOrientation)this.OrientationChanges[this.page]=true;
		}

	if(xorientation!=this.CurOrientation)
		{
		if(xorientation=="P")
			{
			 this.wPt=this.fwPt;
			 this.hPt=this.fhPt;
			 this.w=this.fw;
			 this.h=this.fh;
			}
		else

			{
			 this.wPt=this.fhPt;
			 this.hPt=this.fwPt;
			 this.w=this.fh;
			 this.h=this.fw;
			}
		 this.PageBreakTrigger=this.h-this.bMargin;
		 this.CurOrientation=xorientation;
		}
	}

this._endpage=function _endpage(){this.state=1;}

this._newobj=function _newobj()
	{
	 this.n++;
	 this.offsets[this.n]=lib.strlen(this.buffer);
	 this._out(this.n + " 0 obj");
	}

this._dounderline=function _dounderline(xx , xy , xtxt)
	{
	xup=this.CurrentFont["up"];
	xut=this.CurrentFont["ut"];
	xw=this.GetStringWidth(xtxt)+this.ws*lib.substr_count(xtxt," ");
	return lib.sprintf("%.2f %.2f %.2f %.2f re f",xx*this.k,(this.h-(xy-xup/1000*this.FontSize))*this.k,xw*this.k,-xut/1000*this.FontSizePt);
	}

this._parsejpg=function _parsejpg(xfile)
	{
	xa= new cImage();
	xa.Open(xfile);
	if(!xa)this.Error("Missing or incorrect image file: " + xfile);
	if(xa["id"]!=2)this.Error("Not a JPEG file: " + xfile);
	if(!lib.isset(xa["channels"]) || xa["channels"]==3)xcolspace="DeviceRGB";
	else if(xa["channels"]==4)xcolspace="DeviceCMYK";
	else xcolspace="DeviceGray";
	xbpc=(xa["bits"]?xa["bits"]:8);
	xdata=xa.GetBuffer()
	size=xa.size;
	xa.Close();
	return lib.newArray("w" , xa["width"] ,"h" , xa["height"],"cs" , xcolspace,"bpc" , xbpc,"f" , "DCTDecode","data" , xdata,"size",size);
	}

this._textstring=function _textstring(xs){return "(" + this._escape(xs) + ")";}

this._escape=function _escape(xs){
	return lib.str_replace(")","\\)",lib.str_replace("(","\\(",lib.str_replace("\\","\\\\",xs)));
}

this._putstream=function _putstream(xs)
	{
	 this._out("stream");
	 this._out(xs);
	 this._out("endstream");
	}

this._out=function _out(xs,isBinary)
	{
	if(this.state==2)
		{this.pages[this.page]+=xs + "\n";}
	else
		{
		this.buffer+=xs + "\n";
		}
	}

this.GetBuffer=function GetBuffer(){
	return this.buffer;
}

this.GetMargin=function GetMargin(s){
	if (arguments.length<1){s="l";}
	else{s = s.toLowerCase();}
	switch(s){
		case "l":
		case "left":
			return this.lMargin;
		case "r":
		case "right":
			return this.rMargin;
		case "b":
		case "bottom":
			return this.bMargin;
		case "t":
		case "top":
			return this.tMargin;
	}
}

this._LoadExtension=function _LoadExtension(path){
	eval(lib.readtextfile(path));
}

this.LoadExtension=function LoadExtends(path){
	this._LoadExtension(this.EXTENDSPATH +path+".ext");
}
this.LoadModels=function LoadModels(path){
	this._LoadExtension(this.MODELSPATH +path+".mod");
}
this.ExtendsCode=function ExtendsCode(AddTo,CodeAdd){
	Code = new String(eval("this." + AddTo));
	CodeAdd = new String(CodeAdd);
	pI = CodeAdd.indexOf("{")+1;pE = CodeAdd.lastIndexOf("}")
	sToAdd = CodeAdd.substring(pI,pE)
	pE = Code.lastIndexOf("}")
	eval("this." + AddTo + "=" + Code.substring(0,pE) + "\n" + sToAdd +"}");
}
}

</script>

 

basics.asp

<!--#include File="images.asp"-->
<!--#include File="math.asp"-->
<script language="javascript" runat="server">


function CreateJsObject(s){return eval('new '+s);}
function cfile(){this.obj;this.mode;this.isBinary=false;}
function clib(){
this.fso = new ActiveXObject("Scripting.FileSystemObject");
this.empty=function empty(s){
if (s==''||s=='undefined')return true
else return false;
;}
this.ord=function ord(ch){return ch.charCodeAt(0)}
this.count=function count(ar){var i=0;for (k in ar){i++}return i;}
this.strlen=function strlen(s){s1 = new String(s);return s1.length;}
this.chr=function chr(value){return String.fromCharCode(value)}
this.die=function die(s){Response.Write("<font style='font.size:11;font-family:verdana'>" + s +"</font>");Response.End}
this.basename=function basename(s){
i=s.lastIndexOf("/")
if(i<0){i=0}
return s.substring(i,s.length)
}
this.fopen=function fopen(name,params){
switch(params.charAt(0)){
	case "r" : v = 1;c=false;p=Server.MapPath(name);break;
	case "w" : v = 2;c=true;p=name;break;
	case "a" : v = 8;c=true;p=Server.MapPath(name);break;
}
var f = new cfile();
try{
f.obj=this.fso.OpenTextFile(p,v,c);
}
catch(e){return e;}
f.mode=params.charAt(0);
if (params.length>1){if (params.charAt(1)=="b"){f.isBinary = true}};
return f;
}

this.eregi=function eregi(r,s){
re = new RegExp(r,"gi")
return re.test(s)
}

this.explode=function explode(ch,svalue,limit){
var s=new String(svalue)
if(arguments.length=2){return s.split(ch)}
else{return s.split(ch,limit)}
}

this.ltrim=function ltrim(s) {
return s.replace(/^\s+/,"");
}
this.trim=function trim(s) {
//debug(s)
ns = new String(s)
return ns.replace(/\s+$|^\s+/g,"");
}
this.rtrim=function rtrim(s) {
ns = new String(s)
return ns.replace(/\s+$/,"");
}

this.file=function file(path){
   	var f
   	var ar = new Array()
   	try{
   	f = this.fso.OpenTextFile(Server.MapPath(path), 1);
   	while (!f.atEndOfStream){
   		ar[ar.length] =  f.ReadLine();
	}
f.close()
return ar;
}
catch(e){this.die("Error, path not found : "+path) }
}

this.fwrite=function fwrite(f,buffer){
try{f.obj.write(buffer)}
catch(e){return e.number;}
return true;
}

this.fread=function fread(f,nch){
try{f.obj.read(nch)}
catch(e){return e.number;}
return true;
}

this.fclose=function fclose(f){
try{f.obj.close()}
catch(e){return e.number;}
return true;
}

this.substr=function substr(){
var i;var s;
s = new String(arguments[0])
if (arguments.length==2){
	e=s.length;
	i=(arguments[1]<0?s.length+arguments[1]:arguments[1])
	}
else{
	i=arguments[1]
	e=(arguments[2]<0?s.length+arguments[2]:arguments[2])
	}

return s.substr(i,e)
}
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}
}
this.is_int=function is_int(v){
try{
res=!isNaN(parseInt(v))
}
catch(e){res=false}
return res;
}
this.is_string=function is_string(s){
try{
res=isNaN(parseInt(s))}
catch(e){res=false}
return res;
}
this.is_array=function is_array(o){
try{t=(o.constructor==Array);}
catch(e){t=false}
finally{return t}
}
this.date=function date(s){
var i;
r="";var d = new Date();
for(i=0;i<s.length;i++){
switch(s.charAt(i)){
	case "Y" : {
		r = r + d.getFullYear();
		break;}
	case "m":{
		r = r + d.getMonth()+1;
		break;}
	case "d":{
		r = r + d.getDay();
		break;}
	case "H":{
		r = r + d.getHours();
		break;}
	case "i":{
		r = r + d.getMinutes();
		break;}
	case "s":{
		r = r + d.getSeconds();
		break;}
	}
}
return r;
}
this.str_replace=function str_replace(psearchText,preplaceText,poriginalString){

searchText=new String(psearchText)
replaceText=new String(preplaceText)
originalString=new String(poriginalString)

var strLength = originalString.length;
var txtLength = searchText.length;
if ((strLength == 0) || (txtLength == 0))
{ return originalString; }
var i = originalString.indexOf(searchText);
if ((!i) && (searchText != originalString.substring(0,txtLength)))
{ return originalString; }
if (i == -1)
{ return originalString; }
var newstr = originalString.substring(0,i) + replaceText;
if (i+txtLength < strLength) { newstr += this.str_replace(searchText,replaceText,originalString.substring(i+txtLength,strLength)); }
return newstr;
}

this.str_replace1=function str_replace1(psearchText,preplaceText,poriginalString){
originalString=new String(poriginalString)
s = 'new RegExp("' + psearchText + '","gi")'
Response.Write(s);
Response.End;
re = eval(s);
return originalString.replace(re,preplaceText)
}
this.substr_count=function substr_count(s,ch){
ar = s.split(ch);
return ar.length;
}
this.isset=function isset(s){if(s){return true}else{return false}}
this.function_exists=function function_exists(s){
if(s="gzcompress"){return false};
}
this.gzcompress=function gzcompress(){Response.Write("gzcom");Response.End;}
this.getimagesize=function getimagesize(){Response.Write("getimagesize");Response.End;}
this.imagesx=function imagesx(){Response.Write("imagex");Response.End;}
this.imagesy=function imagesy(){Response.Write("imagey");Response.End;}
this.tempnam=function tempnam(){Response.Write("temname");Response.End;}
this.imagejpeg=function imagejpeg(){Response.Write("imagjpg");Response.End;}
this.scalar_array=function scalar_test(ar){
var i;
s='ar';tmp='';
for(i=0;i<arguments.length;i++){
		if(i==0){s="ar";}
		else
		{
		tmp = ( typeof(arguments[i])=="number" ? arguments[i] : "\"" + arguments[i] +"\"");
		s +=  "[" + tmp + "]" ;
		}
		o=eval(s);
		if (!this.is_array(o)){
			eval(s + "=new Array()");
		}
}
return;
}
this.newArray=function newArray(){
var i;
var ar=new Array();
for(i=0;i<arguments.length;i++){
	ar[arguments[i]]=arguments[i+1];i=i+1
}
return ar;
}
this.file_exists=function file_exists(path){
   	res = this.fso.FileExists(Server.MapPath(path))
   	return res;
}

this.readtextfile=function readtextfile(path){
   	var f,res
   	if (this.file_exists(path)){
   	f = this.fso.OpenTextFile(Server.MapPath(path), 1);
   	res = f.ReadAll();
f.close()
}
else{die("Path Not Found : "+Server.MapPath(path))}
return res;
}

this.readbinfile=function readbinfile(path){
   	var f,res;
   	f = Server.CreateObject("ADODB.Stream");
   	f.CharSet ="ISO-8859-1";
   	f.Type=2
 	f.Open()
 	f.LoadFromFile(Server.MapPath(path))
 	f.Position=0
   	res = f.ReadText();
f.Close()
return res;
}

this.filesize=function filesize(path){
   	if(!this.file_exists(path)){return false;}
   	return this.fso.getFile(Server.MapPath(path)).size;
}

this.printf = function printf(format) {
  document.write(_spr(format, arguments));
}


this.sprintf=function sprintf(format) {
  return _spr(format, arguments);
}

this.SaveToFile=function SaveToFile(filename,buffer){
var f;
f=this.fso.OpenTextFile(Server.MapPath(filename),2,true)
f.write(buffer);
f.close();
}

this._spr=function _spr(format, args) {
  function isdigit(c) {
     return (c <= "9") && (c >= "0");
  }

  function rep(c, n) {
     var s = "";
     while (--n >= 0)
        s += c;
     return s;
  }

  var c;
  var i, ii, j = 1;
  var retstr = "";
  var space = " ";


  for (i = 0; i < format.length; i++) {
     var buf = "";
     var segno = "";
     var expx = "";
     c = format.charAt(i);
     if (c == "\n") {
        c = "<br>";
     }
     if (c == "%") {
        i++;
        leftjust = false;
        if (format.charAt(i) == '-') {
           i++;
           leftjust = true;
        }
        padch = ((c = format.charAt(i)) == "0") ? "0" : space;
        if (c == "0")
           i++;
        field = 0;
        if (isdigit(c)) {
           field = parseInt(format.substring(i));
           i += String(field).length;
        }

        if ((c = format.charAt(i)) == '.') {
           digits = parseInt(format.substring(++i));
           i += String(digits).length;
           c = format.charAt(i);
        }
        else
           digits = 0;

        switch (c.toLowerCase()) {
           case "x":
              buf = args[j++].toString(16);
              break;
           case "e":
              expx = -1;
           case "f":
           case "d":
              if (args[j] < 0) {
                 args[j] = -args[j];
                 segno = "-";
                 field--;
              }
              if (expx != "") {
                 with (Math)
                    expx = floor(log(args[j]) / LN10);
                 args[j] /= Number("1E" + expx);
                 field -= String(expx).length + 2;
              }
              var x = args[j++];
              for (ii=0; ii < digits && x - Math.floor(x); ii++)
                 x *= 10;

              x = String(Math.round(x));

              x = rep("0", ii - x.length + 1) + x;

              buf += x.substring(0, x.length - ii);

              if (digits > 0)
                 buf += "." + x.substring(x.length - ii) + rep("0", digits - ii);
              if (expx != "") {
                 var expsign = (expx >= 0) ? "+" : "-";
                 expx = Math.abs(expx) + "";
                 buf += c + expsign + rep("0", 3 - expx.length) + expx;
              }
              break;
           case "o":
              buf = args[j++].toString(8);
              break;
           case "s":
              buf = args[j++];
              break;
           case "c":
              buf = args[j++].substring(0, 1);
              break;
           default:
              retstr += c;
        }
        field -= buf.length;
        if (!leftjust) {
           if (padch == space)
              retstr += rep(padch, field) + segno;
           else
              retstr += segno + rep("0", field);
        }
        retstr += buf;
        if (leftjust)
           retstr += rep(space, field);
     }
     else
        retstr += c;
  }
  return retstr;
}
}
</script>

 

images.asp

<script language="jscript" runat="server">

function cImage(){

this.Buffer;
this.width=-1;
this.height=-1;
this.mime="";
this.channels;
this.bits;
this.size=-1;
this.extension;
this.id;

this.Open=function Open(pFileName){
this.FileName = pFileName
this.Buffer=Server.CreateObject("ADODB.Stream");
this.Buffer.CharSet ="ISO-8859-1";
this.Buffer.Type = 2
this.Buffer.Open()
//Response.Write(Server.MapPath(pFileName));Response.End;
this.Buffer.LoadFromFile(Server.MapPath(pFileName));
this.Buffer.Position = 0
this.size=this.Buffer.Size;
this.extension = pFileName.substring(pFileName.lastIndexOf(".")+1).toLowerCase();

this.mime = this.GetMimeType(this.extension);
	switch(this.mime){
		case "image/jpeg":this._parseJpeg();
	}
}

this.GetMimeType=function GetMimeType(ext){
	switch(ext){
		case "jpg":
		case "jpeg":
			return "image/jpeg";
		case "png":
			return "image/png";
	}
}

function toAscii(code){
	//debug(code)
	switch(code){
		case 8364: code=128;break;
		case 8218: code=130;break;
		case 402: code=131;break;
		case 8222: code=132;break;
		case 8230: code=133;break;
		case 8224: code=134;break;
		case 8225: code=135;break;
		case 710: code=136;break;
		case 8240: code=137;break;
		case 352: code=138;break;
		case 8249: code=139;break;
		case 338: code=140;break;
		case 381: code=142;break;
		case 8216: code=145;break;
		case 8217: code=146;break;
		case 8220: code=147;break;
		case 8221: code=148;break;
		case 8226: code=149;break;
		case 8211: code=150;break;
		case 8212: code=151;break;
		case 732: code=152;break;
		case 8482: code=153;break;
		case 353: code=154;break;
		case 8250: code=155;break;
		case 339: code=156;break;
		case 382: code=158;break;
		case 376: code=159;break;
		default:
			Response.Write("Error ascii code : " + code);
			Response.End
	}
	return code;
}

this.Read=function Read(nB,radix){
	var res=""
	if (arguments.length<2){radix=16;}
	else if (radix=="string"){return this.Buffer.ReadText(nB);}
	for(i=1;i<=nB;i++){
			ch = this.Buffer.ReadText(1).charCodeAt(0)
			if (ch>255)ch=toAscii(ch)
			ch = ch.toString(16)
			if (ch.length==1)ch = "0" + ch
			res += ch
		}
	if (radix!=16){
		res = res.toString(radix);
		if (radix==10){res = parseInt(res,16)}
		else if (radix==2){
			if (res.length!=nB*8){
				s = "";for (i=0;i<nB*8-res.length;i++){s+="0"}
				res = s + res;
			}
		}
	}
	return res;
}

this._parseJpeg = function _parseJpeg(){
	var TEM = 0x01;	var SOF = 0xc0;	var DHT = 0xc4;	var JPGA= 0xc8
	var DAC = 0xcc;	var RST = 0xd0;	var SOI = 0xd8;	var EOI = 0xd9
	var SOS = 0xda;	var DQT = 0xdb;	var DNL = 0xdc;	var DRI = 0xdd
	var DHP = 0xde;	var EXP = 0xdf;var APP = 0xe0;	var JPG = 0xf0
	var COM = 0xfe; var marker=0;var length;
	this.id=2;
	if (this.Read(1,10)==0xff){
		while(!this.Buffer.EOS){
		marker = this.Read(1,10)
		while (marker==0xff){marker = this.Read(1,10)}
		switch(marker){
			case DHP:case SOF+0:case SOF+1:case SOF+2:case SOF+3:case SOF+5:
			case SOF+6:case SOF+7:case SOF+9:case SOF+10:case SOF+11:case SOF+13:case SOF+14:case SOF+15:
					length = this.Read(2,10)
					this.bits		= this.Read(1,10)
					this.height		= this.Read(2,10)
					this.width		= this.Read(2,10)
					this.channels	= this.Read(1,10)
					return;
			case APP+0:	case APP+1:	case APP+2:	case APP+3:case APP+4:	case APP+5:	case APP+6:	case APP+7:
			case APP+8:	case APP+9:	case APP+10:case APP+11:case APP+12:case APP+13:case APP+14:case APP+15:
			case DRI:case SOS:	case DHT:case DAC:case DNL:case EXP:
				h=this.Read(2,10)-2
				this.Buffer.Position +=  h;
				break;
			}
		}
	}
}

this._parsePng = function _parsePng(){

}

this.GetBuffer=function GetBuffer(){
	this.Buffer.Position=0
	return this.Buffer.ReadText()
}

this.Close=function Close(){
	this.Buffer.Close();
}

}
</script>




 

math.asp

<script language="javascript" runat="server">
Math.hexdec = function(sHexNum) {return  parseInt(sHexNum, 16);}
Math.bindec = function(lBinaryNum) {return parseInt(lBinaryNum.toString(), 2);}
Math.deg2rad = function(fDegrees) {return  ((2 * Math.PI) / 360) * fDegrees;}
Math.dechex = function(lDecimalNum) {return lDecimalNum.toString(16);}
Math.getHex = function getHex(num){
  hexStr = "0123456789ABCDEF";
  hex="";
  if (num>=16) {
     hex = hexStr.substr(parseInt(num/16),1);
     num = num%16;
  }
  hex += hexStr.substr(num,1);

  return hex;
}
String.prototype.hexCodeAt = function(index) {
return eval("0x" + this.charCodeAt(0).toString(16));
}
</script>

Compartilhar este post


Link para o post
Compartilhar em outros sites

Olá xanburzum, cara muitoo obrigado pela força!

Ja ajudou muito, de verdade.

 

So está ocorrendo um problema ao rodar o código:

Path Not Found : D:\ApplData\Intranet\manutencao\asv\gerar\fpdf\fonts\helvetica.js

 

Eu acompanhei desde o momento em que você postou a resposta aqui no forum e pesquisei no "são" google sobre este "erro" e não achei muitas coisas.

Poderia dar um auxilio quanto ao q devo fazer, pois pelo google ta dificil.

 

Agradeço a atenção e ajuda.

 

Olá xanburzum, cara muitoo obrigado pela força!

Ja ajudou muito, de verdade.

 

So está ocorrendo um problema ao rodar o código:

Path Not Found : D:\ApplData\Intranet\manutencao\asv\gerar\fpdf\fonts\helvetica.js

 

Eu acompanhei desde o momento em que você postou a resposta aqui no forum e pesquisei no "são" google sobre este "erro" e não achei muitas coisas.

Poderia dar um auxilio quanto ao q devo fazer, pois pelo google ta dificil.

 

Agradeço a atenção e ajuda.

Compartilhar este post


Link para o post
Compartilhar em outros sites

faltou um arquivo, o helvetica.js dentro da pasta fonts, chegando em casa em posta aqui para você.

 

o melhor é você me mandar um email que te passo a aplicação completa

 

xanburzum@terra.com.br

Compartilhar este post


Link para o post
Compartilhar em outros sites

faltou um arquivo, o helvetica.js dentro da pasta fonts, chegando em casa em posta aqui para você.

 

o melhor é você me mandar um email que te passo a aplicação completa

 

xanburzum@terra.com.br

 

 

 

 

xanburzum bom dia cara.. eu mandei o e-mail pra você e retornou uma resposta automatica.

Eu devo aguardar seu contato via e-mail ou mando outro e-mail? To muito precisando saber como dar continuidade ao processo.

Abraços

Compartilhar este post


Link para o post
Compartilhar em outros sites

em mandei mas ele voltou, talvez seu server entendeu os code´s como perigiso, devido CSS HTML etc

me mande novamente

Compartilhar este post


Link para o post
Compartilhar em outros sites

em mandei mas ele voltou, talvez seu server entendeu os code´s como perigiso, devido CSS HTML etc

me mande novamente

 

Bom dia xanburzum.. ja lhe encaminhei outro email

Compartilhar este post


Link para o post
Compartilhar em outros sites

acabei de enviar...

divirta-se

Compartilhar este post


Link para o post
Compartilhar em outros sites

Pessoal , boa noite,

 

Estou com um problema ao gerar um arquivo em pdf com asp classico.

 

O momento do erro é ao executar a função pdf.Output();

 

Este erro no localhost não ocorre mas, ao executar no servidor de homologação

aparece a seguinte mensagem "O arquivo não começa em %PDF.

 

se alguém já passou por isso e puder dar um apoio agradeço.

Compartilhar este post


Link para o post
Compartilhar em outros sites

FPDF error: Unable to create output file: Etiqueta.pdf

 

pdf.Output("Etiqueta.pdf"),"T"

 

sem os parâmetros

 

Da a mensagem erro ao carregar documento pdf - Chrome

 

Se alguém puder ajudar!!

 

Obrigado.

 

Não consegui encontrar a solução ainda.

Compartilhar este post


Link para o post
Compartilhar em outros sites

ele gera algum número do erro ?

 

Verifique o caminho está correto e a pasta tem permissão

Compartilhar este post


Link para o post
Compartilhar em outros sites

xanburzum,

 

Verifiquei com a infra ontem todas as pastas tem permissão,

Quanto ao caminho estou usando ou penso que estou, da própria pasta que tem o arquivo.

 

 

essa rotina;

<%
Dim imagem,iPs
imagem = "verallia.JPG"
Set pdf=CreateJsObject("FPDF")
pdf.CreatePDF "P","mm","A4"
pdf.SetPath("fpdf/")
pdf.SetFont "Arial","",12
pdf.Open()
%>
após terminar de ler os registros selecionados
next
pdf.Close()
pdf.Output()
Ocorre a mensagem o pdf abre mas o conteúdo nao aparece
e da a mensagem " Falha ao carregar documento PDF "

Compartilhar este post


Link para o post
Compartilhar em outros sites

Pessoa cheguei a um resultado diferente usando o seguinte comando:

pdf.Close()
'pdf.Output()
pdf.Output server.mappath("Etiqueta" & i &".pdf" ),"D"
é gravado o arquivo em local físico.
Tenho que pensar como imprimir direto agora

Compartilhar este post


Link para o post
Compartilhar em outros sites

Agúem sabe como ler os arquivos que foram gravados e mandar direito para impresso mesmo que tenha que abrir a caixa de seleção das impressoras.

 

Ou seja, após gerar os PDF, o sistema ja abre a opção de impressão?

 

Encontrei esse script mas, é para PHP eu uso ASP Classico.

 

//ou assim:

$file_handler = fopen("c:\\teste.pdf", "r");
$contents = fread($file_handler, filesize("c:\\teste.pdf"));
fclose($file_handler);
echo $contents;

print "<script>window.print()</script>";
sc_redir(form_facturas);

 

​Se for possível dar um apoio agradeço...

Compartilhar este post


Link para o post
Compartilhar em outros sites

×

Informação importante

Ao usar o fórum, você concorda com nossos Termos e condições.