Jonathan Romley wrote:
> Hi,
> 
> I have Acrobat7.0 install in my computer. I want to generate a PDF 
> document.  i have the following code in java to generate
> the PDF. The library that i am using is iText-2.0.8.

You say you are using iText, but that doesn't show in your code!

> if(format.equalsIgnoreCase("pdf"))
> {
> response.setContentType("application/pdf");
> File file = new File(docPath);
> if(file == null || !file.exists())
> {
> errors.add(ActionErrors.GLOBAL_ERROR, new ActionError(
> "mydocument.filenotfound.problem"));
> saveErrors(request, errors);
> return mapping.getInputForward();
> }

OK, suppose that the file isn't found.
What is sent to the browser?
HTML with a 404 message?

> FileInputStream is = new FileInputStream(file);
> int read = 0;
> byte[] bytes = new byte[1024];
> while((read = is.read(bytes)) != -1)
> {
> out.write(bytes , 0 , read);
> }
> is.close(); 
> out.flush();
> out.close();
 > return null;
 > }

You're not generating a PDF using iText;
you're just reading a file from the file system
and sending it to the ServletOutputStream.
In other words: you're just serving a file,
and you don't even take into account the #1 caveat
we always mention when we talk about serving PDFs
to MSIE.

> Any insight would be appreciated.

First explain why you chose to design your application
the way you did. You also don't say if the file you are
trying to serve to the browser is actually a PDF file.
It could be anything.
-- 
This answer is provided by 1T3XT BVBA

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions

Buy the iText book: http://www.1t3xt.com/docs/book.php

Reply via email to