1

I have this script on php and i need to create table automatcally from that

foreach ( $GetJobResult->Components->Component as $component_index => $component ) {
    $quote_title = ($component_index + 1) . ') ' . $component->Title . "-Machine :\r\n";
    if (isset ( $component->Paper->Family )) {
        if (isset ( $component->Paper->Type ) && isset ( $component->Paper->Color )) {
            if ($component->Ink->FrontColors == '0') {
                $quote_impression = "sans impression\r\n";
            }
            $getPaperInfoResult = $ws->getPaperInfo ( $component->Paper->Family, $component->Paper->Type );
            foreach ( $getPaperInfoResult->PapFamType as $paper_index => $paperinfo ) {
                if (($paperinfo->Ccoul == $component->Paper->Color) && ($paperinfo->Gramm == $component->Paper->Weight)) {
                    $quote_support = $paperinfo->Lfam . ' - ' . $paperinfo->Lcoul . ' - ' . $paperinfo->Gramm . ' g/m2' . "\n";
                    $quote_impression = $component->Ink->FrontColors . ' Couleur(s) ( ' . $component->Ink->FrontColorDesc . ') au recto / ' . $component->Ink->BackColors . ' Couleur(s)' . ' ( ' . $component->Ink->BackColorDesc . ' ) ' . "\n";
                    break;
                }
                // $quote_desc[]= $getPaperInfoResult->PapFamType [$component_index + 1]->Lfam . ' - ' . $getPaperInfoResult->PapFamType [$component_index + 1]->Lcoul . ' - ' . $getPaperInfoResult->PapFamType [$component_index + 1]->Gramm . ' g/m2' . "\n";
            }
        }
        $row++; $col++;
        $tbl = $p->add_table_cell($tbl, $col, $row, $quote_title, $opttitrecontact);
        $imp_text_element1.=$quote_title."-Support : ".$quote_support."-Impression : ".$quote_impression;
    }
 }

It's done table in each cell the data and skip the one cell on put the data so i need just table contains the data how can i do that.

dario
  • 5,149
  • 12
  • 28
  • 32
test
  • 19
  • 5
  • Welcome to Stack Overflow. Your question could use a bit more detail. Please edit it and include any errors you see or maybe some examples of the resulting data you are getting versus what you're trying to get. – Twisty Jun 15 '15 at 18:27
  • i do my script but the result not table contains the data in different cellul – test Jun 15 '15 at 22:17

1 Answers1

0

I see a possible problem, by the way you increase the variables for

$row++; $col++;

That means, for each additional content, you increase the row and the cell. I would expect, the row should only increased as soon you need a new row.

I guess you want not only add one cell for each run in you foreach-loop: $tbl = $p->add_table_cell($tbl, $col, $row, $quote_title, $opttitrecontact); Maybe you want to add more cells, if so, you should add multiple add_table_cell() calls with the data you want to place.

However as Twisty already mentioned, you might describe your problem more precise. Also, the support team from PDFlib might give you further help.

Rainer
  • 2,013
  • 1
  • 10
  • 7
  • Thanks @Rainer but how can i creat table with the data Thanks in advance – test Jun 16 '15 at 09:33
  • @test, I'm sorry, but I don't understand the background of the question. What do you mean with "data"? Just add table cells with the content you want place. Straight forward. You might check the samples in the PDFlib cookbook (cool resource) http://www.pdflib.com/pdflib-cookbook/tables/ – Rainer Jun 17 '15 at 10:00
  • Thanks @Rainer i need on cell retour the line but not do i do \r\n that $tbl = $p->add_table_cell($tbl, $col, $row, $quote_title."\r\n".$quote_support, $opttitrecontact); – test Jun 17 '15 at 10:43
  • so you want a have a multi line text in this cell? if so, you have to add the content in a two steps: create a textflow which contains the text, then apply this textflow to the cell. As a sample, you might check the starter_table.php sample. Per default, a text cell is a textline, which is always a single line. I'm sure, in the meanwhile you have read this in detail within the PDFlib Tutorial. – Rainer Jun 17 '15 at 12:46
  • how do you think you might get help, when you don't share error messages? – Rainer Jun 17 '15 at 14:12