custom printing

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View

is it possible to print certain details on a fixed area of a paper
using PHP?

here's the scenario:

i'm trying to print labels with names and addresses. the names and
addresses are stored in the database.

after i retrieve the details, i should be able to print as many (or as
less) number of details as many (or as less) number of times at a
specified position.

for example if i have a sheet of paper that can hold 12 addresses with
4 rows and 3 columns, i can have the page marked areas as

a11 a12 a13
a21 a22 a21
a31 a32 a33
a41 a42 a43

each of which denotes a label.

is it possible to print the label say at position a32? or 2 labels
starting at position a33 and a41? (assuming we are printing it in a "Z"


Re: custom printing

r6uji7 wrote:
Quoted text here. Click to load it

PHP is used to retrieve the information. You should use HTML or,
better, CSS to format your page.  Using CSS you can format your data
one way for the screen and another way for printing.


Re: custom printing

Ken Robinson wrote:
Quoted text here. Click to load it

I do this sort of thing with XML -> XSLT -> XSL-FO -> PDF

Web browsers are not good for reports that rely on pagination. XSLT will
give you complete control of the layout whether your output is PDF or
whatever format. /


Re: custom printing

Quoted text here. Click to load it

Certainly. All you have to know is the documentformat you need to print.
You could generate eg postscript or pcl and send that directly to a
printer, or you could render pdf/html/rdf/doc/images and send that to a
program capable of rendering/printing the specific format.

Re: custom printing

Here's another suggestion: export the address labels from PHP as an XML
file, and use an application like InDesign to import it into a predefined

see <


phil [dot] ronan @ virgin [dot] net /

Re: custom printing

Quoted text here. Click to load it

If you want to get precise print out, you pretty much have to use PDF. PHP
has functions for creating PDF files. Printing out a grid with text should
be fairly straight forward to implement. Just look in the PHP online manual.

If you don't want to bother with that, a really dumb way to achieve that
same thing is to create an uncompressed PDF file with placeholder text
strings, something like

11111111  22222222  3333333
44444444  55555555  6666666

then do a search and replace on the placeholders. Just need to keep the
number of characters the same, padding with white spaces  when necessary.

Re: custom printing

r6uji7 wrote:
Quoted text here. Click to load it

As others have already pointed out, PDF is a good way to go with this.
For simple PDF-creation (actually quite advanced as well if you put your
mind to it), I recommend the FPDF class. /

It doesn't require PDFlib, nor does it require PHP to be (re)compiled
with PDFlib-support, and it's very easy to use. It's also free, as
opposed to PDFlib which costs /$450 for commercial use. On the FPDF
website you'll also find a script that extends the class which lets you
print labels very easily - all you need to know is the dimensions of the
label-sheet(s) you want to support and add them to the script. I've been
using that for a while and it works flawlessly :)

Roy W. Andersen
ra at broadpark dot no / /

"Hey! What kind of party is this? There's no booze
and only one hooker!"          - Bender, Futurama

Re: custom printing

thanks one and all for your inputs! i guess fpdf seems like a good
option to start with before i can confidently move onto xml/xsl stuff.
thank you everyone once again.

Re: custom printing

r6uji7 wrote:
Quoted text here. Click to load it

Good luck with that. Remember that you are restricting your reports to
rely on php. If you have another project that needs to print the same
report from a different language, you are out of luck. I don't know of
many companies using XSL-FO. The one I know that does just offered me a
job based on that skill set alone.

It can be time consuming to learn the XSLT and XSL-FO language, but the
results are tenfold. I know this isn't the proper group to discuss this,
but people developing web applications in PHP need to be aware of better
alternatives to fpdf. Because this is a relatively new language, there
are not very many GUI programs to help write the translation style
sheet. In time the prices will drop for them and maybe a "good" open
source one will fall out.


Site Timeline