Не удается открыть FPDF Создать PDF с помощью Adobe Reader - PullRequest
0 голосов
/ 23 сентября 2019

Я создаю PDF, используя FPDF.Я могу открыть PDF-файл с помощью Chrome, но после загрузки этого файла и при открытии его с помощью Adobe Reader он показывает пустую страницу, здесь нет данных и отображается сообщение об ошибке «произошла ошибка при обработке страницы. При чтении этого документа возникла проблема (18)»».Я добавил мой код ниже, может кто-нибудь помочь мне решить эту проблему.

 require('fpdf.php');
//A4 width : 219mm
//default margin : 10mm each side
//writable horizontal : 219-(10*2)=189mm


//create pdf object
$pdf = new FPDF('L','mm','A4');
//add new page
$pdf->AddPage();

//set font to arial, bold, 14pt
$pdf->SetFont('Arial','B',14);

$pdf->Cell(70 ,5);
$pdf->Cell(55 ,5,'TAX CREDIT NOTE/DEBIT NOTE',0,1);
$pdf->Cell(90 ,5);
$pdf->Cell(55 ,5,'LANKA IOC PLC',0,1);
$pdf->Cell(70 ,5);
$pdf->Cell(55 ,5,'VAT REG NO:114314315-7000',0,1);

$pdf->Cell(159 ,5,' ',0,1);//end of line
$pdf->Cell(159 ,5,' ',0,1);//end of line
$pdf->Cell(159 ,5,' ',0,1);//end of line
$pdf->Cell(159 ,5,' ',0,1);//end of line
$pdf->Cell(159 ,5,' ',0,1);//end of line


$url = $_SERVER['REQUEST_URI'];

          $valuearrayone=explode('=', $url);
          $valuearrayone[0];
          $userrealidall =$valuearrayone[1];
          $valuearraytwo=explode('&', $userrealidall);

           $userrealid = $valuearraytwo[0];
           $invoiceid = $valuearraytwo[1];

$result = $wpdb->get_results ( "SELECT DISTINCT POST_DATE FROM wp_ioc_debit_note where PAYER = '$userrealid' AND INVOICE = '$invoiceid'" );
                    //if($result==
                    foreach ( $result as $print ) 
{


$pdf->Cell(150 ,5);
$pdf->Cell(55 ,5,'Document Date :',0,0);
$pdf->Cell(159 ,5,$print->POST_DATE,0,1);//end of line

}

$pdf->Cell(150 ,5);
$pdf->Cell(55 ,5,'Credit/Debit Note No :',0,0);
$pdf->Cell(159 ,5,$invoiceid,0,1);//end of line


$result = $wpdb->get_results ( "SELECT BILL_DOCNO FROM wp_ioc_debit_note where PAYER = '$userrealid' AND INVOICE = '$invoiceid'" );
                    //if($result==
                    foreach ( $result as $print ) 
{


$pdf->Cell(150 ,5);
$pdf->Cell(55 ,5,'Billing Doc No :',0,0);
$pdf->Cell(159 ,5,$print->BILL_DOCNO,0,1);//end of line

}


$result = $wpdb->get_results ( "SELECT DISTINCT INVOICE_REF FROM wp_ioc_debit_note where PAYER = '$userrealid' AND INVOICE = '$invoiceid'" );
                     //if($result==
                    foreach ( $result as $print ) 
{
$pdf->Cell(150 ,5);
$pdf->Cell(55 ,5,'Reference Invoice No      :',0,0);
$pdf->Cell(159 ,5,$print->INVOICE_REF,0,1);//end of line

}



//make a dummy empty cell as a vertical spacer
$pdf->Cell(189 ,10,'',0,1);//end of line

global $wpdb;
          //$last_link = $wpdb->get_var('SELECT display_name FROM wp_users where user_login = '.$userrealid);
          $newest = $wpdb->get_row("SELECT display_name, ID FROM wp_users where user_login = '$userrealid'");
          $lastarrowpublication = $newest->display_name;
          $uid = $newest->ID;
$pdf->Cell(55 ,5,'Customer Name:',0,0);
//$pdf->Cell(85 ,5,$newest->display_name,0,1);
$pdf->Cell(159 ,5,$newest->display_name,0,1);//end of line
$pdf->Cell(55 ,5,'Customer Code:',0,0);
//$pdf->Cell(85 ,5,$newest->display_name,0,1);
$pdf->Cell(159 ,5,$userrealid,0,1);//end of line

//set font to arial, regular, 12pt
$pdf->SetFont('Arial','',12);
$url = $_SERVER['REQUEST_URI'];

          $valuearrayone=explode('=', $url);
          $valuearrayone[0];
          $userrealid =$valuearrayone[1];
          global $wpdb;
$newest = $wpdb->get_row("SELECT meta_value FROM wp_usermeta WHERE meta_key = 'Address' AND user_id = '$uid'");
$newest->meta_value;
$pdf->Cell(55 ,5,'Address:',0,0);
$pdf->Cell(159 ,5,$newest->meta_value,0,1);//end of line
 global $wpdb;
$newest1 = $wpdb->get_row("SELECT meta_value FROM wp_usermeta WHERE meta_key = 'vat_number' AND user_id = '$uid'");
$newest1->meta_value;
$pdf->Cell(55 ,5,'VAT Reg No:',0,0);
$pdf->Cell(159 ,5,$newest1->meta_value,0,1);//end of line
$url = $_SERVER['REQUEST_URI'];

          $valuearrayone=explode('=', $url);
          $valuearrayone[0];
          $userrealidall =$valuearrayone[1];
          $valuearraytwo=explode('&', $userrealidall);

          $userrealid = $valuearraytwo[0];
          $invoiceid = $valuearraytwo[1];


//make a dummy empty cell as a vertical spacer
$pdf->Cell(189 ,10,'',0,1);//end of line

//invoice contents
$pdf->SetFont('Arial','B',10);



$pdf->SetFont('Arial','',8);

//Numbers are right-aligned so we give 'R' after new line parameter

$display_heading = array('MATERIAL'=>'MATERIAL', 'Description'=>'Description', 'DISC'=>'DISC', 'VAT'=>'VAT', 'TOTAL'=>'TOTAL');


$rows = $wpdb->get_results("SELECT MATERIAL, Description, DISC, VAT, TOTAL FROM wp_ioc_debit_note where PAYER = '$userrealid' AND INVOICE = '$invoiceid'");
//$header = $wpdb->get_results("SHOW columns FROM wp_invoice_details");
$header = array('MATERIAL', 'Description', 'DISC', 'VAT', 'TOTAL');
//mysqli_query($connString, "SHOW columns FROM employees");


foreach($header as $col)
{
    if($col == 'Description')
    {
        $pdf->Cell(150,12,$col,1);
    }
    else if($col == 'Doc No')
    {
        $pdf->Cell(35,12,$col,1);
    }
    else if($col == 'Csh Rpt No')
    {
        $pdf->Cell(35,12,$col,1);
    }
    else 
    {
        $pdf->Cell(25,12,$col,1);
    }

}
foreach($rows as $row) {
    $pdf->Ln();
    foreach($row as $row=>$column)
        if($row =='Description'){
            $pdf->Cell(150,12,$column,1);
        }
        else if($row =='doccurr')
        {
            $pdf->Cell(35,12,$column,1);
        }
        else if($row =='invoice_no')
        {
            $pdf->Cell(35,12,$column,1);
        }
        else
        {
            $pdf->Cell(25,12,$column,1);
        }
}


$pdf->Output();
...