Forum Moderators: coopster

Message Too Old, No Replies

Printing 500 client invoices.

- with a web-application

         

Mr Bo Jangles

6:31 am on Sep 23, 2007 (gmt 0)

10+ Year Member



Hi all,
How is this best handled with a web-application? And of course, only want to hit the 'Print' button once.

I can see how to create one very large page with suitable page-breaks for each indidual invoice, but have never done anything like that for a large number of pages - so don't know what and when you run into limitations.

Or is there a more appropriate method whereby you create just one page and cycle the process - but if so, how do you initiate the automatic printer initiation? Can that be done successfuly with some javascript?

I'm happy to assume(require) client machines will have a good level of memory - but in such a process, what issues are you likely to run into? Is page timeout going to occur, etc.

Anyone had experiece with this process?
Grateful for any assistance as always.

phparion

8:53 am on Sep 24, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



it is very easy yet little tricky.

there could be two ways,

1 - make a large page of 500 invoices, not recommended

2 - use a mysql database or xml repository to store your invoices and then run a loop over invoice to create one page for each invoice

then you can use a function like

echo '<A href="javascript:print()">PRINT THIS PAGE!</A>';

you can also make a javascript function for this in header tags and then call it within your loop after displaying your invoice on the page so that it will be done automatically and you won't need to press this PRINT link yourself.

Habtom

8:57 am on Sep 24, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The above response is not a bad idea. You might need to find a way to make small delays between print commands.

Mr Bo Jangles

9:38 am on Sep 24, 2007 (gmt 0)

10+ Year Member



Many thanks phparion for responding (and the other responder too).
In attempting to find out a bit more by googling around, I uncovered one statement (and stated categorically!) that there was absolutely no way that any javascript could ever trigger a printer by itself - i.e. always user input would be required. If that is true, then doesn't it make the 'loop around' solution unworkable?

I'd be very grateful for more comment and advice.

Incidently, how large could I make a html page? If say it was a prudent and workable solution to break the job up into 'print batches' of, say, 50 or so invoices at a time, would that be a good solution?

phparion

9:51 am on Sep 24, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I am not sure why JS print() wont work on a function call,

this need to be done step-by-step

your first assignment is to make sure if print() works in a loop

1 - put it in a function say

function printPage() {
print();
}

2 - then run a loop of 3 runs.

3 - make sure printer is connected

in each run call this function.

if you dont want to waste few pages then keep your page blank white so that your pages will be printed out white :)

see if it works and send three jobs to the printer.

if this step fails according to your research that print wont work automatically then you cannot go further with this, you would need to find another way to make automatic print() calls.

so first try this.

Mr Bo Jangles

9:54 am on Sep 24, 2007 (gmt 0)

10+ Year Member



The article said the there was no way that the js can bypass the Windows printer dialog box coming up i.e. no way to get a direct printer trigger.

Habtom

10:05 am on Sep 24, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Yea, there is an article here [javascript.about.com] explaining why it is not possible.

You might consider creating all the 500 invoices in one PDF file, and print in one print command. That seems easier.