0
我使用API來生成PDF文檔。在此API文檔,我有:如何使用API生成PDF文檔?
http://...../view_awb.php?user=nume_utilizator&parola=123456&awb=CGS12345678A
If success, the view_awb.php file will return a PDF document
下一個,我有這些代碼:
require "../dbcommon2.php";
$url = "http://webexpress.cargus.ro/custom_print/shipment_import/view_awb.php?user=canai_test&parola=test&awb=TSD21185178T";
$pdf = file_get_contents($url, false);
require_once("../../dompdf/dompdf_config.inc.php");
$dompdf = new DOMPDF();
$dompdf->load_html($pdf);
$dompdf->render();
$dompdf->stream("sample.pdf");
一切看起來正常,但是當我打開PDF文件,我只看到
%PDF-1.3 3 0 obj > endobj 4 0 obj > stream xY[ sÚ8¾ï¯Ðe{UgÙ¹£tèd!KHg/:³ãñ.`Öì7ýõß«Æ6HM;M¤WÞãG¡oýûáHL"ð¥D¦é4Á
在哪裏問題是什麼?我怎樣才能正確生成pdf文件? 我使用Adobe Reader打開pdf文件sample.pdf
實際上,它看起來像PDF,你是什麼意思 「我開」 呢?你用記事本打開它? – Andrey
由Adobe Reader打開pdf文件sample.pdf –
您是否將內容類型設置爲'application/pdf'? –