#47 Oracle APEX download PDF reports
Hi all,
A while ago a customer asked me if it is possible to download a (classic) report as PDF file. I know that the interactive report has a option to download it as PDF, but the classic report hasn't that option. So I've searched on the internet for a JS library that has the ability to download a PDF.
I've found the open source library jsPDF and the addon Autotables. JsPDF is a very nicefull tool HTML5 client side solution for download PDF. The addon Autotables is used for generating reports in JsPDF using JSON (AJAX call).
How to use it in APEX:
Report in PDF file
Demo: https://apex.oracle.com/pls/apex/f?p=94735:20
11-12-2018: I have created a APEX plugin for this. Check it on https://apex.world/ords/f?p=100:710:5668685349080::::P710_PLG_ID:S4S_PDF_DOWNLOAD
It is also possible to customize the report, like changing header colors, fontsize, etc. For more info visit the Github page.
See you next time!
A while ago a customer asked me if it is possible to download a (classic) report as PDF file. I know that the interactive report has a option to download it as PDF, but the classic report hasn't that option. So I've searched on the internet for a JS library that has the ability to download a PDF.
I've found the open source library jsPDF and the addon Autotables. JsPDF is a very nicefull tool HTML5 client side solution for download PDF. The addon Autotables is used for generating reports in JsPDF using JSON (AJAX call).
How to use it in APEX:
- Download the source code or use file URL's.
- Create a AJAX callback procedure that returns JSON data. (Note: Array or object type will both work)
- Implement some Javascript code.
- Create a dynamic action that will fire the Javascript code when the user click on the download button.
function download_pdf(){
var doc = new jsPDF('landscape', 'pt'); //Create JSPDF
var columns = ["EMPNO", "ENAME"]; //Report headers
var filename = 'Download PDF'; //filename
// Load data into report
apex.server.process ( "DOWNLOAD_PDF", {}, {
success: function(Data)
{
doc.autoTable(columns, Data); //Combine headers with data
doc.save(filename); //Create PDF
}
});
}
Report in PDF file
Demo: https://apex.oracle.com/pls/apex/f?p=94735:20
11-12-2018: I have created a APEX plugin for this. Check it on https://apex.world/ords/f?p=100:710:5668685349080::::P710_PLG_ID:S4S_PDF_DOWNLOAD
It is also possible to customize the report, like changing header colors, fontsize, etc. For more info visit the Github page.
See you next time!
Comments
Post a Comment