jsreport-core cannot export PDF after updating vm2 to 3.9.18
-
Hi Jan,
I saw in this thread (https://forum.jsreport.net/topic/2810/new-version-of-jsreport-v2-to-fix-the-vm2-issue) that the dependency of jsreport-core can be upgraded to solve the security problem of vm2, but jsreport-core will not work after I upgrade vm2 to 3.9.18
The specific error location is jsreport-core/lib/render/render.js await reporter.beforeRenderListeners.fire(request, response) , after this method reports an error, the following will directly enter the catch and return an empty, resulting in the PDF cannot be exported, so at this time how should i solve this problem
-
I have found the issue in the template definition
For some reason it had
"pdfPassword": {
"ownerPassword": "",
"password": ""
},I edited the template to remove this and is working now
-
Can you provide a keyword, I didn't find any of these three @thomaskotze
-
{
"id": "kIO8LXPI88cNDAlD",
"chrome": {
"displayHeaderFooter": false,
"format": "",
"landscape": false,
"marginBottom": "1.2cm",
"marginTop": "1.2cm",
"mediaType": "print",
"printBackground": true,
"scale": 1
},
"content": ".....",
"creationDate": "2023-03-16T06:28:40.978Z",
"data": {
"shortid": "Bye-DwjHbL"
},
"engine": "handlebars",
"folder": {
"shortid": "KGZUaG"
},
"helpers": ".....",
"htmlToXlsx": {
"htmlEngine": "chrome"
},
"inheritedEditPermissions": [],
"inheritedReadPermissions": [],
"modificationDate": "2023-05-17T13:51:08.531Z",
"name": "SQLTemplate",
"pdfOperations": [
{
"mergeWholeDocument": true,
"renderForEveryPage": false,
"templateShortid": "S1lEXGUP3U",
"type": "merge"
}
],
"pdfPassword": {
"ownerPassword": "",
"password": ""
},
"readPermissions": [
"vRmSVHVE0TapQdlQ"
],
"recipe": "chrome-pdf",
"shortid": "S1go9_oBZI"
}
-
rendertemplateconfig.json, I did not use the parameter pdfPassword in it, it seems that this is not the problem, thank you for your timely reply. @thomaskotze
-
This is how I call the render method in jsreport-core, the following config is the incoming template.
jsreport.render({ template: template, data: renderData })
{ "name": "name", "shortid": "11111111111111", "$entitySet": "templates", "engine": "handlebars", "recipe": "chrome-pdf", "folder": { "shortid": "Zw9h83c" }, "phantom": { "headerHeight": "120px", "footerHeight": "155px", "width": "1609", "height": "1243", "waitForJS": true, "viewportSize": { "width": "1510", "height": "910" }, "zoomFactor": "1.0" }, "chrome": { "width": "1609px", "height": "1243px", "marginTop": "150px", "marginBottom": "189px", "marginRight": "50px", "marginLeft": "50px", "waitForJS": true }, "pdfOperations": [ { "type": "prepend", "templateShortid": "SpotTpCover" }, { "type": "merge", "templateShortid": "SpotTpCover", "renderForEveryPage": false, "mergeWholeDocument": true, "mergeToFront": true }, { "type": "merge", "templateShortid": "header_footer", "renderForEveryPage": false, "mergeWholeDocument": true, "mergeToFront": true } ] }
-
Sorry what I refer to is the Template Definition Stored in JSReport server, not what we are sending via the api
-
I searched the entire program and there is no such parameter @thomaskotze
-
If you Are on a template in JSReport Server and go to pdf:utils and configure and you go to password tab , insert something there it adds it to the report definition
-
If it is convenient, post a piece of code (because the API calls are the same, I can quickly locate the location), or tell me the approximate path of this thing, because I really did not find this thing, thank you @thomaskotze
-
I seem to have found the wrong place, vm2 3.9.18 does not have the Contextify method, so how to solve this problem, is it to directly rewrite the place where the Contextify method is used in jsreport-core\lib\render\safeSandbox? @thomaskotze
\jsreport-core\lib\render\safeSandbox.js:110:48 Error when processing render request 1 Cannot read properties of undefined (reading 'Contextify') TypeError: Cannot read properties of undefined (reading ' Contextify')
-
Hi,
Sorry I am not sure what you are asking.
In the second post I indicated that I manage to solve my problem.
I am not sure how that properties got there , perhaps form migration to later versions and I thought you are just looking into this to check if there might be a bug.
Thank you