Jump to content

Batch printing using for loop


majocmatt

Recommended Posts

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
Link to comment
Share on other sites

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.
Link to comment
Share on other sites

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.
Link to comment
Share on other sites

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.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.