You asked this question on the devl list and Chris gave you an excellent
answer.
He also suggested that you read up a bit on XSL-FO as there are standard
techniques that can be used to embed TIFF images in XSL-FO documents.
Several people spent a bit of time reading your servlet. Please re-read
Chris' answer to you and look for an example XSL-FO document that embeds
a TIFF graphic. You should be able to find XSL-FO resources on the web.
Look for the web version of Dave Pawson's book. Look for the Mulberry
resources and the OASIS web site. Search the FOP-USER archives as well
as the Mulberry XSL list archive.
I don't think you need a servlet yet. The first thing you need is
an XSL-FO example of a document that embeds a TIFF document.
You may need to understand XSL-FO better to do this.
You can render this in PDF, PCL, etc using FOP from the command line.
Your next step would be to generate the TIFF file from the database
as Chris suggested. This could be done with a CGI or Servlet.
You'll get a lot of help here as long as people can see that you've
made some effort on your own.
On Fri, 2004-04-02 at 14:27, Jerry wrote:
> Hi,
>
> I have a problem with displaying tiff data in PDF
> format using FOP. We have binary data in tiff stored
> in database. What I need to do is to write a servlet
> to get those binary data in tiff format from database
> and put those data in a byte array. Next, in the same
> servlet, I need to get those binary data in tiff
> format from the byte array and display them on the web
> in PDF format using FOP. I know if the binary data is
> formatted object, it is easy to convert it into PDF
> using FOP. However, the data in the byte array "bt" in
> tiff does not belong to the standard formatting
> object.
> My understanding is I need to either convert
> it into the formatting object using XSL or convert it
> into XML. However, I am new to FOP and XML/XSL and do
> not know how to do that. If possible, we need to
> convert the data format in memory,that means,
> everything is done in memory, not save it as a file
> first and process using FOP. Anyone has the
> experience and would like to share the knowledge and
> experience with me, I will greatly appreciate. If you
> have a piece of codes for me to share, that will be
> greatly helpful.
>
> I also attached my piece of codes for your reference.
> I know my code is not working, because I tried to
> convert non-standard formatting object to PDF. I need
> to do something about this part. Please help me.
>
> Thanks in advance,
>
>
> Jerry
>
> ***********************************************************
> import javax.servlet.*;
> import javax.servlet.http.*;
> import java.io.*;
> import java.util.*;
> import java.util.zip.*;
> import java.sql.*;
> import java.text.*;
>
>
> import java.net.*;
> import java.util.Properties;
> import java.awt.image.*;
> import com.sun.media.jai.codec.*;
> import com.sun.media.jai.*;
> import javax.media.jai.JAI;
> import javax.media.jai.*;
> import javax.media.jai.RenderedOp;
> import javax.media.jai.PlanarImage;
> import javax.media.jai.OpImage;
> import javax.media.jai.util.*;
> import
> javax.media.jai.remote.SerializableRenderedImage;
> import java.awt.image.renderable.ParameterBlock;
> import java.lang.Object;
> import java.awt.Image;
> import javax.swing.ImageIcon;
> import java.io.ByteArrayOutputStream.*;
>
>
> import com.csi.utils.StringUtils;
> import com.csi.daserver.global.*;
> import com.csi.dcserver.objects.DCSession;
> import com.csi.dcserver.exceptions.*;
> import com.csi.daserver.utils.MsgPool;
> import com.csi.dcserver.crypto.Crypto;
>
>
> import org.xml.sax.InputSource;
>
> import org.apache.fop.apps.Driver;
> import org.apache.fop.apps.XSLTInputHandler;
> import org.apache.fop.messaging.MessageHandler;
>
> import
> org.apache.avalon.framework.logger.ConsoleLogger;
> import org.apache.avalon.framework.logger.Logger;
>
>
> public class ImageDownload extends HttpServlet {
>
> Logger log = null;
> ....
> public void doGet(HttpServletRequest req,
> HttpServletResponse resp) throws ServletException,
> IOException {
>
> ...
>
> //got the binary data in tiff format from database
> and put the binary data in byte array bt
> Byte[] bt = (byte[]) v.elementAt(0);
>
> sendPDFBinaryResponse(resp, req, bt,
> "application/pdf");
> return;
> }
> }
>
> //
> private void
> sendPDFBinaryResponse(HttpServletResponse
> res,HttpServletRequest req, byte[]
> bt,StringsContTypeHeader) throws IOException,
> ServletException{
>
>
>
> if(sContTypeHeader=="application/pdf"){
>
> if (log == null) {
> log = new
> ConsoleLogger(ConsoleLogger.LEVEL_WARN);
> MessageHandler.setScreenLogger(log);
> }
>
>
> renderFO(new InputSource(new
> ByteArrayInputStream(bt)), res);
>
>
> }
>
> }
>
>
>
>
>
> public void renderFO(InputSource foFile,
> HttpServletResponse response) throws ServletException
> {
> try {
> ByteArrayOutputStream out = new
> ByteArrayOutputStream();
>
>
> response.setContentType("application/pdf");
>
> Driver driver = new Driver(foFile, out);
> driver.setLogger(log);
> driver.setRenderer(Driver.RENDER_PDF);
>
> driver.run();
>
> byte[] content = out.toByteArray();
>
>
> response.setContentLength(content.length);
> response.getOutputStream().write(content);
> response.getOutputStream().flush();
>
>
>
> } catch (Exception ex) {
> throw new ServletException(ex);
> }
> }
>
> ...
>
> }
>
>
> ****************
> This is the exact error I got:
>
> org.xml.sax.SAXParseException: Content is not allowed
> in prolog.
> at
> org.apache.xerces.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1172)
> at org.apache.fop.apps.Driver.render(Driver.java:498)
> at org.apache.fop.apps.Driver.run(Driver.java:565)
>
>
> __________________________________
> Do you Yahoo!?
> Yahoo! Small Business $15K Web Design Giveaway
> http://promotions.yahoo.com/design_giveaway/
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
--
John Austin <[EMAIL PROTECTED]>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]