1
你好我想從我的數據庫中得到我的pdf文件名並只合並它們我在我的數據庫中有兩個問題是名稱但沒有「.pdf」之後如何在文件名後面設置它,陣列。 而我的第二個問題是我該如何合併它們?如何將PDF文件與數據庫結合使用如何合併PDF文件?
<?php
// run query
$query = mysql_query("SELECT antwoord_id FROM antwoordklant WHERE gebruiker_id = ('" . $id . "')");
// set array
$filearray = array();
// look through query
while ($row = mysql_fetch_assoc($query)) {
// add each row returned into an array
$filearray[] = $row;
// OR just echo the data:
echo $row['antwoord_id']; // etc
}
// debug:
print_r($filearray); // show all array data
echo $filearray[0]['antwoord_id']; // print the first rows username
$datadir = "/home/easyhous/public_html/architectenplan/pdf";
$outputName = $datadir."merged.pdf";
$cmd = "gs -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=$outputName ";
//Add each pdf file to the end of the command
foreach($filearray as $file) {
$cmd .= $file." ";
}
$result = shell_exec($cmd);
那麼你想只合並文件名或文件名和文件? – Bernhard
我只想合併文件,但爲此我需要文件名,它們可以始終是不同的。所以當我從我的數據庫中獲得文件名時,我想合併我的地圖中的同名文件 –