5 Replies Latest reply on Mar 28, 2013 7:00 PM by Sam_06

    Display PDF contents in a PL/SQL region

      I am trying to create a page that directly dispalys the content of a PDF file stored as a BLOB in some table. I was able to do that using a link that shows the regular pop-up confirming if I want to save file or open directly, this works fine, but it is not what I want. I want to directly display the content of the pdf without needing to click on anything or save file.

      I am pretty sure I am using the right code, but it is not showing the content of the file correctly, it shows ascii symbols instead such as:

      %PDF-1.5 %���� 2 0 obj <>stream x�������mH@pg�� endstream endobj 3 0 obj <>]/SMask 2 0 R/Subtype/Image/BitsPerComponent 8/Width 495/Length 55792/Height 99/Filter/FlateDecode>>stream x�Խ|TE�?�= zA@@� E���ED�C�JSJH�l �J�%����nv7�4RHHH#�m��33��lB@��������u�w�ܩ��=g�̥���f ���X�?-e1R&��l~f����\Tr����K�O��-~q�����O��&�y^v��ғx���y���e���~Vz7�<���@��C�O�_�fʀ����/U ���l15���h0�PTCEy�}�w쾄��zC1E5�g���P&��D�7Y��4R�Z }����D"4��2��P�&ʢ��C,Fe2�_-f�]��� D�d6[�fK�Ŭ��2���

      The code I am using is as follows ( in a PL/SQL dynamic region ):


      v_mime VARCHAR2 (48);
      v_length NUMBER;
      v_file_name VARCHAR2 (2000);
      v_lob_content BLOB;

      SELECT mime_type, file_content, DBMS_LOB.getlength (file_content)
      INTO v_mime, v_lob_content, v_length
      FROM tbl_pdfs
      WHERE report_id = 2;

      OWA_UTIL.mime_header (NVL (v_mime, 'application/pdf'), FALSE);
      HTP.p ('Content-length: ' || v_length);
      WPG_DOCLOAD.download_file (v_lob_content);



      Does anyone know why it is not rendering the content of the PDF correctly? I am using APEX 4.1 and I tested with IE and FF.