我需要转换XML数组(包含base64解码)并将其编码为PDF。
这是数组:
<response>
<xmlArray>
<blabla>TG9yZW0gaXBzdW0gZG9sb3Igc2l0IGFtZXQsIGNvbnNlY3RldHVyIGFkaXBpc2NpbmcgZWxpdC4gTnVuYyB2ZW5lbmF0aXMsIGp
1c3RvIHV0IGF1Y3RvciBzZW1wZXIsIHB1cnVzIGxlY3R1cyBlbGVtZW50dW0gbGliZXJvLCBhYyBwZWxsZW50ZXNxdWUgYW50ZSBqdXN0b
yBldCB0dXJwaXMuIE51bmMgYmliZW5kdW0gZWdlc3RhcyBkb2xvciB2b2x1dHBhdCBlZ2VzdGFzLiBTdXNwZW5kaXNzZSBkYXBpYnVzIHN
lbSBvZGlvLCBpbiBmYXVjaWJ1cyBsZWN0dXMgcHVsdmluYXIgdml0YWUuIE5hbSBtYXR0aXMgZXVpc21vZCBhdWd1ZSwgZWdldCBmaW5pY
nVzIGxlbyBoZW5kcmVyaXQgbmVjLiBDbGFzcyBhcHRlbnQgdGFjaXRpIHNvY2lvc3F1IGFkIGxpdG9yYSB0b3JxdWVudCBwZXIgY29udWJ
pYSBub3N0cmEsIHBlciBpbmNlcHRvcyBoaW1lbmFlb3MuIE51bmMgaWQgbnVuYyBsZWN0dXMuIFBlbGxlbnRlc3F1ZSBsYWN1cyB1cm5hL
CB2aXZlcnJhIGNvbnZhbGxpcyBlZmZpY2l0dXIgdmVsLCBhbGlxdWFtIHNpdCBhbWV0IGRpYW0uIEluIGEgYWxpcXVldCBtYXNzYS4gU2V
udCwgdGVtcHVzIGhlbmRyZXJpdCBlbmltIGZhdWNpYnVzLiBEb25lYyBtYXR0aXMgZWxpdCBub24gbWFzc2EgaW50ZXJkdW0gZmF1Y2lid
XMuIEFlbmVhbiBub24gbWF1cmlzIGluIHVybmEgbWFsZXN1YWRhIGx1Y3R1cy4=
</blabla>
</xmlArray>
</response>
我到目前为止的尝试是
<?php
// 1st. convert xml array; get the blabla array information
$blabla2 = $xml->xmlArray->blabla;
// remove CR, new lines and whitespace on blabla2
$blabla3 = str_replace(array("\n", "\t", "\r"), '', $blabla2);
// 2nd. encode it to PDF
header('Content-type: application/pdf');
$blabla4 = base64_decode($blabla3 );
echo $blabla4 ;
?>
结果是pdf,但不是我预期的方式,因为它在pdf上显示了这一行:
%PDF-1.410obj<</Title(þÿ)/Creator(þÿwkhtmltopdf0.12.2.4) ...
您介意告诉我如何正确显示PDF格式吗?
非常感谢!