Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
roadhead
Dec 25, 2001

I have a receipt printer, connected to a cash drawer that takes plain text input (with special control characters for drawer popping and paper cutting) outputting formatting receipts in my software.

The catch is I have to support a variety of printers with different control codes (easy), widths (harder) and demonic possessions (hardest).

So what I'm looking for is an easy way to use an existing layout language (LaTeX, HTML, etc.) to layout a document that eventually is put into a String on which getBytes() is called and 100% plain vanilla already formatted text with the right column alignment and justifications.

I'm leaning heavily towards either HTML or some horrible hack of ReportMill - but I'm open to ideas and conjecture, as I've got a little while to think about this.


I'll be storing the "templates" in the database and they're accessed from just a plain text field, since thats how they end up when sent to the printer :/

Adbot
ADBOT LOVES YOU

roadhead
Dec 25, 2001

I'd like to Parse an HTML-formatted String (so I can get tables at a certain width, columns either justified or centered, other simple stuff).

Once this data is "rendered" I need to pop it back into a plain String (still formatted using absolute spaces and cr/lf) to feed it to a receipt printer.

Am I crazy?

I have to make a bunch of these receipts, and they have to dynamically adjust their width based on the printer model. The end result would be exactly like what you get if you rendered the HTML in a browser, then copied and pasted it into a non-HTML aware application.


So, is this going to be possible with the Java standard library? I'm using javax.swing.text.html.HTMLDocument right this second.

Any other ideas ?

roadhead
Dec 25, 2001

TRex EaterofCars posted:

There is a mature Java curses lib, and it's pretty awesome. A guy at work popped out a tabular pgsql database stats browser with it in a day.

I'm curious why roadheads' implementation has to be in java and not something like LaTeX or PS. Those languages are made for type-setting.

It has to be in Java because thats what we use, the whole project is in Java. Seven years in the making, the end-all be-all of hardware store software. AP, AR, GL, PoS, Inventory, Payroll etc. I'm just one person out of many, and this is what I've been stuck with lately :)

Some of the foundation for this area has already been laid and a single "receipt" template completed, but the formatting was all in lots and lots of lines of actual Java code, no template being stored in the database at all. I was hoping to write something that would lay out my template, put it to a formatted string, with several "replaceable" variables for the content that is transmitted from the PoS terminal. That part is already in place in our String utilities, so I don't have to worry about that, just the layout part :)

Since a customer could have any model of printer, the width of the form is defined run-time, which is why I wanted to use HTML and set the width of the table with a resolvable variable.

Does this explain it better at all ?

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply