Search code examples
c++xmlmfcprintingmarkup

Is there such a thing like a Printer-Markup-Language


I like to print a document. The content of the document are tables and text with different colors. Does a lightwight printer-file-format exist, which can be used like a template?

PS, PDF, DOC files in my opinion are to heavy to parse. May there exist some XML or YAML file format which supports:

  1. Easy creation (maybe with a WYSIWYG-Editor)
  2. Parsing and manipulation with Library-Support
  3. Easy sending to the printer (maybe with Library-Support)

Or do I have to do it the usual way and paint within a CDC?


Solution

  • I noticed you’re using MFC (so, Windows). In that case the answer is a qualified yes. In recent versions of Windows, Microsoft offers the XPS Document API which lets you create and manipulate a PDF-like document using XML, which can then be printed using the XPS Print API.

    (For earlier versions of Windows that don’t support this API, you could try to deal with the XPS file format directly, but that is probably a lot harder than using CDC. Even with the API you will be working at a fairly low level.)

    End users can generate XPS documents using the XPS print driver that is available for free from Microsoft (and bundled with certain MS products—they probably already have it on their system).