0

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

Jeff Foster
  • 43,770
  • 11
  • 86
  • 103
manav inder
  • 3,531
  • 16
  • 45
  • 62
  • It's not clear *what* exactly is a pain. If you could post a sample of code so we can try to refactor it, that would make it easier to help you. – Jon Skeet Jul 20 '11 at 13:53
  • 1
    Perhaps get your organisation to stop messing around using dot matrix printers and upgrade! – m.edmondson Jul 20 '11 at 13:53
  • 1
    Surely buying a new printer is cheaper than all that development time? – Iain Galloway Jul 20 '11 at 13:54
  • 1
    I assume you know you can now do "multi part printing" on a laser printer, see http://www.royalegraphics.co.uk/html/ncr-laser-paper.html for example. – Ian Ringrose Jul 20 '11 at 13:58

4 Answers4

2

You can export the dataset to XML (DataSet.WriteXml) and transform it to another textual format using XSLT.

Oded
  • 489,969
  • 99
  • 883
  • 1,009
1

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.

Community
  • 1
  • 1
Ian Ringrose
  • 51,220
  • 55
  • 213
  • 317
1

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.

jonsca
  • 10,218
  • 26
  • 54
  • 62
Vijay Gill
  • 1,508
  • 1
  • 14
  • 16
0

use tabs for everything. it will let you put stuff in tab columns automatically.

marinara
  • 538
  • 1
  • 5
  • 10