1 Reply Latest reply on Dec 10, 2009 7:55 AM by David Bolsover

    a4j:mediaOutput to render pdf document

    David Bolsover Newbie

      Hi guys...

      Tearing my hair out - just can't seem to make a4j:mediaOutput render a pdf document....

      I have no problems rendering jpg but when I set element="object" mimeType="application/pdf", the Bean.paint method does not get called.

      Does anyone have a working example please?

        • 1. Re: a4j:mediaOutput to render pdf document
          David Bolsover Newbie

          OK - Sorted

          A good nights sleep and upgrade to 3.3.2-SR1 from 3.3.1-GA solved this particular problem...

          <a4j:mediaOutput element="object" mimeType="application/pdf" classid="CLSID:CA8A9780-280D-11CF-A24D-444553540000"
           id="media" session="false" createContent="#{GenericDocumentBean.paint}" value="1"
           style="width:800px; height:600px;" cacheable="false" >

          I'm actually retrieveing the .pdf from a database so in this code, document.getFdata() retrieves a varbinary(max) field from an SQL Server database via hibernate..

          public void paint(OutputStream stream, Object object) throws IOException, SQLException {
           SerializableBlob sblob = (SerializableBlob) document.getFdata();
           Blob blob = sblob.getWrappedBlob();
           InputStream inStream = blob.getBinaryStream();
           int length = -1;
           byte[] buffer = new byte[4096];
           while ((length = inStream.read(buffer)) != -1) {
           stream.write(buffer, 0, length);

          My next issue - how to embed excel and word in a page - can it be done?