views:

40

answers:

1

Hi, I'm new to web development so please, could you help me to understand if I'm working in the right direction?

There will be a webpage intended for our customers (not intranet) from where they can print labels. Some of the larger customers will have special label printers where configuration and printing using COM-port is the only acceptable option. Basically we have very limited knowledge and control over their environment.

The web-page itself will be a pretty simple html-page or more complex AJAX.

After the customer inputs all the data and happens to chose this type of printing we have following tasks: 1) get data about the printers on the customer's system installed to a comport and if possible get printer settings (like paper size and orientation). Ideally would like to be able to adjust the settings, but if it is a pain can just put into requirements that your printer must be installed to COM1 and configured correctly. 2) send commands and read answers and send PCL code to the selected com port

As I understand I'll need to install something on the customer's machine to be able to talk to com port and get any settings. Just HTML+Javascript are not capable of doing that. Right?

I found RXTX library which seems to communicate to com port on most platforms. Can it be called from JavaScript or I still need to do a Java plugin? Are there technologies other than Java plugin that would solve the task?

The web-page will be used in different environment - platforms and web-browsers. We would like to minimize the number of customized solutions. Will Java allow us to do the same plugin for all environments with minimal customization?

If we require the user to install a plugin will the user be prompted with our credentials to confirm the installation? Will our web-site require higher trust settings?

Thanks for you help!

A: 

Well, I've had to do this in the past. Here is what I did and the circumstances

1) I knew that our customers were in a windows environment so I wrote win32 software to handle the printing.

2) I created a file format to be read by the win32 software that allowed me to specify print parameters and the label data. XML works ok for things like this.

3) My web app created a file in the format used by the win32 software and returned it to the user when they clicked on the "Print Labels" button. The file extension on the file returned was registered by the installer of the win32 software. That means when their browser looked for a default app handler for that file, it found my win32 software.

Bottom line is that the browser is handing off the printer communications to a native application instead of talking directly to the printer.

Obviously you need to be able to dictate your end user's are using a windows machine (or mac or whatever you can write native code). Associating a file extension with my program and returning that file to the user was the key to making the process work for me.

Whether your native code sends pcl directly to the printer or translates into a print api (like the win32 api as mine does) is another consideration.

Another approach you could consider is instead of sending PCL codes, you could create a PDF of the document. Format the document to the size and orientation of the label printer. The user will still have to hit the print button, but that might work. I have done this for printing to bar code printers and it works fine. Sometimes getting the margin and orientation correct is a little tricky, but that can be figured out.

Don Dickinson
Thanks Don!Yeah, creating PDF was my first choice as it is so easy! However, for those printers, printing from PDF is 3-4 times slower than from PCL and there are concerns that the bar-codes printed from an image (like in PDF) may fail to scan (PCL will tell the printer to create the barcode instead on passing on the image). Any of the two reasons make PDF unacceptable option for us.Were there any particular reasons why you did not use applets or a similar approach?
Yana
@Yana: PDF isn't just images, it's actual formatting instructions (like PostScript) to the rendering device (display, printer, whatever). I would be surprised if there were problems scanning bar-codes printed through PDF. (But the speed issue you found might still be a problem for you.)
Greg Hewgill
@yana I haven't found any problems with pdf's and bar codes. but, i'm doing pretty simple bar codes (no 2d or 3d). its just lines and spaces. i didn't do applets because i've never done them and don't have experience with them. the solution i came up with worked just fine.
Don Dickinson
@yana - one more thing about the pdf web app ... i was printing packing labels with GCC128 barcodes on them. the barcodes were printed with a line command in the pdf library (not a graphic). the only problem i've ever had was when someone was sticking the label over the top of a barcode already on the box. the barcode under the label was showing through a little. so this was an issue of the quality of paper used for the label and/or the positioning of the label, not the fact that the label was printed from pdf.
Don Dickinson