Printing unformatted text to label printer

Forums for specific tips, techniques and example code
ChrisClark
Posts: 11
Joined: Tue Apr 20, 2010 8:14 pm

Printing unformatted text to label printer

Postby ChrisClark » Tue Apr 20, 2010 8:37 pm

I am trying to print raw text printer commands to a label printer and using the printer.printUnformatted method. What appears to be happening (seen when printed to file) is additional printer commands other than what I am sending through are being included and this results in a blank label being printed at the end of the label print when I call printer.close. Other applications printing the text to the same printer driver don't produce the additional commands.

Reading through other items on the forum I see comments that suggest printUnformatted perhap isn't reliable and developers have resorted to creating external dlls for this.

Is that the path I will have to go down also or can someone suggest any alternatives please? I find it hard to believe that Jade does not support printing plain text out. Perhaps there is something in the driver settings but i've looked through all of them and doesn't seem obvious. As stated other applications using the same printer driver (and print to file) produce the correct text.

I'd definitely appreciate any pointers people may have.

Thanks
Chris

bdoolan
Posts: 19
Joined: Fri Aug 14, 2009 7:26 pm

Re: Printing unformatted text to label printer

Postby bdoolan » Tue Apr 20, 2010 9:55 pm

Hi Chris,
Yes printing is always a hassle.

I generate html on the server from templates I created and find this works very well. Each document I want to generate has its own set of templates which allow parameterisation of the final document. If there are only a few dozen document types to be generated, this hand-crafted approach can be very suitable. Printing the document is then, obviously, via a browser on the client.

Experience shows that Firefox is the best browser to target using this technique since (on Windows at least) it allows good control over Page Setup and adheres closely to most of the browser standards. Having said that most browsers will often produce the right result, earlier versions of IE excepted. I even use this successfully to print onto bespoke labels which have a very precise region where the text has to be printed, so accuracy in positioning is vital.

More recently I developed Java code based on YaHP (Yet another HTML to PDF Converter, LGPL (GNU) licence) which converts the html to pdf on the server. This got round most of the Browser issues. YaHP actually uses a pluggable renderer on the server so the results are almost identical to what is printed using the html on the browser.

Cheers, Brendan


Return to “Tips and Techniques”

Who is online

Users browsing this forum: No registered users and 11 guests

cron