1

I'm running Apex 19.2.

I have a pdf stored as blob file in a table. I'm trying to download the blob in a page process.

The process works fine however, the file doesn't download but gets displayed in the browser instead.

Can anyone help please ? I need the file to download and not show in the browser...

Here is my code :

        File Blob; -- Blob content is set somewhere else...
        sys.HTP.init;
        sys.OWA_UTIL.mime_header(MimeType, FALSE);
        sys.HTP.p('Content-Length: ' || DBMS_LOB.getlength(File));
        sys.HTP.p('Content-Disposition: filename="report.pdf"');
        sys.OWA_UTIL.http_header_close;

        sys.WPG_DOCLOAD.download_file(file);
        apex_application.stop_apex_engine;  

Thanks, Cheers,

Thomas Carlton
  • 5,344
  • 10
  • 63
  • 126

2 Answers2

1

Change this line:

sys.HTP.p('Content-Disposition: filename="report.pdf"');

To this:

sys.HTP.p('Content-Disposition: attachment; filename="report.pdf"');
Dan McGhan
  • 4,479
  • 1
  • 11
  • 15
0

By default this is an individual browser setting, a preference configurable by end users.

It does appear that it can be forced through the link/URL that generates the PDF:

pmdba
  • 6,457
  • 2
  • 6
  • 16