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: [EMAIL PROTECTED]



---------------------------------------------------------------------
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: <[EMAIL PROTECTED]>
For additional commands, e-mail: <[EMAIL PROTECTED]>

Reply via email to