简体   繁体   English

PDF在PHP中打印迭代

[英]PDF to print iteration in PHP

Can anyone tell me if it's possible to iterate over an array of SimpleXML objects that contain PDF data and have each print to separate PDF files? 谁能告诉我是否可以遍历一个包含PDF数据且每个打印都分开PDF文件的SimpleXML对象数组? I've been fighting with this for over a week now. 我已经为此打了一个多星期了。 My latest loop code is as follows: 我最新的循环代码如下:

foreach($xml->DocumentPDFs->DocumentPDF->PDFBytes as $PDFBytes => $value) {
    $binary = base64_decode($value);
    file_put_contents($xml->EnvelopeStatus->EnvelopeID . "/" . $xml->EnvelopeStatus->DocumentStatuses->DocumentStatus->Name . ".pdf", $binary,FILE_APPEND);
}

This prints out the first PDF and then exits the loop. 这将打印出第一个PDF,然后退出循环。

So it turns out it was syntax issues. 因此事实证明这是语法问题。 Both in the base64_decode call and the file_put_contents call: 在base64_decode调用和file_put_contents调用中:

foreach($xml->DocumentPDFs->DocumentPDF as $value) {
    $binary = base64_decode($value->PDFBytes);
    file_put_contents($xml->EnvelopeStatus->EnvelopeID . "/" . $value->Name . ".pdf", $binary);
}

So there you go. 所以你去了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM