开发者

Help : printing multiple "reports" from browser (IE 6 essential, others would be nice)

开发者 https://www.devze.com 2022-12-13 00:46 出处:网络
No thoughts on this one? Anyone? Here is my scenario: I have a form where the user selects a report type, and then selects a list of users they want to generate reports for. When they submit the f

No thoughts on this one? Anyone?


Here is my scenario:

I have a form where the user selects a report type, and then selects a list of users they want to generate reports for. When they submit the form, a new window is opened that uses pagination to allow the user to review each user report individual by using next and previous links.

The user wants the option to:

  1. print both the currently displayed report by itself (that's an easy one), and
  2. a "print all" option to print all the selected reports.

However, each report for each user must have its own "Page x of n" footer.

For the footer, I have been using the browser footer options, but in order to have the page numbering start new on each report printout, I have to make a separate window.print() call for each one. I have implemented this this way, and it works, but it's awful because each print() call causes a new print dialog to displa开发者_如何学编程y, meaning the user has to click print in each dialog to finalise the print request. Many reports = a stupid number of popped up print dialogs.

Ideally, I would like the printing of a report group to look like a single print job, but I need that page count to be restarted for each report.

I thought of trying to count pages myself to make my own footer, but that seemed like a daunting task considering all the variables that could affect how many pages a report would occupy. I also read some about using ActiveX and WebBrowser objects to force prints and hide the print dialog, but I have had no success with that because I am running on XP SP2. Also, I understand it's frowned upon from a security perspective, and it's not a good cross-browser solution.

Has anyone dealt with printing of this type before and would have some suggestions for a way to make this work or a better way to handle it?

Thanks in advance.


I've seen this done two ways the simplist using the MeadCo scriptx component which alows you to print without a dialog. But as you rightly say this is not good from a security perspective. This was done in a corporate environment where they had control over the end users browser.

The second would be to go down the ajax route and load each report page individually, without prining, then concat each report html together into one doucment adding any needed page breaks. Finally rendering to an IFRAME and calling print on that frame to print all reports in one action.


This isn't tremendously helpful, but you may want to look into using a pdf generator, such as PDFlib or fpdf. Doing this with static pages will incur all the problems you stated, as well as some which you didn't (such as the user setting his own font or font size and ruining your pagination).

0

精彩评论

暂无评论...
验证码 换一张
取 消