Thanks for the response.  In your 'talk_to_html' example it appears that
your pdf file is has already been written to a location on disk and it is
simply opened by the <object> tag.  I am trying to dynamically generate a
pdf on the fly (based on information I have stored in a database) and stream
it to the browser for viewing by the client.  

Is there a way to dynamically create the pdf, stream it to the clients
browser, and open it within a specified area of a JSP?  Based on iText in
Action it looked like there was a way to do this using a combination of an
<embed> tag within a JSP and a servlet using the iText library.

Additional note, the client (user) will only need to review the PDF within
their browser.  They will NOT need to interact (insert, delete, etc) with
the pdf other than potentially saving it to their own local disk.

Thanks,
Paul

------------------------------

Message: 4
Date: Thu, 24 Apr 2008 08:02:25 +0200
From: 1T3XT info <[EMAIL PROTECTED]>
Subject: Re: [iText-questions] Trouble Embedding dynamic PDF within a
        specified area of a JSP
To: Post all your questions about iText here
        <[email protected]>
Message-ID: <[EMAIL PROTECTED]>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed

Paul Bundick wrote:
> I'm having trouble embedding dynamic PDF within a specified area of a JSP
> using the <embed> tag.

I'm not sure if I understood the question, but if you want
an HTML page with a PDF objects as well as other HTML content,
why don't you try the <object> tag? See for instance:
http://itext.ugent.be/playground/talk_to_html.html

-- 
This answer is provided by 1T3XT BVBA

------------------------------

Message: 3
Date: Thu, 24 Apr 2008 01:32:59 -0400
From: "Paul Bundick" <[EMAIL PROTECTED]>
Subject: [iText-questions] Trouble Embedding dynamic PDF within a
        specified       area of a JSP
To: <[email protected]>
Message-ID: <[EMAIL PROTECTED]>
Content-Type: text/plain; charset="iso-8859-1"

I'm having trouble embedding dynamic PDF within a specified area of a JSP
using the <embed> tag.

My JSP code resembles the following:

<embed
src="<%=request.getContextPath()%>/controller/Administration/administrator_v
iewcreate_invoice.jsp?Embed_Invoice=Embed_Invoice" width="100%"
height="100%" type="application/pdf" />

When the JSP loads, this code fires off a request to the controller servlet
which uses an action class to build a very basic (at the moment) pdf stream.
A snippet of the action class code snippet is below:

public String createPDFInvoice( HttpServletRequest request,
HttpServletResponse response ) {

                HttpSession session = request.getSession();

                Date todaysDate = new Date();

                Customer customer =
(Customer)session.getAttribute("CUSTOMER_TO_INVOICE");

                Document document = new Document(PageSize.LETTER);

                ByteArrayOutputStream baos = new ByteArrayOutputStream();
                try {
                        PdfWriter writer =
PdfWriter.getInstance(document,baos);
                        document.open();

                        document.add(new Paragraph("Invoice"));
                        document.add(new Paragraph(new Date().toString()));
                        document.add(new Paragraph(customer.getFullName()));

                        document.close();
                        response.setContentType("application/pdf");
                        response.setContentLength(baos.size());
                        ServletOutputStream out =
response.getOutputStream();
                        baos.writeTo(out);
                        out.flush();
                } catch ( Exception e ) {
                        e.printStackTrace();
                        System.out.println("document: "+e.getMessage());
                }

        
return("/Administration/administrator_viewcreate_invoice.jsp");
}

When the action class returns to the controller servlet, the following code
is executed:

        requestedURL =
request.getContextPath()+"/Administration/administrator_viewcreate_invoice.j
sp";
        try {
                response.sendRedirect(requestedURL);
        } catch( IOException ioe ) {
                System.out.println("Problems redirecting admin view/create
invoice request in ControllerServlet.");
                ioe.printStackTrace();
        }
        return;

If I scrap the <embed> tag and just use a <form> tag with a target of a new
window (target="_blank") the PDF shows up and takes up the entire browser
window.  I would like to use the <embed> tag as it is described in iText in
Action (I've really enjoyed the book by the way - thus far) so that other
items on my JSP are also displayed in addition to the section that is
displaying the dynamic PDF.  This is not working, however, using the code
above.

Some advice on where I have gone wrong here would be greatly appreciated.

Thanks,
Paul

<<attachment: winmail.dat>>

-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference 
Don't miss this year's exciting event. There's still time to save $100. 
Use priority code J8TL2D2. 
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions

Do you like iText?
Buy the iText book: http://www.1t3xt.com/docs/book.php
Or leave a tip: https://tipit.to/itexttipjar

Reply via email to