By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,067 Members | 1,849 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,067 IT Pros & Developers. It's quick & easy.

custom printing

P: n/a
hello,

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"
format)

regards,
ranjit

Jul 17 '05 #1
Share this Question
Share on Google+
8 Replies


P: n/a

r6uji7 wrote:
hello,

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.


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.

Ken

Jul 17 '05 #2

P: n/a
r6uji7 <r6****@gmail.com> wrote:
is it possible to print certain details on a fixed area of a paper
using PHP?

here's the scenario:

[snip]

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.

Jul 17 '05 #3

P: n/a
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
template

see <http://www.adobe.com/products/indesign/crossmedia.html#xmlID>

Phil

--
phil [dot] ronan @ virgin [dot] net
http://vzone.virgin.net/phil.ronan/
Jul 17 '05 #4

P: n/a
Ken Robinson wrote:
r6uji7 wrote:
hello,

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.

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.

Ken


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.

http://xml.apache.org/fop/

-JI
Jul 17 '05 #5

P: n/a
"r6uji7" <r6****@gmail.com> wrote in message
news:11*********************@f14g2000cwb.googlegro ups.com...
hello,

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


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.
Jul 17 '05 #6

P: n/a
r6uji7 wrote:
hello,

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


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.

http://www.fpdf.org/

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 / http://roy.netgoth.org/

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

P: n/a
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.

Jul 17 '05 #8

P: n/a
r6uji7 wrote:
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.


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.

http://groups.yahoo.com/group/XSL-FO/message/2344

-JI
Jul 17 '05 #9

This discussion thread is closed

Replies have been disabled for this discussion.