Printing multiple PDF files using JavaScript

后端 未结 2 569
广开言路
广开言路 2021-01-05 01:33

I want to know how to print multiple PDF files in a single print click.

I can easily print single PDF file but I dont know how to print when there are more files.

相关标签:
2条回答
  • 2021-01-05 02:27

    Either do as Shodow Wizard suggests and print out the files sequentially or concatenate the files server-side.

    You could make an ajax request with the fine names that the user wants to print, concatenate them server side, return the concatenated pdf and then print that out. The concatenation implementation would depend on what server-side language you are using.

    0 讨论(0)
  • 2021-01-05 02:32

    You can call print() multiple times in your code, resulting in the files being printed one after the other:

    function PrintAll() {
        var pages = ["page1.pdf", "page2.pdf", "page3.pdf"];
        for (var i = 0; i < pages.length; i++) {
            var oWindow = window.open(pages[i], "print");
            oWindow.print();
            oWindow.close();
        }
    }
    
    0 讨论(0)
提交回复
热议问题