Jump to content


Photo

Batch printing using for loop


  • Please log in to reply
3 replies to this topic

#1 majocmatt

majocmatt
  • Members
  • PipPipPip
  • Advanced Member
  • 40 posts

Posted 24 August 2006 - 05:21 PM

Hi there, I was wondering if someone could help me out here.

What I have is a page where users will choose reports via checkboxes that are next to each report name. Then when they submit the form, the processor gathers all of the selected up in an array.

Next, I have a for loop that goes through each of the previously selected reports and prints them literally through the printer.

The part that I cannot figure out is how to actually print them. I checked the manual and found the PECL printer_write() function, but I do not understand how to use PECL, furthermore, some of my users will be Mac and linux users, and from the description, those PECL functions dont support that.

Then I thought to use javascript, but I don't know any javascript, and am having much trouble finding anything on the internet because the word 'print' has multiple definitions in the coding world.

Does anyone have a suggestion that could help in achieving the ability to print to a users printer for each iteration of the loop?

Thanks,

Matt

#2 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 24 August 2006 - 05:29 PM

You can use PECL print functions if the computer that php is installed on is on Windows. It doesnt matter what OS the user uses when they goto your site it should work. However the printer functions will print to a printer that is connected to the server and not the clients printer.

The only way to print a document to the client is with javascript, search for "printing with javascript" in google you should get some tutorials on how to to print with javascript, however I'm not sure whether you can get javascript to print files other than the one being servered to the browser.

#3 majocmatt

majocmatt
  • Members
  • PipPipPip
  • Advanced Member
  • 40 posts

Posted 24 August 2006 - 05:39 PM

Ok, I'll give it a search.

But just to respond to your reply, the server is Linux  :(

Also, I think that I would generate the report layout during each iteration just by storing all the html in a variable such as:

$report_to_print = "<table>";
$report_to_print .= "<tr>";
$report_to_print .= "<td>Yadda yadda</td>";
etc etc...

Then hopefully just use a print function (that I'm about to search for) to print($report_to_print)

I'm hoping it works, also thanks for your help.

#4 majocmatt

majocmatt
  • Members
  • PipPipPip
  • Advanced Member
  • 40 posts

Posted 24 August 2006 - 06:56 PM

I'm not having much luck finding what I need. Most of the info I find on the web if for making links to print the current page. I need a batch printing system. I feel I have all my ducks in a row up until the point of actually printing the reports.

How do others make batch printing of selected items? Where you check all the checkboxes next to what you want printed and hit Print.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users