Problem opening servlet generated PDF in browser

This is the code i use to show the PDF in a browser
ByteArrayOutputStream outStream = new ByteArrayOutputStream();
res.setContentType("application/pdf");
res.setHeader("Content-Disposition","inline;Filename= " + file.getName());
ServletOutputStream sos = res.getOutputStream();
               outStream.writeTo(sos);
               sos.flush();          
               outStream.close();
               sos.close();
In Netscape i get an error saying the filename does not start with %PDF and in IE the page just shows up blank. from the blank pagewhen i use the back button and then hit the forward button the pdf will show up in IE.
I also tries using fileOuput stream instead of servletoutputstream
     FileOutputStream fout = new FileOutputStream( file );
               outStream.writeTo(fout);
               fout.close() ;
               outStream.close() ;
In this case IE does nothing but it works on netscape or mozilla
This is running on websphere 5.0 , apache webserver on linux env
But i need to get this worked on IE any help would be greatly appreciated!
Thanks in Advance
Sid

(SIGH)
Crossposted over here:
http://forum.java.sun.com/thread.jspa?threadID=631107

Similar Messages

  • Can't open libHaru-generated PDF with Reader, other readers work.

    Our application uses libHaru to export PDF images.  These PDFs can be opened using PDFlite on Windows, Preview on Mac and some other readers.  However, I have tried several versions of Adobe Reader on both platforms and the files fail to open with the message: "There was an error processing a page.  There was a problem reading this document (14)."   So, it seams that Adobe Reader believes that there is problem with this file.  However, from my very limited understanding of PDF structure, I have no idea what might be wrong, so I don't know how to fix it.  The file is written unencrypted.  It is about as simple a PDF as we can generate - a red-filled rectangle.  I would greatly appreciate any suggestions or help.
    Here is a sample PDF:
    %PDF-1.3
    %∑æ≠™
    1 0 obj
    <<
    /Type /Catalog
    /Pages 2 0 R
    >>
    endobj
    2 0 obj
    <<
    /Type /Pages
    /Kids [ 4 0 R ]
    /Count 1
    >>
    endobj
    3 0 obj
    <<
    /Producer (Haru Free PDF Library 2.3.0-dev)
    >>
    endobj
    4 0 obj
    <<
    /Type /Page
    /MediaBox [ 0 0 236 207 ]
    /Contents 5 0 R
    /Resources <<
    /ProcSet [ /PDF /Text /ImageB /ImageC /ImageI ]
    /Pattern <<
    /Type /Pattern
    /PatternType 1
    /PaintType 2
    /TilingType 2
    /BBox [ 0 0 100 100 ]
    /XStep 100
    /YStep 100
    >>
    >>
    /Parent 2 0 R
    >>
    endobj
    5 0 obj
    <<
    /Length 6 0 R
    >>
    stream
    1 0 0 -1 -118 296 cm
    1 w
    0 0 0 RG
    [] 0 d
    1 0.3 0.3 rg
    q
    % Rect
    119.25 90 m
    352.5 90 l
    352.5 294.75 l
    119.25 294.75 l
    119.25 90 l
    h
    B
    Q
    endstream
    endobj
    6 0 obj
    135
    endobj
    xref
    0 7
    0000000000 65535 f
    0000000015 00000 n
    0000000064 00000 n
    0000000123 00000 n
    0000000188 00000 n
    0000000458 00000 n
    0000000647 00000 n
    trailer
    <<
    /Root 1 0 R
    /Info 3 0 R
    /Size 7
    >>
    startxref
    666
    %%EOF

    You would need to post a sample PDF that demonstrates the problem.  All you posted there is text.  (PDF is a BINARY file format)
    From: Adobe Forums <[email protected]<mailto:[email protected]>>
    Reply-To: "[email protected]<mailto:[email protected]>" <[email protected]<mailto:[email protected]>>
    Date: Thu, 13 Oct 2011 11:02:42 -0700
    To: Leonard Rosenthol <[email protected]<mailto:[email protected]>>
    Subject: Can't open libHaru-generated PDF with Reader, other readers work.
    Can't open libHaru-generated PDF with Reader, other readers work.
    created by Fred Snerd<http://forums.adobe.com/people/Fred+Snerd> in PDF Language and Specifications - View the full discussion<http://forums.adobe.com/message/3969828#3969828

  • Problem opening Form based PDF via Safari browser with Adobe Reader 9.3 on MAC

    Hi,
    I'm mentioning below the problem that we are facing when we open a form based PDF created using a licensed version of Adobe Livecycle Designer ES (Version 8.2.1.4029.1.523496) on a MAC machine through a Safari Browser.
    We tested this PDF form on a windows machine and the PDF opens in an IE browser via the latest Adobe reader 9.3 without any problem. I then received complaints by our clients that they were unable to open the same PDF on their Safari browser on a MAC machine, I tried to resolve the problem by downloading the latest version of Adobe Reader 9.3 for MAC but noticed that the Safari browser window would just keep refreshing the page without displaying the PDF at all. I then uninstalled the Adobe Reader 9.3 version and downloaded and installed an older version i.e., Abobe Reader 8.2 version for MAC and noticed that the PDF document successfully opened in the Safari browser. My question is why does a form based PDF work with an older version of Adobe Reader for MAC and not with the latest version? Our clients are not comfortable with the fact that we are refraining them from upgrading to the latest version of Adobe Reader for MAC and that they would have to downgrade their existing Adobe Reader 9.3 to a lower version Adobe Reader 8.2 in order for the PDF forms to work when it should be the other way around.
    Is there any fix or a patch that is currently being worked on that would resolve this issue in the latest Adobe Reader for MAC? If yes then when would it be ready? This issue is quite critical for our business and would appreciate it if this would be looked into with high priority.
    Thanks and Regards,
    Sheikh Huraiz Ahmed.

    That suggestion makes sense and likely works, but only if the user is on a machine that will allow them to use Reader. I'm sending this out to a lot of teachers, who are using machines either at school, or are school-issued machines, and they don't have the admin privileges to install software-- even Reader.
    so my problem is, if they are stuck on a machine without Reader, and without the possibility of having Reader... it's just not going to work because Preview can't handle these functions.
    And, since that is not an acceptable answer with what I'm trying to do... I will find another way to create/submit forms. I think there are some online possibilities I will have to make work.
    very, very disappointing and frustrating.
    Kristi

  • Problem with printing generated pdf.

    Hello!
    I need to print pdf file, that was generated by my application. I am using Apache FOP to generate pdf (xml+xslt). For printing I am using Maxatec MT-150 receipt printer. Seems, that pdf is generated successfully, because I can open it and I also can print it using Windows interface. However, when I am sending it to printer in my JAVA application, printed file is just set of unreadable characters and black lines. I was trying to use different DocFlavors, like DocFlavor.INPUT_STREAM.AUTOSENSE, DocFlavor.URL.AUTOSENSE, but neither had a luck. My code looks like this:
    PrintService receiptPrintService = getReceiptPrinterService(printerName);
    DocPrintJob printJob = receiptPrintService.createPrintJob();
    FileInputStream fis = new FileInputStream(new File("StatusReport.pdf"));
    Doc doc = new SimpleDoc(fis, DocFlavor.INPUT_STREAM.AUTOSENSE, null);
    printJob.print(doc, null);
    private static PrintService getReceiptPrinterService(String printerName) {
              PrintService[] services = PrintServiceLookup.lookupPrintServices(null, null);
              for (PrintService printService : services) {
                   if (printerName.equals(printService.getName())) {
                        return printService;
              return null;
         }For some reason I cannot set DocFlavor.INPUT_STREAM.PDF, as it throws following exception: sun.print.PrintJobFlavorException: invalid flavor. (despite the fact that I can pdf using the same printer, but through Windows interface)
    So, I really don't see what is the problem. Should I use something in my xslt template to specify content type? currently I have:
    <xsl:output method="xml" version="1.0" omit-xml-declaration="no" indent="yes"/>Any help would be appreciated.
    Alexander.

    @Dick_Adams
    I am sorry, but what error message are you talking about? The only error I get is "sun.print.PrintJobFlavorException: invalid flavor" and as far as I understand it depends on printer, what is supported and what is not supported. Or am I wrong? I am using standard java.awt.print library.
    @AndrewThompson64, thanks for the tip!)) It does print correctly, but in this case I am not sure I have enough possibilities to control printing. For instance, my pdf was printed as landscape, but I need portrait.

  • Problem opening a particular PDF document in ALL browsers

    I have a problem a PDF document in all browsers.
    I have a mail order account online and I am trying to open one of my statements by clicking on the PDF logo.
    A new window opens and is either blank or tells me it cannot load (depending which browser used).  When the new window opens the address in the browser is an IP address / name of the company / document number.PDF 
    I have contacted the company but they tell me to either download the latest Adobe Reader (which I have), and try a different browser (which I have).
    I have tried changing settings in all browsers as per instructions found on other sites, and I can open PDF docs from other sites and my pc no problem. This tells me that the problem lies with the company, yet they cannot seem to resolve.
    Does anyone have any ideas or can shed light on this puzzling problem?
    So grateful, thanks.

    Can you try to download that PDF to your local disk, and open it from there?

  • Error in opening smartform generated PDF attachments

    Hi every one,
        my smartforms generate multiple emails based on the widely used code as shown below.
    The emails are successfully being sent to different locations, but the problem is the first PDF file is opening, but the others followed by it are not opening. It's giving an error ' File damaged and cannot be opened!'
    Pls see the below code and help me out.
    Points would be awarded.
    Thanks to all in advance!!
    Arnab
    REPORT  zvenkat_smartform_via_mai.
    *&  Structures and Infotype Internal tables.
    TABLES pernr.
    INFOTYPES:
      0000,
      0001,
      0002,
      0006,
      0022,
      0023.
    INCLUDE dbpnpmac.
    *&  Declaration part
    Types
    TYPES:
       BEGIN OF t_emp_info,
         pernr TYPE pa0001-pernr,
         ename TYPE pa0001-ename,
         bukrs TYPE pa0001-bukrs,
         persk TYPE pa0001-persk,
         stell TYPE pa0001-stell,
         gblnd TYPE pa0002-gblnd,
       END OF t_emp_info,
       BEGIN OF t_mard,
         matnr TYPE mard-matnr,
         werks TYPE mard-werks,
         labst TYPE mard-labst,
         meins TYPE mara-meins,
       END OF t_mard.
    Work areas
    DATA:
      w_emp_info TYPE t_emp_info.
    Internal tables
    DATA:
      i_emp_info TYPE STANDARD TABLE OF t_emp_info,
      i_mard     TYPE STANDARD TABLE OF t_mard.
    "  Mai related declarations
    "Variables
    DATA :
         g_sent_to_all   TYPE sonv-flag,
         g_tab_lines     TYPE i.
    "Types
    TYPES:
         t_document_data  TYPE  sodocchgi1,
         t_packing_list   TYPE  sopcklsti1,
         t_attachment     TYPE  solisti1,
         t_body_msg       TYPE  solisti1,
         t_receivers      TYPE  somlreci1,
         t_pdf            TYPE  tline.
    "Workareas
    DATA :
         w_document_data  TYPE  t_document_data,
         w_packing_list   TYPE  t_packing_list,
         w_attachment     TYPE  t_attachment,
         w_body_msg       TYPE  t_body_msg,
         w_receivers      TYPE  t_receivers,
         w_pdf            TYPE  t_pdf.
    "Internal Tables
    DATA :
         i_document_data  TYPE STANDARD TABLE OF t_document_data,
         i_packing_list   TYPE STANDARD TABLE OF t_packing_list,
         i_attachment     TYPE STANDARD TABLE OF t_attachment,
         i_body_msg       TYPE STANDARD TABLE OF t_body_msg,
         i_receivers      TYPE STANDARD TABLE OF t_receivers,
         i_pdf            TYPE STANDARD TABLE OF t_pdf.
    PARAMETERS:
               p_mai_id(99) TYPE c.
    *& Start-of-selection.
    START-OF-SELECTION.
    GET pernr.
      PERFORM get_data.
      PERFORM show_smartform.
    *& End-of-selection.
    END-OF-SELECTION.
    *&      Form  get_data
    FORM get_data .
      rp-provide-from-last p0000 space pn-begda pn-endda.
      rp-provide-from-last p0001 space pn-begda pn-endda.
      rp-provide-from-last p0002 space pn-begda pn-endda.
      MOVE-CORRESPONDING: p0000 TO w_emp_info,
                          p0001 TO w_emp_info,
                          p0002 TO w_emp_info.
      SELECT matnr werks labst
      FROM mard
      INTO CORRESPONDING FIELDS OF TABLE i_mard.
    ENDFORM.                    " get_data
    *&      Form  show_smartform
    FORM show_smartform .
      DATA :
        l_sform_name TYPE tdsfname,
        l_fm_name    TYPE rs38l_fnam.
      DATA :
            l_sf_control TYPE ssfctrlop,
            l_sf_options TYPE ssfcompop.
      DATA: i_otf LIKE itcoo OCCURS 100 WITH HEADER LINE.
           i_pdf LIKE tline OCCURS 100 WITH HEADER LINE.
      DATA: op_option TYPE ssfctrlop,
            job_output TYPE ssfcrescl.
    op_option-getotf = 'X'.
      l_sform_name = 'ZVENKAT_SMARTFORM'.
      CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
        EXPORTING
          formname           = l_sform_name
        IMPORTING
          fm_name            = l_fm_name
        EXCEPTIONS
          no_form            = 1
          no_function_module = 2
          OTHERS             = 3.
      IF sy-subrc  0.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ELSE.
        CALL FUNCTION l_fm_name
          EXPORTING
            control_parameters = op_option
            output_options     = l_sf_options
            w_emp_info         = w_emp_info
    IMPORTING
      DOCUMENT_OUTPUT_INFO       =
       job_output_info            = job_output
          TABLES
            p0006              = p0006
            p0022              = p0022
            p0023              = p0023
            i_mard             = i_mard.
        IF sy-subrc   0.
          MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                  WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
        ENDIF.
        CALL FUNCTION 'CONVERT_OTF'
          EXPORTING
            format = 'PDF'
          TABLES
            otf    = job_output-otfdata
            lines  = i_pdf.
        IF sy-subrc  0.
          MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                  WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
        ENDIF.
        PERFORM send_mai.
      ENDIF.
    ENDFORM.                    " show_smartform
    *&      Form  send_mai
    FORM send_mail .
      "Subject of the mai.
      w_document_data-obj_name  = 'MAI_TO_HEAD'.
      w_document_data-obj_descr = 'Regarding Mai Program by SAP ABAP'.
      "Body of the mai
      PERFORM build_body_of_mai
        USING:space,
              'Hi,',
              'I am fine. How are you? How are you doing ? ',
              'This program has been created to send simple mai',
              'with Subject,Body with Address of the sender. ',
              'Regards,',
              'Venkat.O,',
              'SAP HR Technical Consultant.'.
      "Write Packing List for Body
      DESCRIBE TABLE i_body_msg LINES g_tab_lines.
      w_packing_list-head_start = 1.
      w_packing_list-head_num   = 0.
      w_packing_list-body_start = 1.
      w_packing_list-body_num   = g_tab_lines.
      w_packing_list-doc_type   = 'RAW'.
      APPEND w_packing_list TO i_packing_list.
      CLEAR  w_packing_list.
      "Write Packing List for Attachment
      w_packing_list-transf_bin = 'X'.
      w_packing_list-head_start = 1.
      w_packing_list-head_num   = 1.
      w_packing_list-body_start = 1.
      DESCRIBE TABLE i_attachment LINES w_packing_list-body_num.
      w_packing_list-doc_type   = 'PDF'.
      w_packing_list-obj_descr  = 'PDF Attachment'.
      w_packing_list-obj_name   = 'PDF_ATTACHMENT'.
      w_packing_list-doc_size   = w_packing_list-body_num * 255.
      APPEND w_packing_list TO i_packing_list.
      CLEAR  w_packing_list.
      "Fill the document data and get size of attachment
      w_document_data-obj_langu  = sy-langu.
      READ TABLE i_attachment INTO w_attachment INDEX g_tab_lines.
      w_document_data-doc_size = ( g_tab_lines - 1 ) * 255 + STRLEN( w_attachment ).
      "Receivers List.
      w_receivers-rec_type   = 'U'.      "Internet address
      w_receivers-receiver   = p_mai_id. "here mai Id should be given
      w_receivers-com_type   = 'INT'.
      w_receivers-notif_del  = 'X'.
      w_receivers-notif_ndel = 'X'.
      APPEND w_receivers TO i_receivers .
      CLEAR:w_receivers.
      "Function module to send mai to Recipients
      CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
        EXPORTING
          document_data              = w_document_data
          put_in_outbox              = 'X'
          commit_work                = 'X'
        IMPORTING
          sent_to_all                = g_sent_to_all
        TABLES
          packing_list               = i_packing_list
          contents_bin               = i_attachment
          contents_txt               = i_body_msg
          receivers                  = i_receivers
        EXCEPTIONS
          too_many_receivers         = 1
          document_not_sent          = 2
          document_type_not_exist    = 3
          operation_no_authorization = 4
          parameter_error            = 5
          x_error                    = 6
          enqueue_error              = 7
          OTHERS                     = 8.
      IF sy-subrc = 0 .
        MESSAGE i303(me) WITH 'Mai has been Successfully Sent.'.
      ELSE.
        WAIT UP TO 2 SECONDS.
        "This program starts the SAPconnect send process.
        SUBMIT rsconn01 WITH mode = 'INT'
                        WITH output = 'X'
                        AND RETURN.
      ENDIF.
    ENDFORM.                    " send_mai
    *&      Form  build_body_of_mai
          text
         -->L_MESSAGE  text
    FORM build_body_of_mai  USING l_message.
      w_body_msg = l_message.
      APPEND w_body_msg TO i_body_msg.
      CLEAR  w_body_msg.
    ENDFORM.                    " build_body_of_mai

    Hi,
    Check the code below
    1.converting smartform to PDF
    Summury: Converting the smartfrom to PDF is process of 3 simple steps.
    • Calling the Smart form, then it returns the OTF data in Return.
    • Converting the OTF data into required format using the Function Module CONVERT_OTF_2_PDF.
    • Download the File
    *& Report ZTEST_NREDDY_PDF
    REPORT ZTEST_NREDDY_PDF.
    DATA: it_otf TYPE STANDARD TABLE OF itcoo,
    it_docs TYPE STANDARD TABLE OF docs,
    it_lines TYPE STANDARD TABLE OF tline,
    st_job_output_info TYPE ssfcrescl,
    st_document_output_info TYPE ssfcrespd,
    st_job_output_options TYPE ssfcresop,
    st_output_options TYPE ssfcompop,
    st_control_parameters TYPE ssfctrlop,
    v_len_in TYPE so_obj_len,
    v_language TYPE sflangu VALUE 'E',
    v_e_devtype TYPE rspoptype,
    v_bin_filesize TYPE i,
    v_name TYPE string,
    v_path TYPE string,
    v_fullpath TYPE string,
    v_filter TYPE string,
    v_uact TYPE i,
    v_guiobj TYPE REF TO cl_gui_frontend_services,
    v_filename TYPE string,
    v_fm_name TYPE rs38l_fnam.
    CONSTANTS c_formname TYPE tdsfname VALUE 'ZTEST'.
    CALL FUNCTION 'SSF_GET_DEVICE_TYPE'
    EXPORTING
    i_language = v_language
    i_application = 'SAPDEFAULT'
    IMPORTING
    e_devtype = v_e_devtype.
    st_output_options-tdprinter = v_e_devtype.
    *st_output_options-tdprinter = 'locl'.
    st_control_parameters-no_dialog = 'X'.
    st_control_parameters-getotf = 'X'.
    .................GET SMARTFORM FUNCTION MODULE NAME.................
    CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
    EXPORTING
    formname = c_formname
    IMPORTING
    fm_name = v_fm_name
    EXCEPTIONS
    no_form = 1
    no_function_module = 2
    OTHERS = 3.
    IF sy-subrc 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    ...........................CALL SMARTFORM............................
    CALL FUNCTION v_fm_name
    EXPORTING
    control_parameters = st_control_parameters
    output_options = st_output_options
    IMPORTING
    document_output_info = st_document_output_info
    job_output_info = st_job_output_info
    job_output_options = st_job_output_options
    EXCEPTIONS
    formatting_error = 1
    internal_error = 2
    send_error = 3
    user_canceled = 4
    OTHERS = 5.
    IF sy-subrc 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ELSE.
    .........................CONVERT TO OTF TO PDF.......................
    CALL FUNCTION 'CONVERT_OTF_2_PDF'
    IMPORTING
    bin_filesize = v_bin_filesize
    TABLES
    otf = st_job_output_info-otfdata
    doctab_archive = it_docs
    lines = it_lines
    EXCEPTIONS
    err_conv_not_possible = 1
    err_otf_mc_noendmarker = 2
    OTHERS = 3.
    IF sy-subrc 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    ........................GET THE FILE NAME TO STORE....................
    CONCATENATE 'smrt' '.pdf' INTO v_name.
    CREATE OBJECT v_guiobj.
    CALL METHOD v_guiobj->file_save_dialog
    EXPORTING
    default_extension = 'pdf'
    default_file_name = v_name
    file_filter = v_filter
    CHANGING
    filename = v_name
    path = v_path
    fullpath = v_fullpath
    user_action = v_uact.
    IF v_uact = v_guiobj->action_cancel.
    EXIT.
    ENDIF.
    ..................................DOWNLOAD AS FILE....................
    MOVE v_fullpath TO v_filename.
    CALL FUNCTION 'GUI_DOWNLOAD'
    EXPORTING
    bin_filesize = v_bin_filesize
    filename = v_filename
    filetype = 'BIN'
    TABLES
    data_tab = it_lines
    EXCEPTIONS
    file_write_error = 1
    no_batch = 2
    gui_refuse_filetransfer = 3
    invalid_type = 4
    no_authority = 5
    unknown_error = 6
    header_not_allowed = 7
    separator_not_allowed = 8
    filesize_not_allowed = 9
    header_too_long = 10
    dp_error_create = 11
    dp_error_send = 12
    dp_error_write = 13
    unknown_dp_error = 14
    access_denied = 15
    dp_out_of_memory = 16
    disk_full = 17
    dp_timeout = 18
    file_not_found = 19
    dataprovider_exception = 20
    control_flush_error = 21
    OTHERS = 22.
    IF sy-subrc 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    ENDIF.
    Regards,
    Raj.

  • Open a generated pdf file in new window

    Dear all,
    I'm using JDev ADF 11.1.1.4.0
    I use the command button method to generate pdf file with JasperReports and I store it into the public folder /reports/test5.pdf. To open this file I can use goLink or goButton with target frame _blank, but how can I open this file automatically after generation?
    I was reading about fileDownloadActionListener, but it's not what I need, I just want to open the file in new window browser.
    Any help will be appreciated.
    Regards,
    Wojtek.

    try this
    HttpServletResponse response = (HttpServletResponse) FacesContext
                                      .getCurrentInstance().getExternalContext().getResponse();
                       ServletOutputStream servletOutputStream;
                       servletOutputStream = response.getOutputStream();
                       byte[] bytes = null;
                       JasperDesign jasperDesign;
                                try {
                                        jasperDesign = JRXmlLoader.load(ios);
                                        jasperReport = JasperCompileManager.compileReport(jasperDesign);                
                                        JRPdfExporter exporter = new JRPdfExporter();
                                        JasperPrint jasperPrint;
                                        jasperPrint =
                                                JasperFillManager.fillReport( jasperReport, parameters, connection );
                                    } catch (JRException e) {
                                            e.printStackTrace();
                                bytes =
                                JasperRunManager.runReportToPdf(jasperReport,parameters, connection);
                       response.addHeader("Content-disposition", 
                       "attachment;filename=sale.pdf"); 
                       response.setContentType("application/pdf");
                       response.setContentLength(bytes.length);
                       servletOutputStream.write(bytes, 0, bytes.length);
                       servletOutputStream.flush();
                       servletOutputStream.close();
                       context.responseComplete();
                            } catch (IOException e) {
                        e.printStackTrace();
                    } catch (JRException e) {
                         e.printStackTrace();
                    }

  • Problem opening  Microsoft Office & PDF Email attachments

    Just got a Motorola Razr.  Having a problem opening Microsoft Office (e.g. Work, Excel) and PDF Email attachments.   Receive message "winmail.dat Unsupported file type".   Can open jpg files.  I have Quick Office, which is suppose to enable you to do this, but does not seem to make a difference.   Wonder if it is an Android 2.3.5 issue.  I used to have a Blackberry and this was not an issue.  This is a showstopper for me and I will return the phone if I can't read Microsoft Office and PDF files attached to emails.  My email server / client is Verizon.
    I would appreciate any recommendations.

    Hope this is one of those "better late than never" scenarios.
    The problem sounded familiar, and it's one that's been around for a long, long time.  I don't think it's a Razr problem, or a Droid problem, but it is about email clients.  I've had similar issues with email on computers.
    The problem starts with Outlook's RTF format.  It saves the document's formatting info (bold, underline, etc.) and other info in the winmail.dat file, and some email clients simply can't decode it. 
    The sender can change the format of what they're sending, though, and I believe that the most recent versions of Outlook can change those format setttings on a person-by-person basis (don't want to start a rumor here because I could be wrong about that).
    Just copy and paste the error message into Google (or your preferred search engine, and you'll see some info that might be helpful.

  • Servlet generated PDF wont show up in browser

    This is the code i use to show the PDF in a browser
    ByteArrayOutputStream outStream = new ByteArrayOutputStream();
    res.setContentType("application/pdf");
    res.setHeader("Content-Disposition","inline;Filename= " + file.getName());
    ServletOutputStream sos = res.getOutputStream();
                   outStream.writeTo(sos);
                   sos.flush();          
                   outStream.close();
                   sos.close();
    In Netscape i get an error saying the filename does not start with %PDF and in IE the page just shows up blank. from the blank pagewhen i use the back button and then hit the forward button the pdf will show up in IE.
    I also tries using fileOuput stream instead of servletoutputstream
         FileOutputStream fout = new FileOutputStream( file );
                   outStream.writeTo(fout);
                   fout.close() ;
                   outStream.close() ;
    In this case IE does nothing but it works on netscape or mozilla
    This is running on websphere 5.0 , apache webserver on linux env
    But i need to get this worked on IE any help would be greatly appreciated!
    Thanks in Advance
    Sid

    I just skipped posting over the actual pdf write code.
    ByteArrayOutputStream outStream = new ByteArrayOutputStream();
    //Write bytes to the PDF
    writer = createDocument(document, outStream);
    res.setContentType("applicatio�n/pdf");
    res.setHeader("Content-Disposi�tion","inline;Filename= " +
    file.getName());
    ServletOutputStream sos = res.getOutputStream();
    outStream.writeTo(sos);
    sos.flush();
    outStream.close();
    sos.close();
    If i use fileOutputStream i can see that the file is being created physically without any problem. It would not though open up in the Browser!
    Thanks
    Sid

  • Problem opening html file in separate browser window

    I have an forms app where a user can download a file from the database and then open that file on the client. After the file is downloaded, I use webutil_host.nonblocking ('cmd /s start' ||filename) and it works fine for .doc, .xls etc. as these open a separate program. Problem occurs when user downloads an html file, the command opens the file in the same browser window as forms is running, thus ending the forms session.
    I've tried web.show_document('file:\\'||filename) but that fails as I assume it is looking for the file on the application server instead of on the client.
    Any ideas on how to workaround this issue?

    Well I searched around on google looking for a java servlet or jsp example and couldn't find one. I know they are out there becasue thats where I got mine about a year ago. I dont work at the same place anymore and couldnt take my code with me. Anyway, you would use this servlet for any document (xls, doc, html, txt, pdf) that is in the blob column in the db. The servlet would send a mime type first in the response and then the blob. The browser would display the blob in the associated helper application on the client (Excel, Word, IE, notpad, Adobe Acrobat Reader, etc..). The user can then save the document to their hard drive if they wish. This is faster becasue the clients hard drive isnt involved in the transfer from db to client. The user can then edit the document and reupload the document. Thats how we did it.
    Maybe somebody else can post a link to a generic blob download servlet? Thanks..

  • Cannot open links in PDF inside browser.

    Hi,
    I'm facing a problem that's driving me crazy. When I click a PDF and open inside the browser (internet explorer), if the PDF have links and I click on them nothing happen. If I save the PDF and open in Adobe Reader the links function properly and go to the respective URL.
    Can same one help me?

    I forgot to mention:
    Windows 7 and last version of adobe reader

  • Some users can't open Xcelsius-generated PDFs

    I'm creating PDFs with Xcelsius Present 5.3.4 on Windows XP.  When I distribute them, some people can open and others cannot.  I haven't seen any obvious configuration difference and at least one person has had the problem after loading the latest Reader and Flash versions.  Any idea what else they should check?

    I get different reports but most common is either blank or it won't open at all.  One thing I tried today was sending a SWF.  One person who had a problem with the PDF couldn't open SWF but was able to read it when they navigated to it via their browser.  Does that sound like a clue?

  • Problem Open links to fileshare when browse to SharePoint in chrome and firefox

    We have a search center site and results come from file share.
    It seems that when user use Chrome and firefox - there is a problem to open a link to the file. In addition in case the file is an image - the preview image is seen only in IE
    keren tsur

    Hi,
    According to your post, my understanding is that you couldn’t see the image preview in search results.
    First, you should know that the search center can crawl image files, however, the results only return these image files as list items and no image preview will appear whichever browses you use.
    The cause of this issue is that the image result type uses the Default Item template and not the Picture template.
    I recommend that you can use the SharePoint Designer 2013 to modify the hover display template that is being used for default items.
    For more information, you can refer to:
    http://blogs.realdolmen.com/experts/2014/03/17/images-in-sharepoint-server-2013-search/
    Best Regards,
    Linda Li
    TechNet Community Support

  • Having a problem opening documents in pdf

    Not sure if this is in the right place - this website is very confusing.
    I use a screenwriting software called CELTX. I recently had to have a new hard drive installed and subsequently had to re install CELTX onto the new drive. The upshot of that was, all the documents that I had saved to PDF that had been converted uses CELTX now won't open.
    I get a message in ADOBE READER that goes:  Adobe reader cannot open 'title' (Celtx) because it is either not a supported file or the file has been damaged (for example it was sent as an email and not properly decoded).
    I'm using ADOBE 9.1.3. Previously, Adobe supported my CELTX files with no problems,
    I have posted this to the CELTX forum with no joy.
    Thanks for any help

    FYI - Reader Forum http://forums.adobe.com/community/adobe_reader_forums

  • Problem opening up internet pdf files

    I cannot open pdf files from the internet. If I try to open one, only a small black square appears in the upper left corner. This has only recently begun. I have tried reloading adobe reader but the results remain

    Try the suggestions here http://helpx.adobe.com/acrobat/kb/cant-view-pdf-web.html

Maybe you are looking for