I looked around and didn't find many working samples of this... actually none at all but lots of questions about non-working code snippets. There may be some out there, and better than this basic one. I just didn't find any.
This version does not deal with top/bottom margins, colors, images, drawing, paper tray or size selection, orientation, etc. It only prints in whole lines (or multiples if you have embedded newlines), long lines should wrap.
I have attached an archive here containing a small demo Project that uses UPrinter.
Utf8Reader is is class for reading UTF-8 encoded text files. It in turn makes use of the Utf8Codec class. For this demo a UTF-8 CSV file is read as a source of sample Unicode text to print.
ParseCSV is here because the sample data is a CSV file and I want to split the data into fields and then print them with Tabs in between.
Each line of text after the first (heading) line is printed twice in this demo. The only purpose of that was to test page boundary overflow detection.
This hasn't been fully tested so it may fail with some printer drivers. As already stated it is an incomplete and minimal example but it should serve as a starting point if you want to implement more functionality.
![Name: sshot.jpg
Views: 128
Size: 51.2 KB]()
Updates:
New version replaces the earlier attachment here. A few small bug fixes, added properties TopMargin and BottomMargin and method KillDoc.
This version does not deal with top/bottom margins, colors, images, drawing, paper tray or size selection, orientation, etc. It only prints in whole lines (or multiples if you have embedded newlines), long lines should wrap.
I have attached an archive here containing a small demo Project that uses UPrinter.
Utf8Reader is is class for reading UTF-8 encoded text files. It in turn makes use of the Utf8Codec class. For this demo a UTF-8 CSV file is read as a source of sample Unicode text to print.
ParseCSV is here because the sample data is a CSV file and I want to split the data into fields and then print them with Tabs in between.
Each line of text after the first (heading) line is printed twice in this demo. The only purpose of that was to test page boundary overflow detection.
This hasn't been fully tested so it may fail with some printer drivers. As already stated it is an incomplete and minimal example but it should serve as a starting point if you want to implement more functionality.
Updates:
New version replaces the earlier attachment here. A few small bug fixes, added properties TopMargin and BottomMargin and method KillDoc.