Core: Scripts in View are not executing.

  • I'm currently evaluating jsreport core. I have it working and currently able to produce a pdf from a view.
    However, is there a way to force jsreport to execute script when the view is rendered? I notice that the script (declared in-line at the end of view form) I have in the view are NOT executing. Adding a simple "alert("test") in the script generates an error.

    In my controller, when I add (thinking the script will run):
    .Configure((r) => r.Template.Chrome = new jsreport.Types.Chrome
    WaitForJS = true,
    WaitForNetworkIddle = true

    I get an exception error:
    : 'Unable to render template. Timeout Error: pdf generation not completed after 30000ms'

    Can you help?


  • FYI: These are the packages I installed:
    jsreport.AspNetCore -Version 2.0.1
    jsreport.Local -Version 2.0.1
    jsreport.Binary -Version 2.4.0

  • Scripts in View are not executing.

    Scripts are executed inside the chrome when the chrome-pdf recipe runs. Maybe try to play with the pdf rendering in the playground to get a better idea how it works. Then switch to .net


    Check what is that actually doing. You get timeout because of that.

  • Try to add something like this at the end of your view.


    You should see "hello" at the end of the pdf

  • Thank you for the quick reply. My situation is that I have ajax call to inject a div's html. This html is generated by jquery formbuilder ( Is there a way to make sure this ajax runs BEFORE passing it to chrome?

  • Such script will run inside the chrome. However this is ok, you just need to postpone the pdf print until the function finishes.
    This can be achieved using printing trigger

  • Thanks again. The ASP.NET Core app I'm working on uses jquery heavily.
    I'm finding out during simple test that jquery do NOT get executed.

    Script at the end of my view:

        <script type="text/javascript">
            .then(setTimeout(function () {
                window.JSREPORT_READY_TO_START = true; //this will start the pdf printing
            }, 9000));
        async function loadFormBuilder() {
            document.write('start doc ready..');
          //  var test = "hello";
            var test = $("#testjsreport").val();
            document.write('gets printed when var test is not populated by jquery:' + test);

    I have this on my controller:

        public IActionResult ExportToPdf(int? id)
            var existingResponse = _sourcingEventService.GetFormResponseById(id.Value);
              //  .DebugLogsToResponse()
                .Configure((r) => r.Options = new jsreport.Types.RenderOptions
              //      Preview = true,
                    Timeout = 90000
            .Configure((c) => c.Template.Chrome = new jsreport.Types.Chrome
                 WaitForJS = true
            return View(new FormResponseViewModel(existingResponse));

    Are there any tricks to allow executing jquery?

  • There are no tricks needed. It should just work if you have no other issues there.
    Try to return just html recipe and see if there are no js errors.

    You can also prepare for us playground workspace, if you render html and put it there.
    We can take then take a look at what could be wrong.

Log in to reply

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