Write a long document file with FPDF

i am trying to output an array to xml file and pdf files. I succeeded with xml file but pdf file using FPDF is not. The pdf output is just a blank pdf file.

Here’s my code:

$invoice = array(
    'invoice' => array(
        'name' => $customerInfo['name'],
        'lines' => $lineItem,
        'optional' => array(
            'orderNo' => $order_id,
            'orderDate' => date('d.m.y'),
            'recipientNo' => $order_id,
            'address1' => $customerInfo['billingaddress1'],
            'country' => $customerInfo['billcountry'],
            'email' => $customerInfo['billemail'],
            'shipment' => array(
                'emailaddresses' => array(
                    'email' => $customerInfo['billemail']
                ),
            )
        )
    )
);

include 'libs/helper.php';
$xmlData = MyxmlHelper::arrayToXml($invoice, new SimpleXMLElement('<?xml version="1.0" encoding="UTF-8" standalone="yes"?><invoices/>'));

$wp_upload_dir = wp_upload_dir();
$xml_file = $wp_upload_dir['path'].'/invoice.xml';
file_put_contents($xml_file, $xmlData);

require 'libs/fpdf17/fpdf.php';
$pdf_file = $wp_upload_dir['path'].'/invoice.pdf';
$pdf = new FPDF();
$pdf->AddPage();
$pdf->SetFont('Arial','',8);
$pdf->Write(5,$invoice);
$pdf->Output($pdf_file,'F');

Related posts