You're wonderful application is finished ... but the users want printing???. What to do? A computer screen is not a set of paper-sheets and therefore there is no trivial answer to this question. It depends on the nature of the data that needs to be printed, and also on the operating system used.
In Unix , printing is achieved by producing a document in a format that can be understood by the print-spooler program, normally either plain text or PostScript. If formatted text and/or included graphics are required it is often desirable to produce input for a formatting program, call the formatter and send the result to the printer.
In Windows the printer is not driven by a document, but using a series of calls on a GDI (Graphical Device Interface) representing the printer. The good news of this is that whatever you can get on the screen you easily get on the printer. The bad news has been explained above: paper is not the same as your screen. It has pages, is generally worse in colour-handling but provides a much higher resolution. The users do not expect a series of screendumps from your applications. Most Windows applications however are WYSIWYG and there are no established standards for formatting applications.
Below is a brief overview of the options available.
<-
postscript that
creates an Adobe PostScript representation of the object. For most
objects used in diagrams (lines, curves, text), the produced PostScript
is clean PostScript ready for perfect scaling. The remaining objects
(for example a menu or button) are translated into an image
which is then translated to PostScript. Such objects scale poorly.
This facility is useful for creating high-quality diagrams that can be imported in a text created on an external application. This is fairly portable, but using Microsoft applications you must have a PostScript printer attached and there is no previewing. On Windows platform there is no well-supported automated way to print a PostScript file unless you can asks your users to install a PostScript viewer such as Alladin GsView.
notepad /p
"file"
. This route provides no support for graphics or any kind
of advanced formatting.
The library(http/html_write)
library described in section
?? provides a good infra-structure for emitting documents in HTML or
another SGML or XML dialect. There is no such library for LaTeX , but
this can be designed using the same principles.
Using HTML, the application can be transformed into a web-server using the infrastructure described in section 11.9. The user can use standard web-technologies to process the page. Unfortunately well-established web technology does not support vector-drawings, though the emerging SVG technology may change that.
An example of exporting Windows Metafiles is in PceDraw in the file
library(draw/canvas)
.
Formatting text in sections, paragraphs lists, etc. is provided by the XPCE document-rendering classes described in section 11.10. These classes cannot handle pagination though. Another alternative is the use of editor and friends, drawing the text_image on a page while traversing through the document.
An example of printing using win_printer is in PceDraw in the
file library(draw/canvas)
.