Enter your keyword

post

Export table data into PDF Oracle Visual Builder

A very common requirement where we need to export the table data into PDF in Oracle Visual Builder. Oracle Visual Builder doesn’t have out of the box feature that allows you to download the data into PDF, but there are certain open JavaScript libraries which you can use to achieve the same.

In this article, we will use the JS PDF library that will be used to export the table data into PDF.

Export table data into PDF

To use the JS PDF library, we have to include the following script tags in the index.html file:

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>

<script src="https://cdnjs.cloudflare.com/ajax/libs/dom-to-image/2.6.0/dom-to-image.min.js"
    integrity="sha256-c9vxcXyAG4paArQG3xk6DjyW/9aHxai2ef9RpMWO44A=" crossorigin="anonymous"></script>

<script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf/1.3.5/jspdf.min.js"></script>

The following JS function is used to generate the PDF:

 PageModule.prototype.exportToPDF = function () {

    var images = document.querySelectorAll("#downloadImage")
    for (var i = 0, len = images.length; i < len; i++) {
      images[i].removeAttribute(":src");
    }
    domtoimage.toPng(document.getElementById('table-id-to-export'))
      .then(function (blob) {
        var pdf = new jsPDF('l', 'pt', [$('#table-id-to-export').width(), $('#table-id-to-export').height()]);
        pdf.addImage(blob, 'PNG', 0, 0, $('#table-id-to-export').width(), $('#table-id-to-export').height());
        pdf.save("Employees.pdf");


      });
  };

Watch the YouTube video to know how to export table data into PDF:

Further readings:

Convert JSON to String Oracle Integration

Oracle Integration Message Packs and Pricing

Business Identifiers in Oracle Integration

You can subscribe to my YouTube channel for further reading.

Leave a Reply

Your email address will not be published.