You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Hans-Guenter Stein <Ha...@SiteOS.de> on 2001/06/18 20:12:25 UTC

Formatter for FOP 0.18++

Is there anyone who could send me a version of FO2PDFFormatter which
runs with FOP 0.18++?

I tried the following hack, but the resulting pdf is not correct:

  public void format(Document document, Writer writer, Dictionary
parameters) throws Exception
   {
     Driver driver = new Driver();
     driver.setRenderer("org.apache.fop.render.pdf.PDFRenderer",
Version.getVersion());

driver.addElementMapping("org.apache.fop.fo.StandardElementMapping");
     driver.addElementMapping("org.apache.fop.svg.SVGElementMapping");
     ByteArrayOutputStream out = new ByteArrayOutputStream();
     driver.setOutputStream(out);

driver.addPropertyList("org.apache.fop.fo.StandardPropertyListMapping");


driver.addPropertyList("org.apache.fop.svg.SVGPropertyListMapping");
     deferredInit ();
     ByteArrayOutputStream tempStream = new ByteArrayOutputStream ();
     xmlFormatter.format (document, new PrintWriter(tempStream),
NO_PARAMETERS);
     byte[] tempBytes = tempStream.toByteArray ();

************* the tempBytes array now contains the correct fo-file (is
renders ok, if I run its content through fop-0.19.0 manually) *********

     SAXParser parser = new SAXParser ();
     parser.setFeature("http://xml.org/sax/features/namespaces", true);
    driver.buildFOTree(parser, new InputSource (new ByteArrayInputStream
(tempBytes)));
     driver.format();
     driver.render();
     byte ba[] = out.toByteArray();
     char ca[] = new char[ba.length];
     for(int i = 0; i< ba.length;i++)
     writer.write(ba[i]);
    }

    protected void deferredInit () throws Exception {
        if (xmlFormatter == null)
       {
            xmlFormatter = new
XMLFormatter();//formatters.getFormatterForType ("text/xml");
        }
    }

--
Hans-Günter Stein
Vorstand, SiteOS AG
Weißenfelderstraße 3
85551 Kirchheim/Heimstetten (München)

Tel. +49 - 89 - 90 77 66 00
mail: info@SiteOS.de



---------------------------------------------------------------------
Please check that your question has not already been answered in the
FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>

To unsubscribe, e-mail: <co...@xml.apache.org>
For additional commands, e-mail: <co...@xml.apache.org>


Re: Formatter for FOP 0.18++

Posted by Uli Mayring <ul...@denic.de>.
On Mon, 18 Jun 2001, Hans-Guenter Stein wrote:

> Is there anyone who could send me a version of FO2PDFFormatter which
> runs with FOP 0.18++?

Is this for Cocoon1 or Cocoon2? I think the latter supports later versions
of fop, but the former isn't maintained anymore with respect to fop
integration. The only person, who knew how to do that, apparently left the
Cocoon project completely. So if you can get it to work, it would be
pretty convenient for many people. Otherwise you might want to try
Cocoon2.

Ulrich


---------------------------------------------------------------------
Please check that your question has not already been answered in the
FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>

To unsubscribe, e-mail: <co...@xml.apache.org>
For additional commands, e-mail: <co...@xml.apache.org>