ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tomasz brymora <tomekpi...@yahoo.com>
Subject Re: Help required regarding showing pdf from blob data.
Date Tue, 02 Sep 2008 01:01:52 GMT
... I don't know if it will help, but look the iText library
http://www.lowagie.com/iText/
(but you probably knew about already)


--- On Mon, 9/1/08, Richard Yee <ryee@cruzio.com> wrote:

> From: Richard Yee <ryee@cruzio.com>
> Subject: Re: Help required regarding showing pdf from blob data.
> To: user-java@ibatis.apache.org
> Date: Monday, September 1, 2008, 7:15 PM
> Ananth,
> You aren't storing PDF data into your blob. You are
> storing a String. 
> You need to store a PDF in order to retrieve a PDF.
> You should use a PDF library to construct a PDF file.
> 
> The error you are getting is caused by the fact that you
> are writing a 
> String that you retrieved from the database to a file with
> a .pdf 
> extension. The Adobe Acrobat Reader attempts to read the
> file as a PDF 
> but fails because the file isn't in PDF format.
> 
> -Richard
> 
> 
> Ananth.Majumdar@cognizant.com wrote:
> >
> > Hi,
> >
> > We are using Ibatis with Spring in our project. We
> have requirement to 
> > store pdf files in the database as blob columns and
> retrieve them and 
> > show them again as pdf. Currently we are doing the
> following.
> >
> > 1. We are converting the pdf file into a byte array
> and saving it as a 
> > blob column
> >
> > 2. While retrieving we are reading the blob column as
> a byte array
> >
> > 3. While converting the byte array to pdf, we are
> facing encoding 
> > problems. A pdf file is generated and data is written
> into it, but 
> > when we try to open it says ‘Cannot open because it
> is not a supported 
> > file type or the file has been damaged’.
> >
> > Please refer the files attached.
> >
> > In the main method, we try to insert a row into the
> employee table. 
> > The ‘description’ field is a blob column in the
> Employee table.
> >
> > // This is the code for retrieval
> >
> > Employee emp1 = (Employee)
> sqlMap.queryForObject("getEmployee",
> "45");
> >
> > byte[] desc=emp1.getDesc();
> >
> > String filename="abc.pdf";
> >
> > FileOutputStream fos=new FileOutputStream(filename);
> >
> > fos.write(desc);
> >
> > fos.close();
> >
> > Please tell us, how can we convert the byte array to
> pdf file. Please 
> > tell us if there are any other ways to achieve this
> functionality.
> >
> > We feel that it has something to do with the encoding
> formats.
> >

Mime
View raw message