Blank pdf output



  • I know this has got to have some super easy answer but I am just beginning with this stuff and followed this tutorial: https://jsreport.net/blog/pdf-reports-in-sql-server

    Except it gives me a blank page as an output with no real error message.

    I'm using handlebars and chrome-pdf to do this...

    My database connection script is:

    const sql = require('mssql');
    const config = {
        "user": "user",
        "password": "password",
        "server": "server",
        "database": "database"
    }
    
    async function beforeRender(req, res) {
         await sql.connect(config)
        const sqlReq = new sql.Request();
        const recordset = await sqlReq.query(
            `SELECT DBVersion
          ,MinAppVersion
          
    
      FROM VersionTbl`
        )
        Object.assign(req.data, {Versions: recordset });         
    }
    

    I can see it running and connecting properly in the debug tab... and my sql query seems to be correct if I test it directly in the database server.

    My template looks like this:

    <table>
    {{#each Version}}
        <tr>
            <td>{{DBVersion}}</td>
            <td>{{MinAppVersion}}</td>
        </tr>
    {{/each}}
    </table>
    

    The debug log...

    +0      Starting rendering request 27 (user: null)
    +2      Rendering template { name: PQRTemplate, recipe: chrome-pdf, engine: handlebars, preview: true }
    +2      Data item not defined for this template.
    +9      Resources not defined for this template.
    +10     Executing script Connection using dedicated-process strategy
    +779    Base url not specified, skipping its injection.
    +780    Rendering engine handlebars using dedicated-process strategy
    +937    Compiled template not found in the cache, compiling
    +951    Executing recipe chrome-pdf
    +1041   Converting with chrome HeadlessChrome/79.0.3945.0 using dedicated-process strategy
    +1115   Page request: GET (document) file:///C:/Users/********/AppData/Local/Temp/jsreport/autocleanup/264c975a-9ef2-4130-960c-84eeae2ec04a-chrome-pdf.html
    +1122   Page request finished: GET (document) file:///C:/Users/*******/AppData/Local/Temp/jsreport/autocleanup/264c975a-9ef2-4130-960c-84eeae2ec04a-chrome-pdf.html
    +1124   Running chrome with params {"printBackground":true,"margin":{}}
    +1327   Skipping storing report.
    +1327   Rendering request 27 finished in 1327 ms
    

    Can any of you smart people tell me what's going wrong? Thanks



  • The best would be if you would add to your script console.log(recordset). That would help you with debugging the problem.

    Which is likely this one:
    The resulting promise from the query call is actually an object that looks like { recordSet: [] }.
    https://github.com/tediousjs/node-mssql#query-command-callback

    So to fix your code you should do something like this:

    const queryResult = await sqlReq.query(
      `SELECT DBVersion ,MinAppVersion FROM VersionTbl`
    )
    Object.assign(req.data, {Versions: queryResult.recordset });     
    


  • We will make this much easier to troubleshoot in jsreport v3. Stay tuned. :)



  • That worked a treat! Amazing... and thanks very much jan!



  • Maybe please delete or answer your duplicated question here
    https://stackoverflow.com/questions/64889811/blank-pdf-output-using-jsreport



  • Sorry for taking so long to do it, but I just directed the answer to this thread for anyone having the same issue. Thanks again...


Log in to reply
 

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