2016-11-20 90 views
0

我想同樣的文檔轉換爲PDF或我要在URL添加POST方法就像:轉換同一頁面PDF

$dompdf->loadHtml($_POST['name']); 

下面是代碼:

<?php 
// include autoloader 
require_once 'dompdf/autoload.inc.php'; 

// reference the Dompdf namespace 
use Dompdf\Dompdf; 

// instantiate and use the dompdf class 
$dompdf = new Dompdf(); 

$dompdf->loadHtml(file_get_contents('http://localhost/)); 

// (Optional) Setup the paper size and orientation 
$dompdf->setPaper(array(0,0,850,2250), 'landscape'); 

// Render the HTML as PDF 
$dompdf->render(); 

// Output the generated PDF to Browser 
//$dompdf->stream(); 

// Output the generated PDF (1 = download and 0 = preview) 
$dompdf->stream("codex",array("Attachment"=>0)); 
?> 
+0

對,這是什麼問題? – RiggsFolly

+2

你是否看到缺少的單引號?顏色編碼告訴你有一個問題 – RiggsFolly

+0

沒有沒有任何問題,我可以使用這個URL創建一個PDF,但我想在這裏添加Post方法,所以我可以在這裏添加來自HTML的URL –

回答

-3

你'如果file_get_contents丟失了單引號if file_get_contents

<?php 
// include autoloader 
require_once 'dompdf/autoload.inc.php'; 

// reference the Dompdf namespace 
use Dompdf\Dompdf; 

// instantiate and use the dompdf class 
$dompdf = new Dompdf(); 

$dompdf->loadHtml(file_get_contents('http://localhost/')); 

// (Optional) Setup the paper size and orientation 
$dompdf->setPaper(array(0,0,850,2250), 'landscape'); 

// Render the HTML as PDF 
$dompdf->render(); 

// Output the generated PDF to Browser 
//$dompdf->stream(); 

// Output the generated PDF (1 = download and 0 = preview) 
$dompdf->stream("codex",array("Attachment"=>0)); 
?> 
+2

已經在一條評論。這實際上並沒有試圖回答這個問題! – RiggsFolly

+0

在發表評論之前,我開始輸入答案並在評論後發佈。順便說一句,如果你注意到報價缺失,它會工作嗎?絕對沒有。如果我正在糾正它,沒有任何意見可以降低它。我正在回答正確的方向。 –

+0

___句子2:___這並不試圖回答問題 – RiggsFolly