Reputation: 3601
I am working on c# .net application, and using crystal reports. I need to print crystal reports on dot matrix printer, but speed of printing is very slow as crystal reports prints in graphical mode. So i moves to dos based printing and use RawPrinter helper class to print it. That works completly fine.
But writing a dataset to a text file(in invoice report format), uses lots of string manipulation for positioning the characters, spacing etc. I use string builder class and padding and lots of if, else to print page totals, grand totals, taxes etc.
Writing a text file in this way is such a pain.
Please suggest me some other feasible and effective approach.
Thanks
Upvotes: 0
Views: 609
Reputation: 1518
I had a similar issue and changing printers was not a solution because of 1800 or so clients using dot matrix printers. So solution I came up with was to use a templating engine (StringTemplate http://www.stringtemplate.org/), get the output text file and send it to the printer.
Upvotes: 1
Reputation: 538
use tabs for everything. it will let you put stuff in tab columns automatically.
Upvotes: 0
Reputation: 51927
You need some sort of templateing engine, but as you are not doing HTML you need the engine to be stand-alone. See C# template engine for some options.
XSLT is a good option if you like XML and already know how to use it, otherwise I would tend to code with a more "code focused" solution.
Upvotes: 1
Reputation: 499172
You can export the dataset to XML (DataSet.WriteXml
) and transform it to another textual format using XSLT.
Upvotes: 2