how do I design and print labels off a website?

Ye' old general discussion board. Basically, for everything that isn't covered elsewhere. Come here to shoot the breeze, shoot your mouth off, or whatever suits your fancy.
This forum is not for asking programming related questions.

Moderator: General Moderators

LordMerlin
Forum Newbie
Posts: 12
Joined: Mon Dec 05, 2005 11:48 am
Location: South Africa

how do I design and print labels off a website?

Post by LordMerlin »

I'm not sure whether this is a Java / Java SCRIPT / PHP question, but let's try :)

We're busy developing an in-house CRM / ERM, and we need to be able to design and print label for pill dispense bottels.

Our requirements are as follows:
Design the general label layout, including size and text. Graphics isn't really needed.
Add info from a MySQL DB to the label, like patient name, medication / drug info, etc
Print it via a webpage.

Java would probably be the best, though I don't know Java, but I'm sure I can get to grips with it :) The system is written on in PHP, with a MySQL DB, and runs off a Linux server. But we'll have Windows & Linux PC's connecting to it via the web (on a VPN) using firefox.

Any suggestions, resources, info?
User avatar
Skittlewidth
Forum Contributor
Posts: 389
Joined: Wed Nov 06, 2002 9:18 am
Location: Kent, UK

Post by Skittlewidth »

We had to do a similar thing here with address labels about a month ago.
Unfortunately in the end I wasn't the one who carried out the work so I couldn't say step by step how to do it, but we connected our Mysql DB to Access using an ODBC driver, which has wizards for address labels and reports and the like.

I'm by no means a fan of Access but this technique can come in handy when you're working with clients who are used to the Access interface but need to be connected to data in MySQL.

Maybe you need a bit more than this, if you want to design individual labels though.
Grim...
DevNet Resident
Posts: 1445
Joined: Tue May 18, 2004 5:32 am
Location: London, UK

Post by Grim... »

I recommend Word (or equivalent, before the MS bashers jump in and take this off topic) and Mail Merge. Printing things in a specific position with a web page is very hard - it depends on the browser, printer and PC Setup.
Also bear in mind that printing from a web page will include print headers and footers (with the page address, etc).
LordMerlin
Forum Newbie
Posts: 12
Joined: Mon Dec 05, 2005 11:48 am
Location: South Africa

Post by LordMerlin »

Seems like my question was a bit mis-understood. I don't want to install and use any client side software to be able to print. I want this to be part of the webpage structure, so a client only needs a printer, and web browser to be able to print the labels. Access isn't cross platform capable, and requires licensing, which won't work in the environment where it'll be implimented.

I'm not quit sure how to accomplish this, but I'm thinking of having something in place which could create an image, or PDF document at a set size (say A4 (I'm not sure how to determine that), and then send that to a system attached printer? Only thing is, the client should be able to "design" the labels, somehow, similar to what open office / klabel / word can do it?
User avatar
jayshields
DevNet Resident
Posts: 1912
Joined: Mon Aug 22, 2005 12:11 pm
Location: Leeds/Manchester, England

Post by jayshields »

Generating a PDF sounds like a good idea to me, but the client will need a PDF viewer installer, but they are free...
User avatar
Bill H
DevNet Resident
Posts: 1136
Joined: Sat Jun 01, 2002 10:16 am
Location: San Diego CA
Contact:

Post by Bill H »

Unless I have misunderstood the original question, there is some overthinking going on. In what way does a PDF help? He said graphics is not needed.

Just output the text for the label. PHP/MySQL is very good at that. Give some space and print a line telling the user to hit the print button on his computer and use a pair of scizzors to cut the label out.

Not trying to be rude, but wherein lies the complexity?
LordMerlin
Forum Newbie
Posts: 12
Joined: Mon Dec 05, 2005 11:48 am
Location: South Africa

Post by LordMerlin »

Yes, or even if I can get it to generate an image, .jpg / .tif / .gif / .png, that could also eliminate the client to have anything other than a printer and a web browser installed :)
Grim...
DevNet Resident
Posts: 1445
Joined: Tue May 18, 2004 5:32 am
Location: London, UK

Post by Grim... »

Grim... wrote:Printing things in a specific position with a web page is very hard - it depends on the browser, printer and PC Setup.
Also bear in mind that printing from a web page will include print headers and footers (with the page address, etc).
Gosh, which clever person said that? ;)
LordMerlin
Forum Newbie
Posts: 12
Joined: Mon Dec 05, 2005 11:48 am
Location: South Africa

