2 Replies Latest reply on Aug 19, 2013 11:12 AM by Patrick Wolf-Oracle

    MIME type issue in version 4.1/4.2 Compatibility Mode


      Problem: when displaying a PDF file, it displays OK as PDF if APEX 'Compatability Mode' = 'Pre 4.1', but displays as HTML when in either '4.1' or '4.2' mode.



      DB: 11gr2

      Web server: Apache on Linux


      More detailed description... this seems to be a MIME type issue related to APEX (or maybe DB) versioning.  The following code works as expected when run in 'Pre 4.1' mode - ie. it displays an appropriate PDF document in the appropriate Acrobat/other plugin in several browsers (Firefox/Opera/Chrome/IE).  But just by changing 'Compatability Mode' to '4.2' (or even '4.1'), it then downloads the file but displays it as a bunch of random characters, and the web page header MIME type is 'text/HTML'.


      Note: this also happens with other file types such as xls/doc/etc, but I expect fixing PDF should also fix these.


      I'm at a bit of a loss as to where this is happening, it seems there is a difference in the 'Compatibility Modes' between either the creating of the HTML header using 'OWA_UTIL.mime_header' or the component path it traverses before reaching apache.


      The only other thing I could think of is that we do a bit of redirection to display the PDF, though this seems like it might be a red herring.  Basically we use page 560 as a container, and then display the PDF with page 561 within a frame embeded within page 560.  So, on the page 560, which is the one we reference throughout the application, we have  a region with a source of '&lt;iframe src=?p=&APP_ID.:561:&SESSION.height="500" width="700"&gt&lt;/iframe&gt</pre>'.  Then on page 561, in a 'On Load - Before Header' process, we make the call to the code 'DOWNLOAD_APPLICANT_PDF' (below).


      Note: I did try calling 'apex_application.stop_apex_engine' after 'DOWNLOAD_APPLICANT_PDF', as suggested in a couple threads, but it didn't fix the problem, and caused a couple low-level system errors.







            v_length      NUMBER;

            lob_loc       BLOB;

            l_display_inline   CHAR := '1';



            SELECT pdf_data, DBMS_LOB.getlength (pdf_data)

              INTO lob_loc, v_length

              FROM pdf_dest

             WHERE pdf_dest_id = p_doc_id;


            OWA_UTIL.mime_header ('application/pdf', FALSE);

            HTP.p ('Content-length: ' || v_length);

            HTP.p ('Content-Disposition:inline;filename="mydoc.pdf"');



            WPG_DOCLOAD.download_file (lob_loc);