Hi,
I am working on Oracle Database 11g and Apex 4.1.
I am using the following the code to download Excel and it is working fine.
DECLARE
v_insert CLOB ;
v_download CLOB ;
v_length NUMBER ;
l_filename VARCHAR2(100) ;
v_blob BLOB ;
FUNCTION clob_to_blob_func(v_clob Clob) RETURN BLOB AS
v_blob BLOB;
v_in Pls_Integer := 1;
v_out Pls_Integer := 1;
v_lang Pls_Integer := 0;
v_warning Pls_Integer := 0;
v_id number(10);
BEGIN
dbms_lob.createtemporary(v_blob,TRUE);
DBMS_LOB.convertToBlob(v_blob,v_clob,DBMS_lob.getlength(v_clob),
v_in,v_out,DBMS_LOB.default_csid,v_lang,v_warning);
RETURN V_BLOB;
END clob_to_blob_func;
BEGIN
v_insert := ' ' ;
dbms_lob.append ( v_insert, '<table border ="0.5" width = "100%">' ) ;
DBMS_LOB.APPEND ( V_INSERT, '<tr bgcolor="#909090">' ) ;
dbms_lob.APPEND ( v_insert, '<td>Parent ID</td> <td>ID</td> <td>Number</td> <td>System</td> <td>Price</td> <td>Type</td> ' ) ;
dbms_lob.APPEND ( v_insert, '</tr>' ) ;
dbms_lob.append ( v_insert, '</table>' ) ;
v_blob := clob_to_blob_func ( v_insert ) ;
l_filename := 'Billing Plan.xls' ;
OWA_UTIL.mime_header ('application/octet', FALSE);
v_length := dbms_lob.getlength ( v_blob ) ;
htp.p ( 'Content-length: ' || v_length ) ;
htp.p ( 'Content-Disposition: attachment; filename="' || l_filename || '"' ) ;
owa_util.http_header_close;
htmldb_application.g_unrecoverable_error := TRUE ;
wpg_docload.download_file ( v_blob ) ;
END;
The issue is, I want to download the same file in PDF format. So I updated the above procedure the below two lines ,
l_filename := 'Billing Plan.pdf' ;
OWA_UTIL.mime_header ('application/pdf', FALSE);
But it is downloading a file but as,
Unable to Open Document
File type plain text document (text/plain) is not supported
Any suggestions on how I can download the file in PDF format.
Thanks,
Shoaib