12

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.

Thanks in advance.

8
  • 1
    Do you mean you want a user to click a "print" link somewhere and have 8 copies of a PDF spit out of their printer? Unless you've got a really specific use-case for that, it seems like a usability nightmare waiting to happen. Commented Aug 25, 2011 at 8:42
  • 2
    can you explain more clearly? Commented Aug 25, 2011 at 8:43
  • i have 8 (for example) pdf seperate file. the user will click all file to print. i did that open each pdf file using each iframe, there is print option, we can take print. but now i need if i select all(8) pdf file, that will be come to one pdf file to print. Commented Aug 25, 2011 at 8:47
  • You want to concatenate all of the pdfs and then print the single concatenated pdf? Could you instead print each pdf separately, in some order? Commented Aug 25, 2011 at 8:53
  • 2
    @Zahir I don't think you can do it with javascript. What you have to do is to merge all "selected" Document to one on the server side (by submitting the document id's). The languages there are more powerful than javascript. Commented Aug 25, 2011 at 8:58

2 Answers 2

9

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();
    }
}
Sign up to request clarification or add additional context in comments.

5 Comments

Note that this will result in multiple print dialogues.
i am trying to concatenate the pdf using php by ajax then i will try to print the single pdf file. i think this will go to be fine... but i am not try this...
Merging the files server side is of course ideal solution, my way should be used in case you give up on the ideal solution or can't make it work.
is there a way to specify which printer each page goes to?
@waspinator no, such thing is not possible with client side scripting.
2

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.