Search code examples
phppdflib

PDFLib php - no more than 32 columns


I'm currently working with PDFLib 9.0.5 with PHP and I'm truggling with the building of a table.

I've got a large table with 34 columns. The first thing I do is create the header row and i've got this error message

PDFlibException' with message 'Cell in column(s) 33 and row(s) 1: Illegal array index 32 in function pdc_bvtr_setbit

I've made a test with 32 columns and there is no problems. If the array i'm using to create the row is larger than 32 elements, i've got the error.

I thought it could be due to a lack of space whithin my pdf, so i increase the pdf's width but it didn't change anything.

Here is the code which triggered the error :

foreach($this->headerTable as $index=>$text)
{
    $currentOption=$optlist;
    if(is_int($index))
    {
        $currentColorString=(($col%2)==0)?$alternateWhiteColorString:$whiteColorString;
        $currentOption.=(in_array($index,array(2,3)))?' fittextflow={orientate=west}':'';
        $currentOption.=($index==5)?' fittextflow={stamp=ll2ur}':'';
        $currentOption.=(in_array($index,array(0,1,4)))?' fittextflow={stamp=ll2ur}':'';
    }
    else
    {
        $currentColorString=(($col%2)==0)?$greyColorString:$greyAlternateColorString;
        $text=$index.' ('.$text.')';
        $currentOption.=' fittextflow={stamp=ll2ur}';
    }
    $textFlow=PDF_add_textflow($this->pdf,0,$text,$optionHeaderContent);
    $this->table=PDF_add_table_cell($this->pdf,$this->table,$col,1,'',$currentOption.' matchbox={fillcolor={rgb '.$currentColorString.'}} textflow='.$textFlow);
    ++$col;
}

Solution

  • Answer from Rainer comment : this is bug in the current version of PDFlib 9.0.5. It should be fixed in the next release.