2015-05-04 130 views
0

我試圖創建一個.PDF自動,但由於某種原因。由於PDF_REPLACE()語法,PDF無法創建。

所以這個腳本作品完美,只要我不觸發:

$output = pdf_replace("<<<opmerking>>>", $datum, $output); 

網上代碼是在這裏: http://073design.nl/peter/index_process.php

(在第一種情況下,我錯過了功能,但現在我definied功能和接收還是同樣的錯誤在pdf_replace。)

<?php 

$naam = 'Jan Janssen'; 

$datum = 'test'; 


//function define 

function pdf_replace($pattern, $replacement, $string) { 

    $len = strlen($pattern); 

    $regexp = ''; 

    for($i = 0 ; $i<$len ; $i++) { 

    $regexp .= $pattern[$i]; 
    if($i<$len-1) { 

     $regexp .= "(\)\-{0,1} [0-9]*\(){0,1}"; 
    } 
    } 

    return ereg_replace($regexp, $replacement, $string); 
} 


//Generate the headers to let a browser choose correct application 
header('Content-Disposition: filename=dagstaat.pdf'); 

header('Content-type: application/pdf'); 


//open template 
$filename = 'dagstaat.pdf'; 
$fp = fopen($filename, 'r'); 


$output = fread($fp, filesize($filename)); 

fclose($fp); 

//replace the place holders in the template 

$output = pdf_replace("<<<opmerking>>>", $datum, $output); // PROBLEM IS HERE 

echo $output; 
?> 
+2

到底是什麼錯誤? – Kyle

+0

使用此服務http://phptopdf.com/這是非常容易使用 – Thamaraiselvam

+0

@ KP:只需點擊http://073design.nl/peter/index_process.php你會看到錯誤 –

回答

1

您正在嘗試使用一個名爲pdf_replace() b功能在PHP中沒有這樣的函數,並且您沒有通過該名稱定義函數。你得到的PHP錯誤(如果你在文本編輯器中打開「PDF」文件)也清楚地告訴你這裏的問題:「致命錯誤:調用未定義函數PDF_replace()在/var/www/vhosts/073design.nl/第24行的httpdocs/peter/index_process.php「

+0

現在是荷蘭的星期一上午,我認爲一些週末的特基里亞人仍然在我的血管中流淌。你是完全正確的,該功能並不存在!射擊我 –