Post by LordMerlin »

Hi Bill H

It seems like you might be able to help me after all :)

What I meant with graphics is not needed, is. The labels mainly need to contain text, and maybe a border around it, though that would be optional.

What I'm trying to accomplish is as follows: (Restated)
Let's say I have an A4 sheet with labels, say 3 across, and 10 down, and I want to print info onto those labels, some standard text, like "Patient Name", "Presciption", "Date", etc etc, and then some variable text, taken from a DB, which has the patient name, today's date and so forth. This must be printed from a webpage, using the normal print command in any browser, meaning I'd be able to print it out on my printer on my desk, or one shared over the network.

What I would like to be able to accomplish, is to have some sort of control over how the labels look, where which fields must go, what font to use, etc. I would like to be able to print out say a 1000 label for a specific medicine / pill / drug. It's almost like printing out an address list, but via the web :) If it needs to first create a PDF / JPG / TIFF / PNG in order to set the correct dimentions for a printer, then that's fine as well
User avatar
Bill H
DevNet Resident
Posts: 1136
Joined: Sat Jun 01, 2002 10:16 am
Location: San Diego CA
Contact:

Post by Bill H »

AHA: a whole bunch of labels. I didn't get that part.

You're right, it is much like an address list, and I have done a few of those. Unless you need images for the type of pill or something (which your op said you don't), you can still do it with plain text. Study on how to output a DB in columns and rows.

The tricky part is pagination. HTML doesn't do that at all and most browsers don't yet support the CSS that does it. What I do is count the rows and end the output, displaying only one page at a time, maintaining the starting and ending points in $_SESSION vars. Let the user click his/her browser's "print" button and then a displayed "next" button for the next page of labels. You can make that "next" button invisible if you like for printing purposes. I sometimes make it a transparant gif 30px high by the width of the page below the list so it's clickable but doesn't print. Be sure to tell the user in advance, of course.

Edit: I should add you need to output the text in specific sizes, either pts or px, and tell the user not to screw around with his browser settings for the list. That's burned me a couple times. You can also direct them how to remove the header and footer from the printed page.
User avatar
onion2k
Jedi Mod
Posts: 5263
Joined: Tue Dec 21, 2004 5:03 pm
Location: usrlab.com

Post by onion2k »

PDF is ideally suited to this. Putting together a system with FPDF would be very easy.
LordMerlin
Forum Newbie
Posts: 12
Joined: Mon Dec 05, 2005 11:48 am
Location: South Africa

Post by LordMerlin »

Bill, I get what you're saying, and I know how to pagnate in PHP. But, surely I can't have the user pres the "next" button the whole time, especially if he needs to prints a few thousand labels @ a time? How did you get around that? Would you mind sharing some simple samples of how to get this done? This is something alltogether new to me

onion2k, you say PDF would work great for this, please elaborate, if you don't mind. Wouldn't that put extra load on the server? And if I create a PDF file to be printed, then the client would need a PDF viewer to open, and the print it, right. Is there a way of the PDF file being printed automatically, on the fly? Basically, I want the user to simpy select the data to be printed, maybe select the label template (since there are a few different size labels), and then tell it to print.

But this still doesn't answer my other question (unless I don't understand all your answers). Is there a way for the user to design the label layout? Or will it have to be pre programmed into the script? What happens if they want to change the layout, to let's say bigger labels (meaning there will be less labels on the page), or they want to print to a label printer, which has a single row of labels, instead of an A4 sheet with either 2 / 3 / colomns with labels.

Is this getting too technical? Kbarcode has a MySQL database with plenty Avery type labels, which I'm sure I can use as a base for the label sizes? But let's say they get custom size labels which they want to print on, I should have a way of them adding a label into the system. How would I be able to work around that? To me it sounds like I would need to make my HTML tables dynamic, but how? Somehow I would then need to let the system know that it needs to print 2 rows of labels, 50mm from either side, 20mm apart, and 10 above the previous one. Does HTML know about METRICS, or does it only work with pixels?
User avatar
onion2k
Jedi Mod
Posts: 5263
Joined: Tue Dec 21, 2004 5:03 pm
Location: usrlab.com

Post by onion2k »

LordMerlin wrote:onion2k, you say PDF would work great for this, please elaborate, if you don't mind. Wouldn't that put extra load on the server? And if I create a PDF file to be printed, then the client would need a PDF viewer to open, and the print it, right. Is there a way of the PDF file being printed automatically, on the fly? Basically, I want the user to simpy select the data to be printed, maybe select the label template (since there are a few different size labels), and then tell it to print.
Re server load: generating a PDF file takes no more effort than generating a medium size HTML page.
Re needing a PDF reader: Yes they'd need one .. but find me a PC that doesn't have one and I'll be very suprised. Acrobat has been bundled with Windows for years, OSX is entirely based around PDFs for display, and Linux has one that I can't remember the name of.
Re automatically printing: Sure.. look at the 'autoprint' example on this page: http://www.fpdf.org/en/script/script36.php

EDIT: Re metrics .. PDF can do that. HTML can't.
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

you say PDF would work great for this, please elaborate, if you don't mind.
It is great because you can control everything from exact positioning of the elements (impossible to do in a browser because there are too many variables to consider, such as resolution).
Wouldn't that put extra load on the server?
Of course it will, to what extent I am unsure. There are several weighing factors, such as how many hits and concurrent pdf generations you have going simultaneously. Anything you add to your page is going to increase server load in one way or another :cry:
And if I create a PDF file to be printed, then the client would need a PDF viewer to open, and the print it, right. Is there a way of the PDF file being printed automatically, on the fly?
Right. But remember we are trying to avoid printing from the browser because lots of bad things can happen there. Labels could be split in half at the page breaks, etc. I really don't see the inconvinience of this, it is one minor step of a program being automatically opened, and clicking print from there instead of the browser.
onion2k wrote:Re automatically printing: Sure.. look at the 'autoprint' example on this page: http://www.fpdf.org/en/script/script36.php
Now you have no excuse ;)


But this still doesn't answer my other question (unless I don't understand all your answers). Is there a way for the user to design the label layout? Or will it have to be pre programmed into the script? What happens if they want to change the layout, to let's say bigger labels (meaning there will be less labels on the page), or they want to print to a label printer, which has a single row of labels, instead of an A4 sheet with either 2 / 3 / colomns with labels.
If you take some time to look at the functions for modifying and creating PDF documents, you'll find it is extremely customizable. I have been using PDF generation to generate reports with several different optional templates, store in the database. Having a couple saved templates would be ideal and allow the user to choose, but the power comes in since you could allow users to select the dimensions, etc.

Now the more user modifiable you want this the more complex it's going to get, obviously. Your going to have to make several calculations on how many labels you can fit on a page (which shouldn't be too dificult) without having labels overlapping or whatever. I would keep it simple by offering a dozen or so different templates each with different dimensions, that way you can avoid all the hassle in the first place.
Is this getting too technical? Kbarcode has a MySQL database with plenty Avery type labels, which I'm sure I can use as a base for the label sizes? But let's say they get custom size labels which they want to print on, I should have a way of them adding a label into the system. How would I be able to work around that? To me it sounds like I would need to make my HTML tables dynamic, but how? Somehow I would then need to let the system know that it needs to print 2 rows of labels, 50mm from either side, 20mm apart, and 10 above the previous one. Does HTML know about METRICS, or does it only work with pixels?
Back to my last point, this can get overly complicated with how you are wanting to approach this. First of all, you are not using html, you are creating shapes and lines with positions on the sheet. Have a read of the pdf library function.
LordMerlin
Forum Newbie
Posts: 12
Joined: Mon Dec 05, 2005 11:48 am
Location: South Africa

Post by LordMerlin »

Thanx Jcart.

Let's see if I can get this done :) PDF does make sense, you're right. At this stage I'm just trying to get this done the quickest possible way, and unfortunattely after a few days searching on the web, I couldn't find anything. You're input has steered me into a direction to follow, let's see what come of it :D
Post Reply