mesaglam / alivepdf

Automatically exported from code.google.com/p/alivepdf
0 stars 0 forks source link

addCell not laying out cells horizontally as expected #24

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?

var myPDF : PDF = new PDF(Orientation.PORTRAIT,Unit.MM,Size.LETTER);
myPDF.addPage(Orientation.PORTRAIT);
myPDF.setFont(FontFamily.HELVETICA, ‘B’, 12);
myPDF.textStyle ( new RGBColor ( 255, 0, 0 ) );
myPDF.addCell(50,10,’Some text into a cell !’,1,0);
myPDF.addCell(50,10,’More text into a cell !’,1,0);
myPDF.addCell(50,10,’Last text into a cell !’,1,0);

What is the expected output? What do you see instead?

I would expect horizontal cells laid out 50 mm apart

What version of the product are you using? On what operating system?

Flex 3 Beta 3

Please provide any additional information below.

This works to lay them out vertically:
var myPDF : PDF = new PDF(Orientation.PORTRAIT,Unit.MM,Size.LETTER);
myPDF.addPage(Orientation.PORTRAIT);
myPDF.setFont(FontFamily.HELVETICA, ‘B’, 12);
myPDF.textStyle ( new RGBColor ( 255, 0, 0 ) );
myPDF.addCell(50,10,’Some text into a cell !’,1,1);
myPDF.addCell(50,10,’More text into a cell !’,1,1);
myPDF.addCell(50,10,’Last text into a cell !’,1,1);

Original issue reported on code.google.com by onefootp...@gmail.com on 21 Jan 2008 at 7:44

GoogleCodeExporter commented 9 years ago
I think this is a bug.  I after checking with FPDF source, I think line 2001 in 
PDF.as should read:

} else this.x += pWidth;

instead of:

} else this.x += currentPage.w;

currently you are setting this.x to the page width which pushes any second cell 
you try to add on the same line 
off the page.

I hope that helps others.  I am happy to post a fix if you want to give me SVN 
access.  

Thanks for all your hard work!  - Kevin

Original comment by onefootp...@gmail.com on 21 Jan 2008 at 9:27

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
Hi Kevin,

Nice one ! it's fixed now hehe !

I have to setup that SVN thing for sure and let you know :)

regards,

Thibault

Original comment by thibault.imbert on 21 Jan 2008 at 11:24

GoogleCodeExporter commented 9 years ago
If you need a quick easy cheap SVN host this is who I use: 
myversioncontrol.com.  I have a couple other fixes, 
enhancements that I have found as I am working with the class.  I will post 
issues when I have a chance.

Original comment by onefootp...@gmail.com on 21 Jan 2008 at 11:45

GoogleCodeExporter commented 9 years ago
excellent, I will check that !

;)

Original comment by thibault.imbert on 22 Jan 2008 at 1:59

GoogleCodeExporter commented 9 years ago
thanks guys... i was really looking for this!

God bless!

Original comment by icewing...@gmail.com on 29 Jan 2008 at 5:23

GoogleCodeExporter commented 9 years ago
This bug may have resurfaced.

I wasn't sure what the addCell() function was supposed to do.  I was expecting
multiple addCell calls to layout horizontally, but they were displayed on the 
next
line like in the original post here.  I'm using version 0.1.4.5 that I 
downloaded
yesterday (I'm linking in the SWC file with FlexBuilder 3).  I'm glad to know 
this is
a bug and not a feature.

-Brian

Original comment by cont...@kalbfus.com on 5 Sep 2008 at 10:10

GoogleCodeExporter commented 9 years ago
Hi everyone,

I am trying to add multiple cells to create a table using alivePDF 0.1.4.8 
(which
should be the latest version) I am calling addCell in a for loop (as I pass a 2D
array holding the text for each cell and it's width to the constructor for my
"PDFTable" class)

But for some reason I can't get multiple cells to appear on one row (some rows 
should
only have one cell and some have upto 4) If I have borders turned off, then it 
will
draw the entire table (with only one cell per row), but if I have borders 
turned on
as they will be in the final version, it will only create the first few rows of 
the
table where there is only one cell per row? and the rest of the rows (with 
multiple
cells on each) just dont display at all?

From reading the previous posts on this topic, a bug seems to have been fixed, 
so am
I doing something wrong?

Here is part of my code (from my PDFTable class):
private function buildTable(){

var currRowHeight = 0;
var cellText:String = "";
var cellWidth:Number = 0;
var usedWidth = 0;

for(var row = 0; row < theData.length; row++){
    currRowHeight = getRowHeight(theData[row]);
    for(var col = 0; col < 99; col++){
        trace("adding row "+(row+1)+" cell "+(col+1));
        cellText = theData[row][col].Text || "";
        cellWidth = theData[row][col].Width || tableWidth;
        // Sets the width of the cell to make the table square
        if(col == theData[row].length-1 || cellWidth > tableWidth){
        for(var r = 0; r < theData[row].length-1; r++){
        usedWidth+=theData[row].Width;
            }
            cellWidth = tableWidth-usedWidth;           
        }
                    pdf.addCell(cellWidth,20,cellText,options.CellBorder,row+1,"L",0,"");

    if(theData[row][col+1] == null){
        break;
    }
    }

}
}

Original comment by mike_sow...@hotmail.com on 14 Apr 2009 at 4:10

GoogleCodeExporter commented 9 years ago
I just tried it on v 0.1.4.9. It is not possible to create "tables" using 
addCell or 
AddMultiCell. Everything will show up in one column due to what I would think 
is a 
bug - the last line of code in addMultiCell sets the X coordinate to the left 
margin 
i.e currentX=lMargin; // line 2355 in PDF.as

To overcome this problem, you can set the X coordinate yourself and place the 
columns 
next to each other using the logic shown below.

var x:int = myPDF.getX();
var y:int = myPDF.getY();
myPDF.addMultiCell(50,10,"More text into a cell",1);
myPDF.setY(y);
x = x + 50; // 50 is the width of the last cell
myPDF.setX(x);
myPDF.addMultiCell(57,10,"Last text into a cell",1);
myPDF.setY(y);
x = x + 57;
myPDF.setX(x);
myPDF.addMultiCell(50,10,"Last text into a cell",1);

Note that if you interchange the order of setX and setY in the above code, 
again 
things may not work. Setting the Y coordinate usingthe setY method, resets the 
X 
coordinate to "lMargin". So you have to set Y and then set X to place you 
columns at 
the right locations...

Original comment by nan...@gmail.com on 17 Jun 2009 at 9:44