Problem ... I want to print a series of numbered forms
Archive - Originally posted on "The Horse's Mouth" - 2014-10-05 13:44:02 - Graham EllisJust occasionally, we come across problems that sound easy but end up looking like they need specialised software that's going to cost money to buy for a single use, before we evel look at the time to learn into it. One such problem has cropped up today in that I want to print out a series of sequence numbered forms for completion by people at an event (actually the event being on a train!)
Problem ... I want to print a series of numbered forms
will also provide methodology for
Problem ... I want to print a series of sheets with randomised information in some field(s)
Solution
... generate the form as a series of web pages using a PHP Counter
... use a meta refresh to step through the pages
... Add an request to print on load <body onload="window.print()">
... Set up Firefox to silently autoprint
- visit about:config
- confirm you know what you're doing ;-)
- right click on options and select new
- add in print.always_print_silent as a boolean
- set it to true
Basically, we're using Javascript to automatically print, Firefox to print silently, HTML to generate the pages, with meta refresh to step through them, and PHP to increment our count.
Here's a sample PHP page that I used to test out this mechanism - it prints out five pages ...
<?php
$page = 1;
if ($_REQUEST[page]) $page = $_REQUEST[page] + 1;
?>
<html>
<head>
<?php if ($page < 5) { ?>
<meta http-equiv="refresh" content="10; url=?page=<?= $page ?>">
<?php } ?>
</head>
<body onload="window.print()">
Hello World - page <?= $page ?>
</body>
</html>
More about setting the Firefox option [here].
We teach PHP [course details] ...