尝试使用FPDF在pdf文件中显示数组数据

问题描述

嗨,我正在尝试使用FPDF在表中显示foreach数组数据。 我只将标题放入pdf文件中。 从会话变量获取的数组中的数据,我可以将该变量的内容打印到屏幕上。 在屏幕上打印数组的样子:

Array([0] => Array([ID] => 37 [PoNum] => 30 [ProductNum] => 123456 [Description] => Bara rabbabara [Qty] => 12 [QtyUnit] => STK [价格] => 12000 [PriceUnit] => ISK [折扣] => 0 [总计] => 144000 [BatchNum] => 0 [IsTilbod] => [DeliveryStatus] => LANG_IS_NEWPOCREATED)[1] =>数组([ID ] => 38 [PoNum] => 30 [ProductNum] => 123456666 [Description] => Bararabbabaranúna[Qty] => 10 [QtyUnit] => STK [Price] => 66666 [PriceUnit] => ISK [discount] => 0 [总计] => 666660 [BatchNum] => 0 [IsTilbod] => [DeliveryStatus] => LANG_IS_NEWPOCREATED))

class myPDF extends FPDF{
        function header(){
            $this->Image('wiki.png',10,6);
            $this->SetFont('Arial','B','14');
            $this->Cell(276,5,'Innkaupapöntun','C');
            $this->Ln();
            $this->SetFont('Times','','12');
            $this->Cell(276,'heimilisfang','C');
            $this->Ln(20);
        }
        function footer(){
           $this->SetY(-15);
           $this->SetFont('Arial','8');
           //$this->Cell(0,'Page '.$this->PageNo.'/{nb}','C');
        }
        function headerTable(){
            $this->SetFont('arial','12');
            $this->Cell(35,'Vörunúmer',1,'C');
            $this->Cell(70,'Lýsing','C');
            $this->Cell(20,'Fjöldi','C');
            $this->Cell(30,'Verð','C');
            $this->Cell(40,'Samtals línu','C');
            $this->Ln();
        }
        function viewTable(){
            $responselistPoItems = $_SESSION['currPoItems'];
            $datalistPoItems =json_decode($responselistPoItems,true);
            $this->SetFont('arial','12');
            foreach ($datalistPoItems as $value) {
               $this->Cell(35,$value['ProductNum'],'L');
                $this->Cell(70,$value['Description'],'L');
                $this->Cell(20,$value['Qty'],'L');
                $this->Cell(30,$value['Price'],'L');
                $this->Cell(40,$value['Total'],'l');
                $this->Ln(); 
            }
        }
    }
    $pdf = new myPDF();
    $pdf->AliasNbPages();
    $pdf->AddPage('P','A4',0);
    $pdf->headerTable();
    $pdf->Output('F','testing.pdf',true);
    print_r ($datalistPoItems);

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)