Jquery 基于ajax成功的PDF合并
我正在创建两个pdf发票,并希望在创建后将它们合并为一个,以便于打印。我有这个jquery代码:Jquery 基于ajax成功的PDF合并,jquery,ajax,pdf,Jquery,Ajax,Pdf,我正在创建两个pdf发票,并希望在创建后将它们合并为一个,以便于打印。我有这个jquery代码: $('#printinvoice').click(function(){ $.ajax({ type:"POST", url: "../ajaxcalls/print_invoice.php", data: { Order: itemstotake1
$('#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_merge.PHP)
包括“../tools/PDFMerger/PDFMerger.php”;
$files=$\u POST['pdf']
$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)
有人能告诉我我做错了什么吗
谢谢大家! 可能由于服务器错误而未调用成功回调?添加一个完整的回调,看看是否返回状态消息。
$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);