views:

105

answers:

7

I like to print a document. The content of the document are tables and text with different colors. Is there a lightwight printer-file-format which i can use like a template?

PS, PDF, DOC files i think are to heavy to parse. May there exist some XML or YAML file format which i can

  1. Easy create (maybe with a WYSIWYG-Editor)
  2. Can parse and manipulate with Library-Support
  3. Can send to the printer

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

Tanks!

+2  A: 

I think postscript is the markup language used by printers. I read this somewhere, so correct me if postscript is now outdated.

http://en.wikipedia.org/wiki/PostScript

Alexander Rafferty
_some_ printers, not all. Specifically... postscript printers ;)
Oded
It's not outdated, but it's not the easiest thing to code in for the application stated in the question. PDF is basically the evolution of PostScript, and that's everywhere....
ראובן
Isn't PDF encrypted?
Alexander Rafferty
@Alexander: PDF supports encryption (though it's [necessarily inneffectual](http://www.cs.cmu.edu/~dst/Adobe/Gallery/anon21jul01-pdf-encryption.txt)), but it's not used too often. Every PDF file I've checked has been compressed, which is closely related to encryption.
outis
+1  A: 

For more powerful suite you can use Latex. It will give options of creating templates where you can just copy the text.

On a more GUI friendly note, MS-Word and other word processors have templates. The issue is they are not of a common standard or markup.

You can also use HTML to render stuff in a common markup but it will not be very printer friendly.

sheki
+1  A: 

I think something like TeX or LaTeX (or even troff or groff) may meet your needs. Google them and see.

There are also libraries to render documents for print from HTML source. Look at http://libharu.sourceforge.net/ for example. This outputs a printer-ready .PDF

ראובן
+3  A: 

There is no universal language that is supported across all (or even many) printers. While PCL and PS are the most used, there are also printers which only work with specific printer drivers because they only support a proprietary data format (often pre-rendered on the client).

However, you could use XSL-FO to create documents which can then be rendered to a printer driver using library support.

Lucero
+2  A: 

A think that Post Script is a really good choice for that. It is actually a very simple language, and it must be very easy to parse becuse it is stack-oriented. Then -- most printers supprort it, and even if you have no support you can use GhostScript to convert for many different formats (Consider GS as a "virtual PS supporting printer"). Finally there are a lot of books and tutorials for the language.

About the parsing -- you can actually define new variables and functions in PS. So, maybe, your problem can be solved (almost) entirely using PS.

Kostya
+2  A: 

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).

Nate