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_file_name VARCHAR2 (2000);
SELECT mime_type, file_content, DBMS_LOB.getlength (file_content)
INTO v_mime, v_lob_content, v_length
WHERE report_id = 2;
OWA_UTIL.mime_header (NVL (v_mime, 'application/pdf'), FALSE);
HTP.p ('Content-length: ' || v_length);
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.
Just trying to help here.. afaik, you'd have to wrap the data in an object tag (not sure if you could do it without it being a cached file on the client already..) so that the browser knows to invoke the adobe reader control IN the browser.. something like what is described here: http://stackoverflow.com/questions/2740297/display-adobe-pdf-inside-a-div
In the end, I think you'd get results using an IFRAME tag to hold the pdf code/pdf data inside the apex region you're working with.