problem on clicking the Print button twice

View: New views
3 Messages — Rating Filter:   Alert me  

problem on clicking the Print button twice

by srinu :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

 

In my application , I had a "Print" button in one of the screen . On clicking it, a pdf is opening in the browser. every thing is fine.

 

Now, if I click again the same "Print" button on the screen , a pdf is not opening but  my application screen is displaying again in a new brower.

 

 

 

this is the piece of code which I am using it.:

I might have missed out to set some properties for the response i believe .

any suggestions would be helpful.

**********************************

 

FacesContext context = FacesContext.getCurrentInstance();
            PDFGenerator pdfGenerator = new PDFGenerator();
            try
            {
                if (!context.getResponseComplete())
                {
                    Object response = context.getExternalContext().getResponse();
                    if (response instanceof HttpServletResponse)
                    {
                        HttpServletResponse res = (HttpServletResponse)response;

                        Document document = new Document();
                        ByteArrayOutputStream baos = new ByteArrayOutputStream();
                        PdfWriter.getInstance(document, baos);
                        document.open();
                        if (pdfGenerator.generatorPDF(document,
                                                      cicpsPDFTableTOList))
                        {
                            document.close();
                            res.setContentType("application/pdf");
                            res.setHeader("Cache-Control", "no-cache");
                            res.setContentLength(baos.size());
                            ServletOutputStream out = res.getOutputStream();
                            baos.writeTo(out);
                            out.flush();
                            context.responseComplete();
                        }
                        else
                        {
                            addMessage("No matches found.");
                        document.close();
                        }
                    }
                }
            }

 

 

**********************************

 

Environment:

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

 

iText 1.4.4

JSF

weblogic 9

 

 

thanks,

 

with regards,

Srinivasa.

 

 

 

 

 

 

 


-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
iText-questions mailing list
iText-questions@...
https://lists.sourceforge.net/lists/listinfo/itext-questions

Re: problem on clicking the Print button twice

by srinu :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

to make clear for the problem I am g etting it :

In my application , I had a "Print" button in one of the screen . On clicking it, a pdf is opening in the browser. every thing is fine.

 

Now, if I click again the same "Print" button on the screen , a pdf is not opening but  my application screen is displaying again in a ealier brower (where pdf has opened with the records displayed in the table).

 

 


Re: problem on clicking the Print button twice

by Bruno Lowagie (iText) :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

srinu wrote:
> to make clear for the problem I am g etting it :
>
> In my application , I had a "Print" button in one of the screen . On
> clicking it, a pdf is opening in the browser. every thing is fine.
>
> Now, if I click again the same "Print" button on the screen , a pdf is not
> opening but  my application screen is displaying again in a ealier brower
> (where pdf has opened with the records displayed in the table).

Having read the original question and this clarification,
I still don't understand the problem. If I had to guess,
I'd say it's not iText related; it's just a matter of
designing your web application (Servlet related).
br,
Bruno

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
iText-questions mailing list
iText-questions@...
https://lists.sourceforge.net/lists/listinfo/itext-questions