PROJECTS

C++ Printer Stream

 

Description

C++ printerstream is a simple template extension of the standard C++ output stream. With this class you can redirect the output from a C++ application directly to a printer which then prints the output as a plain text.

You have several options when creating a new instance of printerstream, you can either let the printerstream to ask the user which printer to use, specify a printer name explicitly or supply a valid drawing context.
The output gets printed when the instance of printerstream class is disposed or you explicitly call the end method.
This is a very simple approach with limited functionality, the only option you can change are the page margins.

Example code

#include "printerstream.h"

using namespace std;

int main()
{
  // Initialize output to a printer using PDFCreator
  printerstream<wchar_t> printer("PDFCreator");
  // Set margins to a 5% of the document width
  printer.margins(page_margins((printer.page_width() / 100) * 5));
  // Begin printing a new document called "Test"
  printer.begin("Test");
  // ... print here
  printer << "Hello world";
  // This can be omited
  printer.end();

  return 0;
}

Requirements: