Hi,

We are having a small problem here with generating pdf over an SSL with iText.  We are using Internet Explorer and everytime we click on the link to generate the pdf we get

"This page contains both secure and non secure items"  and we have to click yes or no ...

Here is a sample of our code... very basic and the error still occurs:

        /**
        * This method will create a PDF document for download.
        * <p>
        * @param response
        * @param searchForm
        * @return void
        */
        private void doCreatePDFFile(HROnlineLocale hrOnlineLocale,
                                                                HttpServletResponse response,
                                                                HttpServletRequest request,
                                                                ActionMapping mapping,
                                                                MessageResources messageResources,
                                                                HROnlineVO hrOnlineVO,
                                                                DirectBankDepositForm directBankDepositForm)
                throws Exception {
               
                ByteArrayOutputStream pdfBytes = null;
                ActionMessages errors = new ActionMessages();
       
                try {
                        pdfBytes = generatePDFDocumentBytes(hrOnlineLocale, response, request, mapping, messageResources, hrOnlineVO, directBankDepositForm);//, this.getServletContext());
               
                        response.setHeader("Cache-Control", "must-revalidate, post-check=0,pre-check=0");
                        response.setContentType("application/pdf");
                        response.setHeader("Pragma","public");
                        response.setHeader("Expires","0");
                        response.setContentLength(pdfBytes.size());

                        ServletOutputStream sos;

                        sos = response.getOutputStream();
                        pdfBytes.writeTo(sos);
                        sos.flush();
                       
                } catch (Exception e) {
                        throw e;
                } finally {
                        if (pdfBytes != null) {
                                pdfBytes.reset();
                        }
                }
        }

        /**
         *  
         * @param req must be non-null
         *
         * @return a non-null output stream. The output stream contains
         *         the bytes for the PDF document
         *
         * @throws DocumentException
         *
         */
        protected ByteArrayOutputStream generatePDFDocumentBytes(
                                                                        HROnlineLocale hrOnlineLocale,
                                                                        HttpServletResponse response,
                                                                        HttpServletRequest request,
                                                                        ActionMapping mapping,
                                                                        MessageResources messageResources,
                                                                        HROnlineVO hrOnlineVO,
                                                                        DirectBankDepositForm directBankDepositForm)
                throws Exception {        
               
                Document doc = new Document();

                ByteArrayOutputStream pdfBytes = new ByteArrayOutputStream();
                PdfWriter docWriter = null;

                try        {                
                        docWriter = PdfWriter.getInstance(doc, pdfBytes);
                       
                        doc.addCreationDate();
                        doc.setPageSize(PageSize.LETTER);                        
                        doc.open();        
                       
                        Chunk title = new                                 Chunk(messageResources.getMessage(hrOnlineLocale.getLocaleLocale(),"title.directBankDeposit").toUpperCase(), PdfUtils.getRedBold(11));
                               
                        doc.add((Element) title);

                } catch (Exception e){
                        pdfBytes.reset();
                        throw e;
                }
                finally
                {
                        if (doc != null) {
                                doc.close();
                        }
                        if (docWriter != null) {
                                docWriter.close();
                        }
                }

                if (pdfBytes.size() < 1) {
                        throw new Exception("Document has "+ pdfBytes.size()+ " bytes.");                
                }
                return pdfBytes;
        }

Thanks

RÉMI R. PAQUETTE, CLP
Information Technology Division
Canada Mortgage and Housing Corporation
700 Montreal Road
Ottawa, Ontario
K1A 0P7      CANADA

Tel: (613) 748-4041     [C4-348]
Fax: (613) 748-4071
Email:
[EMAIL PROTECTED]
Website:
http://www.cmhc-schl.gc.ca
Everything HR:
HR on-line
 

Reply via email to