当前位置: 动力学知识库 > 问答 > 编程问答 >

php - Print multiple uploaded document from a web application

问题描述:

I want to know if this is possible to print all attached pdf from an object.

(i'm afraid not, but better asking ;D)

context:

User uploads multiple pdf file in his account, then later, he clicks on "print all the pdf attachements", instead of downloading and then one by one clicking on "print"

Thanks.

网友答案:

There are several ways you can go about this with either just JS or a combination of PHP and js (and perhaps server-side programs that can be called by PHP):

  1. Have the target document be a php file which programatically join all the PDFs into a single document (for instance, with pdftk) and then outputs the joined file with PDF headers. This file would be loaded into an iframe which you could call window.print() on with JavaScript.

  2. Use javascript's window.print() function to target several hidden iframes each of which has one of the PDFs loaded in it. The major drawback of this approach is that it will generate multiple print dialogue boxes.

Both of these approaches rely on the user having the necessary settings and plugins to actually load PDFs within the browser window, but if they don't they'll be prompted to download the large file/multiple files.

网友答案:

This can not be done with PHP. Why? Well, PHP is a server-side script. It has no possibilities to access the user's printer.

To my knowledge there is no solution with javascript either. Mike made a good point with the printer dialog being accessible through a javascript command but that is where it stops. This is a good thing though, would you want a page you enter to be able to use your printer without your permission?

网友答案:

Best way is probably to concatenate all the pdf into a single document server side then allow the user to download and print that. This is what manuscriptcentral and probably other online academic peer review systems do.

分享给朋友:
您可能感兴趣的文章:
随机阅读: