ciao a tutti , come voi sto usando fpdf che è troppo fantastico.
Ma perchè non riesco a trovare l'estensionte table sul sito?? qualcuno me la puo linkare?
ciao a tutti , come voi sto usando fpdf che è troppo fantastico.
Ma perchè non riesco a trovare l'estensionte table sul sito?? qualcuno me la puo linkare?
io ho questo, copia&incolla in un file chiamato table.ext
codice:var widths; this.Table = {Border:{Width:0.1,Color:''},Fill:{Color:''},TextAlign:"C", TextValign:"M"} this.SetColumns=function(){this.widths=arguments;} this.HexToRGB=function(value){ var ar=new Array() s= new String(value.toUpperCase()); ar["R"] = parseInt(s.substring(0,2),16); ar["G"] = parseInt(s.substring(2,4),16); ar["B"] = parseInt(s.substring(4,6),16); return ar; } this.Row=function(){ var xdata = arguments var xi;var xh;var xnb;var xnbmax; var xw; xnb=0; xnbmax=0; for(xi=0;xi<xdata.length;xi++){ xnbmax=Math.max(xnbmax,this.NbLines(this.widths[xi],xdata[xi])) }; xh=(xnbmax)*5; this.CheckPageBreak(xh); for(xi=0;xi<xdata.length;xi++){ xw=this.widths[xi]; xx=this.GetX(); xy=this.GetY(); xnb=this.NbLines(this.widths[xi],xdata[xi]) if (this.Table.Border.Width>0||this.Table.Fill.Color!=''){ var xstyle=''; this.SetLineWidth(this.Table.Border.Width); if(this.Table.Border.Color!=''){ var RGB = this.HexToRGB(this.Table.Border.Color); this.SetDrawColor(RGB["R"],RGB["G"],RGB["B"]); xstyle+='D'; } if(this.Table.Fill.Color!=''){ var RGB = this.HexToRGB(this.Table.Fill.Color); this.SetFillColor(RGB["R"],RGB["G"],RGB["B"]); xstyle+="F" } this.Rect(xx,xy,xw,xh,xstyle); } //Next 3 lines set vertical alignment if(this.Table.TextValign=="B"){this.SetXY(xx,xy+(xnbmax-xnb)*5)}; else if(this.Table.TextValign=="M"){this.SetXY(xx,xy+(xnbmax-xnb)*5/2)}; else this.SetXY(xx,xy); this.MultiCell(xw,5,xdata[xi],0,this.Table.TextAlign); this.SetXY(xx+xw,xy); } this.Ln(xh); } this.CheckPageBreak=function(xh) { if(this.GetY()+xh>this.PageBreakTrigger)this.AddPage(this.CurOrientation); } this.NbLines=function(xw , xtxt) { var xnb; 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=xs.length; if(xnb>0 && xs.charAt(xnb-1)=="\n")xnb--; xsep=-1; xi=0; xj=0; xl=0; xnl=1; while(xi<xnb) { xc=xs.charAt(xi); if(xc=="\n") { xi++; xsep=-1; xj=xi; xl=0; xnl++; continue; } if(xc==" ")xsep=xi; lg=(xcw[xc]); if(lg==null)lg=500; xl+=lg; if(xl>xwmax) { if(xsep==-1) { if(xi==xj)xi++; } else xi=xsep+1; xsep=-1; xj=xi; xl=0; xnl++; } else {xi++;} } return xnl; }
ok grazie mille
io invece ho quest'altro table.ext che 'pare' molto più sofisticato nelle funzioni,
e che vorrei tanto poter utilizzare correttamente, ma mi dà problemi già nelle funzioni base...
devo confessare che sono pivellissima nella programmazione web (non inorridite se vi dico che ho fatto per più di 10 anni la 'classica' pgmtrice cobol batch/online, ed ora sto cercando di imparare 'sul campo'...);
questa è table.ext in mio possesso: -----------------------------------------
//31-08-2007 ****** note di maria ******************************
//
//*************** versione coorretta ***************************
//
// 'Between the lines 156 AND 175'
//
// come da mail dell'autore 'edugs'su forum FPDF dell'11-08-2006
//
// vedi http://www.aspxnet.it/forum/topic.asp
//
// oggetto del Topic: "***** NEW functions in table.ext"
//************************************************** ************
var widths, borders, bordersW, bordersC, aligns, styles, fills;
this.borders = new Array();
this.aligns = new Array();
this.styles = new Array();
this.fills = new Array();
this.bordersW = new Array();
this.bordersC = new Array();
//Propriedades/Properties
this.Table = {Border:{Width:0.0,Color:''},Fill:{Color:''},TextA lign:"J", TextValign:"U", LineH:5}
this.SetColumns=function(){this.widths=arguments;}
//Adicionado por: Eduardo Gonçalves <edugsdf@gmail.com>, 9/27/2005 10:54AM
this.SetBorders=function(){this.borders=arguments; } //Set 1,0 or B,T,L,R
this.SetAligns=function(){this.aligns=arguments;} //Set C,L,R,J
this.SetStyles=function(){this.styles=arguments;} //Set B,I,U of the Column
this.SetFills=function(){this.fills=arguments;} //BackGround of the Column
this.SetBordersW=function(){this.bordersW=argument s;} //Border Width
this.SetBordersC=function(){this.bordersC=argument s;} //Borders Color
this.HexToRGB=function(value){
var ar=new Array()
s= new String(value.toUpperCase());
ar["R"] = parseInt(s.substring(0,2),16);
ar["G"] = parseInt(s.substring(2,4),16);
ar["B"] = parseInt(s.substring(4,6),16);
return ar;
}
this.Row=function()
{
var xdata = arguments;
var xi, xh, xnb, xnbmax, xw;
var sumBorder=0;
var xwSumMultiCell=0;
var lastxw=0;
var xb = ""; //Border of the especific cell
var nxb = ""; //New Border of the Cell
xnbmax=0;
xnb=0;
//Número máximo de Linhas / Maximum number of Lines
for(xi=0;xi<xdata.length;xi++){ xnbmax=Math.max(xnbmax,this.NbLines(this.widths[xi],xdata[xi])); }
xh=(xnbmax)*this.Table.LineH; //Alterado por Eduardo Gonçalves
this.CheckPageBreak(xh);
//-----Inicio/Start-----------------------------
//Colunas/Columns
for(xi=0;xi<xdata.length;xi++)
{
xw=this.widths[xi];
xx=this.GetX();
xy=this.GetY();
//Pega a primeira posição do Y
//Get the First Position of the Y
if(xi==0){ var firstY=this.GetY(); }
//Adicionado por: Eduardo Gonçalves <edugsdf@gmail.com>, 9/27/2005 10:54AM
if(this.borders[xi] == undefined){ xb=0; }
else{
xb=((this.borders[xi]!='')?this.borders[xi]:0);
}
//Adicionado por: Eduardo Gonçalves <edugsdf@gmail.com>, 9/29/2005 3:50PM
if(this.aligns[xi] == undefined){ xalign=this.Table.TextAlign; }
else{
xalign=((this.aligns[xi].length>0)?this.aligns[xi]:this.Table.TextAlign);
}
//Adicionado por: Eduardo Gonçalves <edugsdf@gmail.com>, 9/29/2005 5:44PM
if(this.styles[xi] == undefined){
this.SetFont(''+this.GetFontName()+'','',''+this.G etFontSize()+'');
}
else{
xsStyle=((this.styles[xi].length>0)?this.styles[xi]:'');
this.SetFont(''+this.GetFontName()+'',''+xsStyle+' ',''+this.GetFontSize()+'');
}
//Numero de linhas especificamente de uma coluna
xnb=this.NbLines(this.widths[xi],xdata[xi])
if (this.Table.Border.Width>0||this.Table.Fill.Color! =''){
var xstyle='';
this.SetLineWidth(this.Table.Border.Width);
if(this.Table.Border.Color!=''){
var RGB = this.HexToRGB(this.Table.Border.Color);
this.SetDrawColor(RGB["R"],RGB["G"],RGB["B"]);
xstyle+='D';
}
if(this.Table.Fill.Color!=''){
var RGB = this.HexToRGB(this.Table.Fill.Color);
this.SetFillColor(RGB["R"],RGB["G"],RGB["B"]);
xstyle+="F"
}
this.Rect(xx,firstY,xw,xh,xstyle); //Set the backgroud of the cell
}
//Adicionado por: Eduardo Gonçalves <edugsdf@gmail.com>, 10/3/2005 5:14PM
if(this.bordersW[xi] != undefined){
this.SetLineWidth(this.bordersW[xi]);
}
this.SetDrawColor(0); //Default black
if(this.bordersC[xi] != undefined && this.bordersC[xi] !=''){
var RGB = this.HexToRGB(this.bordersC[xi]);
this.SetDrawColor(RGB["R"],RGB["G"],RGB["B"]);
}
//Adicionado por: Eduardo Gonçalves <edugsdf@gmail.com>, 10/3/2005 5:14PM
if(this.fills[xi] != undefined){
if(this.fills[xi].length>0){
var RGB = this.HexToRGB(this.fills[xi]);
this.SetFillColor(RGB["R"],RGB["G"],RGB["B"]);
}
this.Rect(xx,firstY,xw,xh,"F"); //Set the backgroud of the cell
}
//Next 3 lines set vertical alignment
if(this.Table.TextValign=="B"){this.SetXY(xx,xy+(( xnbmax-xnb)*this.Table.LineH))};
else if(this.Table.TextValign=="M"){this.SetXY(xx,xy+(( xnbmax-xnb)*this.Table.LineH/2))};
else{ this.SetXY(xx,firstY); }
nxb = xb;
if(xnb<xnbmax){
//{Begin - To controle of the Borders - MultiCell }
if(xb.toString()==1){ nxb="LRT"; }
if(xb.toString().indexOf("B")>-1){ nxb=lib.str_replace("B","",xb);}
//{End - To controle of the Borders - MultiCell }
}
//************************************************** ********
//*************** Principal/Main **************************
this.MultiCell(xw,this.Table.LineH,xdata[xi],nxb,xalign);
//*************** END *************************
//************************************************** ********
if(xi==0){ xwSumMultiCell=0; }else{ xwSumMultiCell+=lastxw; }
if(xnb<xnbmax){
var iCount = (xnbmax-xnb);
var yhSumCell = this.Table.LineH;
for(i2=0; i2<iCount; i2++){
//{Begin - To controle of the Borders - Cell }
if((i2+1)==iCount){
if(xb.toString()==1){ nxb="LRB"; }else{ nxb=xb;}
if(xb.toString().indexOf("T")>-1){ nxb=lib.str_replace("T","",xb);}
}
else{
if(xb.toString()==1){ nxb="LR"; }
if(xb.toString().indexOf("B")>-1){ nxb=lib.str_replace("B","",xb);}
if(nxb.toString().indexOf("T")>-1){ nxb=lib.str_replace("T","",nxb);}
}
//{End - To controle of the Borders - Cell }
this.SetXY((this.GetX()+xwSumMultiCell), firstY+yhSumCell)
this.Cell(xw, this.Table.LineH, "", nxb, 1);
//DEBUG -> this.Cell(xw, this.Table.LineH, "{"+this.GetX()+"+"+xwSumMultiCell+"="+(this.GetX( )+xwSumMultiCell)+"}", 1, 1);
yhSumCell+=this.Table.LineH;
}//for(i2=0; i2<iCount; i2++){
}//if(xnb<xnbmax){
this.SetXY(xx+xw,firstY);
lastxw = xw; //Ultimo xw
}
//Colunas/Columns
//-----Fim/End-----------------------------
//Insere a nova linha da tabela
this.Ln(xh);
}//Fim do Row / End of the Row
//--------
this.CheckPageBreak=function(xh)
{
if(this.GetY()+xh>this.PageBreakTrigger)this.AddPa ge(this.CurOrientation);
}
//Calcula número de linhas / It calculates line number
this.NbLines=function(xw , xtxt)
{
var xnb=0;
var xwmax=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=xs.length;
if(xnb>0 && xs.charAt(xnb-1)=="\n")xnb--;
xsep=-1;
xi=0;
xj=0;
xl=0;
xnl=1;
while(xi<xnb)
{
xc=xs.charAt(xi);
if(xc=="\n")
{
xi++;
xsep=-1;
xj=xi;
xl=0;
xnl++;
continue;
}
if(xc==" ")xsep=xi;
xl+=(xcw[xc]);
if(xl>xwmax)
{
if(xsep==-1)
{
if(xi==xj)xi++;
}
else xi=xsep+1;
xsep=-1;
xj=xi;
xl=0;
xnl++;
}
else {xi++;}
}
return xnl;
}
//Função que auto-completa espaços na coluna
//Auto-complete function that spaces in the column
this.completeData=function(strData, imaxnb, icellw){
var fim="n";
var imax=0;
while(fim=="n"){
imax=Math.max(imax,this.NbLines(icellw,strData));
strData+=" ";
if(imaxnb==imax){ fim="s"; }
}
return strData;
}
----------------------------------------------------------------------------------
e questo è il codice del più stupido tra i pgmi:
<%@language=vbscript%>
<%
' esempio di tabella imbecille .......
Dim pdf
Set pdf=CreateJsObject("FPDF")
pdf.CreatePDF()
pdf.SetPath("db/fpdf/")
pdf.LoadExtension("table")
pdf.Open()
pdf.AddPage()
pdf.SetFont "Arial","",10
pdf.SetColumns 150
pdf.Table.Fill.Color="C0C0C0"
pdf.Table.TextAlign = "J"
pdf.Table.Border.Width=1
'//Auto Break
pdf.Row "here it comes the text, aqui vem o texto. here it comes the text, aqui vem o texto. here it comes the text, aqui vem o texto. here it comes the text, aqui vem o texto. "
'//Table two columns
pdf.SetColumns 50, 50
pdf.Table.TextAlign = "J"
pdf.Table.Border.Width=0.4
pdf.Table.Border.Color="000000"
pdf.Table.Fill.Color="8FB7CF"
pdf.Row "Linea 1 - Colonna 1", "Linea 1 - Colonna 2"
pdf.Close()
pdf.Output "test.pdf",1,1
%>
------------------------------------------------------------------------------
e questo è l'errore:
HTTP 500.100 - Errore interno del server - errore ASP
Internet Information Services
Informazioni tecniche (per il personale del supporto tecnico)
* Tipo di errore:
Errore di run-time di Microsoft JScript (0x800A01B6)
Proprietà o metodo non supportati dall'oggetto
/web/maria/ddd.asp
* Tipo di browser:
Mozilla/5.0 (Windows; U; Windows NT 5.1; it; rv:1.8.1.6) Gecko/20070725 Firefox/2.0.0.6
--------------------------------------------------------------------------------------------
lo stesso stupidissimo pgm, fatto girare con table.ext di 'fichico' funziona, però ....
Chi di voi mi sa aiutare???? (ho chiesto a 'edugs' l'ultima versione di table.ext, ma non ho ancora avuto risposta)
grazie. maria