Now it is working, thank you.
GioMaugeri
@GioMaugeri
Posts made by GioMaugeri
-
Error rendering content jsreport 4.0.0
Hi,
I just installed jsreport again on my pc, and I create a new report. I'm having this error when I render it:
Report "content" render failed.
Could not find Chrome (ver. 116.0.5845.96). This can occur if either
- you did not perform an installation before running the script (e.g.
npm install
) or - your cache path is incorrectly configured (which is: C:\Windows\system32\config\systemprofile.cache\puppeteer).
Can you help me solve this?
Thanks.
- you did not perform an installation before running the script (e.g.
-
RE: @ index always 0 in jsreport api
Was that the problem, the missing "mergeWholeDocument", thanks.
-
RE: @ index always 0 in jsreport api
Sorry, it is that if I use @ index without spaces in this text, it is converted in to a number
-
RE: @ index always 0 in jsreport api
Here the json cose that I send as request:
{ "template": { "helpers": "function test(){}", "chrome": { "marginTop": "3cm" }, "engine": "handlebars", "pdfOperations": [ { "template": { "helpers": "function getPageNumber(pageIndex) {\r\n if (pageIndex == null) {\r\n return ''\r\n }\r\n pageIndex = parseInt(pageIndex);\r\n const pageNumber = pageIndex + 1\r\n return pageNumber\r\n}\r\n\r\nfunction getTotalPages(pages) {\r\n if (!pages) {\r\n return ''\r\n }\r\n return pages.length\r\n}\r\n\r\nfunction stringIsNullOrEmptyWithDefault(str) {\r\n if (!str || 0 === str.toString().trim().length) {\r\n return '-';\r\n } else {\r\n return str;\r\n }\r\n}\r\n\r\nfunction stringIsNotNullOrEmpty(str) {\r\n return !(!str || 0 === str.toString().trim().length);\r\n}", "engine": "handlebars", "recipe": "chrome-pdf", "content": "<html>\r\n\r\n<head>\r\n <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />\r\n <style>\r\n * {\r\n box-sizing: border-box;\r\n }\r\n\r\n html,\r\n body {\r\n color: #252525;\r\n font-family: arial, sans-serif;\r\n font-size: 13px;\r\n margin: 0px;\r\n padding: 0px;\r\n margin: 0px 30px 0px 30px !important;\r\n }\r\n\r\n .main {\r\n display: flex;\r\n flex-direction: column;\r\n justify-content: space-between;\r\n width: 100%;\r\n height: 100%;\r\n }\r\n\r\n .header {\r\n width: 100%;\r\n padding-top: 30px;\r\n }\r\n\r\n .footer {\r\n width: 100%;\r\n padding-bottom: 30px;\r\n }\r\n\r\n table {\r\n font-size: 13px;\r\n border-collapse: collapse;\r\n width: 100%;\r\n }\r\n\r\n td {\r\n border: 1px solid #252525;\r\n padding: 5px;\r\n }\r\n\r\n .td-non-border {\r\n border: 0px;\r\n padding: 2px;\r\n }\r\n\r\n .left {\r\n text-align: left;\r\n }\r\n\r\n .right {\r\n text-align: right;\r\n }\r\n\r\n .center {\r\n text-align: center;\r\n }\r\n\r\n .bold {\r\n font-weight: bold;\r\n }\r\n\r\n .text-wrap-2 {\r\n display: -webkit-box;\r\n -webkit-line-clamp: 2;\r\n -webkit-box-orient: vertical;\r\n overflow: hidden;\r\n }\r\n\r\n .text-vertical-align-top {\r\n vertical-align: text-top;\r\n }\r\n\r\n .page-break-before-always {\r\n page-break-before: always;\r\n }\r\n\r\n .margin-0px {\r\n margin: 0px;\r\n }\r\n\r\n .text-align-center {\r\n text-align: center;\r\n }\r\n\r\n .height-60px {\r\n height: 60px;\r\n }\r\n\r\n .text-vertically-right {\r\n position: absolute;\r\n width: 300px;\r\n height: 200px;\r\n z-index: 99999999999;\r\n left: 0%;\r\n margin: 280px 0px 0px -80px;\r\n font-size: 6px;\r\n float: right;\r\n -moz-transform: rotate(270deg);\r\n /* FF3.5+ */\r\n -o-transform: rotate(270deg);\r\n /* Opera 10.5 */\r\n -webkit-transform: rotate(-90deg);\r\n /* Saf3.1+, Chrome */\r\n -moz-transform-origin: 100% 100%;\r\n -o-transform-origin: 100% 100%;\r\n -webkit-transform-origin: 100% 100%;\r\n }\r\n\r\n .font-16{\r\n font-size: 16px;\r\n }\r\n <\/style>\r\n<\/head>\r\n\r\n<body>\r\n\r\n {{#each $pdf.pages}} {{#if 5}}\r\n <div class=\"page-break-before-always\"><\/div>\r\n {{/if}}\r\n <main class=\"main\">\r\n <header class=\"header\">\r\n \r\n <\/header>\r\n <footer class=\"footer\">\r\n <table>\r\n <tbody>\r\n <tr>\r\n <td class=\"td-non-border text-align-center\" width=\"20%;\">\r\n {{#if (stringIsNotNullOrEmpty @root.$info.code)}}\r\n <img class=\"height-60px\" alt=\"Barcoded value {{@root.$info.code}}\" src=\"{{@root.$info.barcode}}\">\r\n <br/> {{/if}}\r\n <b>{{@root.$info.code}}<\/b>\r\n <\/td>\r\n {{5}}\r\n <td class=\"right td-non-border \">\r\n pagina {{getPageNumber 5}} di {{getTotalPages ../$pdf.pages}}\r\n <\/td>\r\n <\/tr>\r\n <\/tbody>\r\n <\/table>\r\n <\/footer>\r\n <\/main>\r\n {{/each}}\r\n<\/body>\r\n\r\n<\/html>" }, "type": "merge" } ], "recipe": "chrome-pdf", "content": "<div style=\"padding-bottom:2000px\">\r\n Test \r\n<\/div>" }, "data": { }, "options": { "reports": { "save": true } } }
-
@ index always 0 in jsreport api
Hi,
I'm using the jsreport api to generate reports. I have a problem with the number of page. I print on the header content the 6 value, and if I open the jsReport on my machine, that works, but when I send the header content to jsReport api, when the report is generated the @ index is always 0.
How can I resolve this?
Thanks in advance.
-
Api send custom content with header for each page
Hi,
I'm trying to do a request to api/report endoinpt and I want to create a report with custom content and with an header for eache page that have custom content too.
For now I sent this:
{ "template": { "content": "hello world", "recipe": "chrome-pdf", "engine": "handlebars", "chrome":{ "marginTop": "3cm" }, "pdfOperations": [ { "type": "merge", "mergeWholeDocument": true, "templateShortid": "-xuqFWrlI" } ] }, "data": {}, "options": { "reports": { "save": true } } }
for now I have custom content on my page ("Hello world") and I want to send custom header but I can send only the template short id of an header. There is a way to send custom content also for the header?
Thanks in advance.