Cant convert Razor View to PDF while running jsreport inside a docker container.



  • I have a docker container set up with jsreport running. Here is the content of my docker file FROM jsreport/jsreport:2.5.0

    In my controller I have decorated the action with
    [MiddlewareFilter(typeof(JsReportPipeline))] attribute and added

    this.HttpContext.JsReportFeature().DebugLogsToResponse().Recipe(Recipe.ChromePdf).OnAfterRender((r) => HttpContext.Response.Headers["Content-Disposition"] = $"attachment; filename=\"{this.Form}.pdf\""); before returning the view.

    This is not working for me. I have copied the logs from my docker container:

    2020-04-13T13:27:33.821Z - info: Searching for available extensions in /app/,
    2020-04-13T13:27:33.825Z - info: Extensions location cache not found, crawling directories,
    2020-04-13T13:27:34.097Z - info: Found 35 extensions,
    2020-04-13T13:27:34.299Z - info: Setting dedicated-process (process based) strategy for rendering. Please visit http://jsreport.net/learn/configuration for information how to get more performance.,
    2020-04-13T13:27:34.308Z - info: Using extension authentication@2.4.2,
    2020-04-13T13:27:34.334Z - info: Using extension cli@2.2.2,
    2020-04-13T13:27:34.336Z - info: Using extension debug@2.1.3,
    2020-04-13T13:27:34.339Z - info: Using extension express@2.6.0,
    2020-04-13T13:27:34.419Z - info: Using extension freeze@2.0.0,
    2020-04-13T13:27:34.421Z - info: Using extension handlebars@2.1.0,
    2020-04-13T13:27:34.423Z - info: Using extension import-export@1.5.1,
    2020-04-13T13:27:34.465Z - info: Using extension jsrender@2.1.1,
    2020-04-13T13:27:34.466Z - info: Using extension tags@2.3.0,
    2020-04-13T13:27:34.467Z - info: Using extension templates@2.3.2,
    2020-04-13T13:27:34.473Z - info: Using extension authorization@2.2.6,
    2020-04-13T13:27:34.475Z - info: Using extension base@2.0.2,
    2020-04-13T13:27:34.477Z - info: Using extension browser-client@2.2.2,
    2020-04-13T13:27:34.478Z - info: Using extension child-templates@1.3.1,
    2020-04-13T13:27:34.480Z - info: Using extension chrome-pdf@1.7.1,
    2020-04-13T13:27:34.527Z - info: Using extension data@2.2.0,
    2020-04-13T13:27:34.528Z - info: Using extension docx@2.5.0,
    2020-04-13T13:27:34.531Z - info: Using extension fs-store@2.7.2,
    2020-04-13T13:27:34.628Z - info: Using extension licensing@2.2.1,
    2020-04-13T13:27:34.630Z - info: Using extension pdf-utils@1.6.1,
    2020-04-13T13:27:34.736Z - info: Using extension pptx@0.5.0,
    2020-04-13T13:27:34.739Z - info: Using extension reports@2.2.1,
    2020-04-13T13:27:34.741Z - info: Using extension static-pdf@0.3.1,
    2020-04-13T13:27:34.743Z - info: Using extension studio@2.7.0,
    2020-04-13T13:27:34.840Z - info: Using extension text@2.0.0,
    2020-04-13T13:27:34.843Z - info: Using extension version-control@1.3.2,
    2020-04-13T13:27:34.898Z - info: Using extension assets@1.5.2,
    2020-04-13T13:27:34.908Z - info: Using extension html-to-xlsx@2.6.0,
    2020-04-13T13:27:35.137Z - info: html-to-xlsx detected chrome as available html engine,
    2020-04-13T13:27:35.137Z - info: Using extension scheduling@2.2.0,
    2020-04-13T13:27:35.177Z - info: Using extension scripts@2.3.0,
    2020-04-13T13:27:35.182Z - info: Using extension studio-theme-dark@0.3.0,
    2020-04-13T13:27:35.183Z - info: Using extension xlsx@2.3.0,
    2020-04-13T13:27:35.263Z - info: Using extension public-templates@2.1.0,
    2020-04-13T13:27:35.264Z - info: Using extension resources@2.0.3,
    2020-04-13T13:27:35.265Z - info: Using extension sample-template@2.5.1,
    2020-04-13T13:27:35.266Z - info: Using general timeout for rendering (reportTimeout: 60000),
    2020-04-13T13:27:35.267Z - info: Using fs provider for template store.,
    2020-04-13T13:27:35.275Z - info: fs store is persisting using fs,
    2020-04-13T13:27:35.277Z - info: fs store sync is disabled,
    2020-04-13T13:27:35.278Z - info: fs store underlying changes synchronization with studio is disabled,
    2020-04-13T13:27:35.284Z - info: fs store is loading data,
    2020-04-13T13:27:35.296Z - info: fs store is initialized successfully,
    2020-04-13T13:27:35.331Z - info: Creating default express app.,
    2020-04-13T13:27:35.355Z - info: jsreport server successfully started on http port: 5488,
    2020-04-13T13:27:35.357Z - info: Verifying license key free,
    2020-04-13T13:27:35.368Z - info: Using free license,
    2020-04-13T13:27:35.374Z - info: reporter initialized,
    2020-04-13T14:37:39.508Z - info: Starting rendering request 1 (user: null),
    2020-04-13T14:37:39.510Z - info: Rendering anonymous template { recipe: undefined, engine: undefined },
    2020-04-13T14:37:39.513Z - error: Rendering request 1 finished with error in 6 ms,
    2020-04-13T14:37:39.514Z - error: Error when processing render request 1 Cannot read property 'includes' of undefined,
    logs:,
    +0      Starting rendering request 1 (user: null),
    +3      Rendering anonymous template { recipe: undefined, engine: undefined },
    +3      Data item not defined for this template.,
    +3      Resources not defined for this template.,
    +6      Rendering request 1 finished with error in 6 ms TypeError: Cannot read property 'includes' of undefined,
        at AsyncFunction.<anonymous> (/app/node_modules/jsreport-pdf-utils/lib/main.js:79:28),
        at /app/node_modules/listener-collection/lib/listenerCollection.js:171:33,
        at /app/node_modules/listener-collection/lib/listenerCollection.js:151:16,
        at tryCatcher (/app/node_modules/listener-collection/node_modules/bluebird/js/release/util.js:16:23),
        at Promise._settlePromiseFromHandler (/app/node_modules/listener-collection/node_modules/bluebird/js/release/promise.js:512:31),
        at Promise._settlePromise (/app/node_modules/listener-collection/node_modules/bluebird/js/release/promise.js:569:18),
        at Promise._settlePromise0 (/app/node_modules/listener-collection/node_modules/bluebird/js/release/promise.js:614:10),
        at Promise._settlePromises (/app/node_modules/listener-collection/node_modules/bluebird/js/release/promise.js:693:18),
        at Async._drainQueue (/app/node_modules/listener-collection/node_modules/bluebird/js/release/async.js:133:16),
        at Async._drainQueues (/app/node_modules/listener-collection/node_modules/bluebird/js/release/async.js:143:10),
        at Immediate.Async.drainQueues (/app/node_modules/listener-collection/node_modules/bluebird/js/release/async.js:17:14),
        at processImmediate (internal/timers.js:456:21),
    2020-04-13T14:37:39.515Z - error: Error during processing request at http://localhost:5488/api/report,
    2020-04-13T15:56:22.743Z - info: Starting rendering request 2 (user: null),
    2020-04-13T15:56:22.744Z - info: Rendering template { name: PDF, recipe: chrome-pdf, engine: handlebars, preview: true },
    2020-04-13T15:56:23.256Z - info: Rendering request 2 finished in 512 ms,
    2020-04-13T15:57:08.984Z - info: Starting rendering request 3 (user: null),
    2020-04-13T15:57:08.985Z - info: Rendering template { name: PDF, recipe: chrome-pdf, engine: handlebars, preview: true },
    2020-04-13T15:57:09.445Z - info: Rendering request 3 finished in 461 ms,```


  • You use FROM jsreport/jsreport:2.5.0 but in logs I see Using extension pdf-utils@1.6.1.
    This pdf utils version isn't part of jsreport@2.5.0. Have you done some customizations in your dockerfile?

    The trouble is this line. It looks the recipe definition isn't properly passed to the jsreport endpoint. Not sure why at this moment.

     Rendering anonymous template { recipe: undefined, engine: undefined }
    

    How do you add jsreport to the asp.net web app? Something like this?

    services.AddJsReport(new ReportingService("http://localhost:5488"));
    

    Do you have some extra code in the controller action, maybe there is some problem.



  • No my dockerfile is just one line which pulls the jsreport image. I do not pass a config file or anything. The contents of the dockerfile are FROM jsreport/jsreport:2.5.0. Is there a later version i could try?

    And yes, i add jsreport to my webapp exactly like that services.AddJsReport(new ReportingService("http://localhost:5488"));

    My controller code:

         response.VehicleName = "Test";
    
         this.HttpContext.JsReportFeature().DebugLogsToResponse().Recipe(Recipe.ChromePdf).OnAfterRender((r) => HttpContext.Response.Headers["Content-Disposition"] = $"attachment; filename=\"{this.Form}.pdf\"");
    
          return this.View("MyView", response);```


  • No my dockerfile is just one line which pulls the jsreport image. I do not pass a config file or anything.

    That is strange. That image for sure has different pdf utils version.

    Is there a later version i could try?

    2.7.2 is the current latest
    https://hub.docker.com/r/jsreport/jsreport/tags
    https://github.com/jsreport/jsreport/releases

    Do you have the latest jsreport.AsppNetCore nugget package? it should be 2.0.2.
    https://www.nuget.org/packages/jsreport.AspNetCore/



  • Sorry, one thing i just noticed is that my Dockerfile was FROM jsreport/jsreport:latest. Maybe that is the problem. I have specified it to be FROM jsreport/jsreport:2.7.2 now. I will run it again and try and let you know.

    Yes, using the latest NuGet Package, which is 2.0.2



  • Using version 2.7.2 still shows using pdf utils version. Here is the log

    2020-04-13T17:41:06.402Z - info: Initializing jsreport@2.7.2 in production mode using configuration file: jsreport.config.json,
    2020-04-13T17:41:06.405Z - info: Searching for available extensions in /app/,
    2020-04-13T17:41:06.411Z - info: Extensions location cache not found, crawling directories,
    2020-04-13T17:41:06.732Z - info: Found 35 extensions,
    2020-04-13T17:41:06.971Z - info: Setting dedicated-process (process based) strategy for rendering. Please visit http://jsreport.net/learn/configuration for information how to get more performance.,
    2020-04-13T17:41:06.978Z - info: Using extension authentication@2.4.2,
    2020-04-13T17:41:07.010Z - info: Using extension cli@2.2.2,
    2020-04-13T17:41:07.013Z - info: Using extension debug@2.1.3,
    2020-04-13T17:41:07.015Z - info: Using extension express@2.6.0,
    2020-04-13T17:41:07.132Z - info: Using extension freeze@2.0.0,
    2020-04-13T17:41:07.134Z - info: Using extension handlebars@2.1.0,
    2020-04-13T17:41:07.138Z - info: Using extension import-export@1.5.1,
    2020-04-13T17:41:07.189Z - info: Using extension jsrender@2.1.1,
    2020-04-13T17:41:07.190Z - info: Using extension tags@2.3.0,
    2020-04-13T17:41:07.192Z - info: Using extension templates@2.3.2,
    2020-04-13T17:41:07.195Z - info: Using extension authorization@2.2.6,
    2020-04-13T17:41:07.197Z - info: Using extension base@2.0.2,
    2020-04-13T17:41:07.199Z - info: Using extension browser-client@2.2.2,
    2020-04-13T17:41:07.203Z - info: Using extension child-templates@1.3.1,
    2020-04-13T17:41:07.207Z - info: Using extension chrome-pdf@1.7.1,
    2020-04-13T17:41:07.263Z - info: Using extension data@2.2.0,
    2020-04-13T17:41:07.264Z - info: Using extension docx@2.5.0,
    2020-04-13T17:41:07.268Z - info: Using extension fs-store@2.7.2,
    2020-04-13T17:41:07.365Z - info: Using extension licensing@2.2.1,
    2020-04-13T17:41:07.368Z - info: Using extension pdf-utils@1.6.1,
    2020-04-13T17:41:07.486Z - info: Using extension pptx@0.5.0,
    2020-04-13T17:41:07.487Z - info: Using extension reports@2.2.1,
    2020-04-13T17:41:07.490Z - info: Using extension static-pdf@0.3.1,
    2020-04-13T17:41:07.493Z - info: Using extension studio@2.7.0,
    2020-04-13T17:41:07.565Z - info: Using extension text@2.0.0,
    2020-04-13T17:41:07.568Z - info: Using extension version-control@1.3.2,
    2020-04-13T17:41:07.610Z - info: Using extension assets@1.5.2,
    2020-04-13T17:41:07.618Z - info: Using extension html-to-xlsx@2.6.0,
    2020-04-13T17:41:07.821Z - info: html-to-xlsx detected chrome as available html engine,
    2020-04-13T17:41:07.822Z - info: Using extension scheduling@2.2.0,
    2020-04-13T17:41:07.863Z - info: Using extension scripts@2.3.0,
    2020-04-13T17:41:07.868Z - info: Using extension studio-theme-dark@0.3.0,
    2020-04-13T17:41:07.869Z - info: Using extension xlsx@2.3.0,
    2020-04-13T17:41:08.013Z - info: Using extension public-templates@2.1.0,
    2020-04-13T17:41:08.014Z - info: Using extension resources@2.0.3,
    2020-04-13T17:41:08.016Z - info: Using extension sample-template@2.5.1,
    2020-04-13T17:41:08.026Z - info: Using general timeout for rendering (reportTimeout: 60000),
    2020-04-13T17:41:08.027Z - info: Using fs provider for template store.,
    2020-04-13T17:41:08.033Z - info: fs store is persisting using fs,
    2020-04-13T17:41:08.035Z - info: fs store sync is disabled,
    2020-04-13T17:41:08.036Z - info: fs store underlying changes synchronization with studio is disabled,
    2020-04-13T17:41:08.054Z - info: fs store is loading data,
    2020-04-13T17:41:08.068Z - info: fs store is initialized successfully,
    2020-04-13T17:41:08.121Z - info: Creating default express app.,
    2020-04-13T17:41:08.182Z - info: jsreport server successfully started on http port: 5488,
    2020-04-13T17:41:08.184Z - info: Verifying license key free,
    2020-04-13T17:41:08.185Z - info: Using free license,
    2020-04-13T17:41:08.202Z - info: reporter initialized,



  • Yes, this is ok. No problem with the 2.7.2. and the log.

    What is your jsreport.Client version?. I have 3.0.1. What is your .net core version?
    0_1586801587917_upload-729e32d3-e88a-40e6-a959-9e2eee09674d

    Do you get the same if you start from scratch? Create the default asp.net core web app, add jsreport.AspNetCore and jsreport.Client nugets and try it out?



  • 0_1586801914349_upload-c26390f6-baad-437f-bf85-1920bcc3ceba

    Using client version 3.0.1. We are still using .net core 2.2.0



  • I got it to work using 2.7.2. everything is working as expected. Thanks for your help!


Log in to reply
 

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