For my graduation project we needed the ability to print a couple of bills etc. Printing lines was pretty simple with the LinesPrinter i blogged about a while ago. We had two choices: either implement a specific print method for each module or implement a reusable markup system. Obviously we went for the second option and came up with something alike BBCode. The codes we implemented are
Since the code is written to work on a Graphics2D device you can also render the formatted text on a jpanel etc instead of a printer device. Here is a screenshot of a generated bill (on a jpanel):
Feel free to download, try and improve the rpcode.zip package.