我正在制作一些pdf发票,并希望将它们合并为一个,以便在创建后更容易打印。我有这个jquery代码:
$('#printinvoice').click(function(){
$.ajax({
type:"POST",
url: "../ajaxcalls/print_invoice.php",
data: {
Order: itemstotake1
},
dataType:"json",
success: function(data) {
$.ajax({
type: "POST",
url: "../ajax/pdf_merger.php",
data: {
PDFS: data
},
success: function (data1) {
alert(data1);
//window.location.assign('../tools/PDFMerger/samplepdfs/TEST2.pdf');
$('.group').removeClass('highlight');
itemstotake1 = [];
}
});
}
});
});
我使用PDFMerge,合并了文件,但我的第二个成功函数没有响应。 这是PHP代码(pdf_merger.php)
包括'../tools/PDFMerger/PDFMerger.php'; $ files = $ _POST ['PDFS'];
$pdf = new PDFMerger;
$pdf->addPDF('../tools/PDFMerger/samplepdfs/three.pdf', 'all')
->addPDF('../tools/PDFMerger/samplepdfs/three.pdf', 'all')
->addPDF('../tools/PDFMerger/samplepdfs/three.pdf', 'all')
->merge('file', '../tools/PDFMerger/samplepdfs/TEST22.pdf');
从$pdf->addPDF
发表评论时,弹出成功提醒(以及window.location)。
有人能告诉我我做错了吗?
谢谢!
答案 0 :(得分:0)
$fileArray= $filer;
$datadir = "../dir/";
$outputName = $datadir."/filename.pdf";
$cmd = "gs -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=$outputName ";
//Add each pdf file to the end of the command
foreach($filer as $file) {
$cmd .= $file." ";
}
$result = shell_exec($cmd);