cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Corda, Ugo" <>
Subject Created PrintFormatter for Cocoon 1.7.2
Date Sat, 22 Apr 2000 00:33:20 GMT

I created a Print Formatter for Cocoon 1.7.2 so that I can experiment with
printing XML documents. Because of current limitations of both Cocoon 1.7.x
and Java 1.2.2, this functionality will make most sense only in Cocoon 2,
using Java 1.3 for the FOP part. But I thought it would be helpful to
already have an idea of how XML printing can work under Cocoon 1.7.x.

Most of the code in comes from the FOP file, which Stanislav Gorkhover recently wrote. In addition
to that code, I created a simple response message that is returned to the
client in HTML form once the print job has been submitted.

In order to use the PrintFormatter, I made the following modifications to
the file:

-	added the line "browser.n = printer=Printer" under the User Agents
-	added the line "formatter.type.text/print  =
org.apache.cocoon.formatter.PrintFormatter" under the XML Formatters section

I also modified my XML and XSL files this way:

-	added the line "<?xml-stylesheet href="myPrintStylesheet.xsl"
type="text/xsl" media="printer"?>" to my XML file
-	added the line "<xsl:processing-instruction
name="cocoon-format">type="text/print"</xsl:processing-instruction>" to my
XSLT-FO file

Finally, my URL request looks like
<http://myCocoonServer/myXMLfile.xml?user-Agent=Printer&cache=false>  (the
cache needs to be disabled during this request, otherwise the document
cannot be printed again after the first request is received by Cocoon -- in
other words, caching the response to the client does not make much sense in
a printing context).

The FOP component that renders the FO tree to the printer driver currently
uses Java 1.2.2. This version of Java has rather minimum printing
capabilities. In particular, you cannot specify programmatically the name of
the printer you want to print to, nor the job ticket information. (Under
WinNT the printer used is the one set as the default printer on the server
running Cocoon).

This mechanism can also be used with pseudo print devices, like a fax driver
or the Adobe PDFWriter. The problem with this type of drivers, though, is
that they usually pop up an interactive dialog, which does not make any
sense in the context of a Cocoon server. I hope future versions of Java
Print will address this limitation.

Ugo Corda
Xerox Corp.

View raw message