If I understand it right, a printer is also a file from the operating system’s view. Can I get a .NET C# FileStream type for a printer? It seems wild to do this.
Thanks in advance.
If I understand it right, a printer is also a file from the operating
Share
A printer is modeled in Win32 as a set of bitmaps. This is wrapped by the
PrintDocument, which basically sets up a callback that lets you draw each page individually and sends them one by one to the printing spooler which then sends the data (in .ps format usually) to the printer.This is how modern printers operate, they draw pages, not text. Only the old school matrix printers drew text character by character, in a stream-like fashion. They used to use the “PRN:” special file. This has lost all meaning in a modern environment however.
The good news is, it’s really easy to work with the
PrintDocumentclass, you get aGraphicsobject for each page that you can use to print text anywhere on the page, as well as draw graphics.You can simulate a stream-like printer if you so wish by caching all the data then just calling
DrawTextfor every page.