jsreport methods got undefined on angular application.

  • I have used the reports in jsreport studio from my application, In this report i download pdf and excel format jsreport studio, this template i used in my application while download pdf and excel format the methods got undefined.

    The jsreport studio code is:
    <button onclick="printExcel()" style="width: 200px" class="small-button button loading-pulse lighten success">
    Download Excel Report
    <button onclick="printPdf()" style="width: 200px" class="small-button button loading-pulse lighten primary">
    Download pdf Report

    the script code is:

    function printExcel() {
    var blob = new Blob([document.getElementById('testform').innerHTML], {
    type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;"
    saveAs(blob, "Report.xls");
    function printPdf() {
    var myJSON = JSON.stringify(jsreport.data.posts);
    var blob = new Blob([myJSON], {
    type: "application/pdf"
    var pdf = new jsPDF();
    pdf.addHTML(($("#pdfContent")[0]), { pagesplit: true }, function () {
    pdf.save('NovusReport' + '.pdf');

    In this code have two methods got undefined while using my application via API.

    ![alt text](0_1500013328029_scriptloadedimages.PNG image url)

    here all the jsreport script method is comes in my application but i don't know why it got undefined .

  • hi,

    I am facing exactly the same situation when trying to use jsReport with Angular 2.

    the possible workaround that I found for now is-
    remember that your report contains <script> tags, and for security issue angular won't let you inject scripts in DOM like this. you can use DomSanitizer to ByPass the security and then put the response in an iFrame [DomSanitizer - https://angular.io/guide/security#bypass-security-apis]

    hope this helps.

Log in to reply

Looks like your connection to jsreport forum was lost, please wait while we try to reconnect.