weixin_33735077 2014-09-17 16:44 采纳率: 0%
浏览 25

PDF合并成功的Ajax

I'm creating a couple of pdf invoices and want to merge them into one for easier printing after they've been created. I have this jquery code:

        $('#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 = [];
                    }


                });

            }
        });

});

I use PDFMerge, the Files are merged, but there is no response of my second success function. Here's the PHP code (pdf_merger.php)

include '../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');

When commenting from $pdf->addPDF, the success alert pops-up(and the window.location).

Can someone tell me what I'm doing wrong?

Thank you!

  • 写回答

1条回答 默认 最新

  • Didn"t forge 2014-10-21 22:20
    关注
    $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);
    
    评论

报告相同问题?