I am relatively new to this topic. In our application we display a
ByteArray  in the pdf format using the fop. What we would like to do is
instead send the contents to the printer instead of displaying it in pdf
or display in  pdf at the same time send a copy to the printer. 

Any suggestions appreciated!
Thanks
Vallikun

The piece of code that generates the byte array in pdf format is given
below:


  private byte[] convertToPdf( String foXmlString )
    throws Exception
  {
    //***********************************************
    // transform an FO XML String into a PDF String
    //***********************************************

    // get a SAX parser (org.apache.xerces.parsers.SAXParser)
    XMLReader parser = createParser();

    // set the parser features
    try
    {
  parser.setFeature("http://xml.org/sax/features/namespace-prefixes",true);
    }
    catch (SAXException e)
    {
        // note: fix exceptions to print stack trace of original exception
        // see ServletUtils.getStackTraceAsString()
        //*****
      throw new Exception("Error in setting up parser feature " +
                           "namespace-prefixes.\n  You need a parser " +
                           "which support SAX version 2");
    }

    ByteArrayOutputStream pdfStream = new ByteArrayOutputStream();
    
    Driver driver = new Driver();

    driver.setOutputStream(pdfStream);
    driver.setRenderer(Driver.RENDER_PDF);

    // create a reader for the FO XML string
    Reader foReader = new StringReader(foXmlString);

    driver.buildFOTree( parser, new InputSource( foReader ) );
    foReader.close();
    driver.format();

    driver.render();

    // close and flush the stream
    pdfStream.flush();
    pdfStream.close();

    byte[] content = pdfStream.toByteArray();
    
    return content;
  }





---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, email: [EMAIL PROTECTED]

Reply via email to