This week's giveaway is in the EJB and other Java EE Technologies forum. We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line! See this thread for details.
hi, I want to show PDF file in the browser, while i am able to show the pdf file while i am hard-coding the name of the pdf file(like C:\abc.pdf), the same code doesn't work when i am specifying the file name at runtime, Intrestingly the same code(specifying file name at runtime) works in Netscape 7.0, while it doesn't work on other browsers(not even at Netscape 6). In IE 6 it opens Adobe Acrobat Reader, but than it throws the error "Can't open file,***.fdf"(*** keeps changing).I am able to view other pdf documents, from other sites on IE(so the problem is not in IE setting, i believe). I am attaching my code, I will be very thankful if anybody can help
Prakash Dwivedi (SCJP2, SCWCD, SCBCD)
"Failure is not when you fall down, Its only when you don't get up again"
Good question. I have been dabbling myself in PDFs from Servlets but haven't had much luck or really time to get it to actually work. I was actually using XML with XSTL and XSL:FO with Apache's Fop, it says you can create PDFs dynamically without saving the actual PDF file. It looks like you already have the PDF file on your Web server. I have seen another product that I thought looked really good, but again you would be making the PDF on the fly. But that product was iText, I think that was the name of the product.
FOP has a Driver class that can be used to take a PDF file and send it to the Output stream.
Not sure fi that will help you in any particular way, but I thought I'd throw my 2 cents worth in. Mark
XML with XSTL and XSL:FO with Apache's Fop works great for creating PDF files on the fly. I will be using that in a production environment. Using XSL:FO is great when you need to apply a stylesheet to an xml file. Are you dealing with xml? If not, then using XSL:FO might be an over kill since you have to parse the xml file, and then run it through Apache's FOP processer. I am storing the file but as Mark mentioned there is a while to generate an OutputStream and send that stream to the response. I ran into a problem like this before. Try saving your results to a ByteArrayOutputStream and sending that to the OutputStream. For some reason bytes were being lost when I did it any other way. Good luck, Ryan
SCJP 1.4, SCWCD
Java: The power, elegance, and simplicity of a hand grenade