Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/281.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/wordpress/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 使用FPDF编写一个长文档文件_Php_Wordpress - Fatal编程技术网

Php 使用FPDF编写一个长文档文件

Php 使用FPDF编写一个长文档文件,php,wordpress,Php,Wordpress,我正在尝试将数组输出到xml文件和pdf文件。我成功地使用了xml文件,但使用pdf文件却没有成功。pdf输出只是一个空白的pdf文件 这是我的密码: $invoice = array( 'invoice' => array( 'name' => $customerInfo['name'], 'lines' => $lineItem, 'optional' => array( 'orderNo

我正在尝试将数组输出到xml文件和pdf文件。我成功地使用了xml文件,但使用pdf文件却没有成功。pdf输出只是一个空白的pdf文件

这是我的密码:

$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');
$invoice=数组(
“发票”=>数组(
'name'=>$customerInfo['name'],
“行”=>$lineItem,
'可选'=>数组(
'orderNo'=>$order\u id,
“orderDate'=>日期('d.m.y'),
“recipientNo”=>$order\u id,
'address1'=>$customerInfo['billingaddress1'],
'country'=>$customerInfo['billcountry'],
'email'=>$customerInfo['bilemail'],
“装运”=>数组(
“emailaddresses”=>数组(
'email'=>$customerInfo['bilemail']
),
)
)
)
);
包括“libs/helper.php”;
$xmlData=MyxmlHelper::arrayToXml($invoice,新的SimpleXMLElement(“”));
$wp_upload_dir=wp_upload_dir();
$xml_file=$wp_upload_dir['path']./invoice.xml';
文件内容($xml文件,$xmlData);
需要'libs/fpdf17/fpdf.php';
$pdf_file=$wp_upload_dir['path']./invoice.pdf';
$pdf=新的FPDF();
$pdf->AddPage();
$pdf->SetFont('Arial','',8);
$pdf->Write(5$invoice);
$pdf->Output($pdf_文件,'F');

不能用$pdf->write编写数组,它只接受字符串。不能用$pdf->write编写数组,它只接受字符串。