... 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 <[EMAIL PROTECTED]> wrote: > From: Richard Yee <[EMAIL PROTECTED]> > Subject: Re: Help required regarding showing pdf from blob data. > To: [email protected] > 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 > > > [EMAIL PROTECTED] 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. > >
