Thanks for the response. It's pretty strange. In the mean time I'll use the workaround.
Posts made by mike-subtilis
-
RE: moment doesn't seem to parse date objects
-
moment doesn't seem to parse date objects
I'm having a weird experience using moment in jsReport to parse dates. The moment library works fine for this example in the node REPL or my node projects, but in jsReport it doesn't seem to want to work.
Not sure if anyone's encountered this before.
I set up a simple example in the jsreport playground:
https://playground.jsreport.net/w/anon/0itP~qJc -
RE: Slow pdf-utils merge with "Render for every page"
Yeah, that's exactly the sort of thing I was thinking. In my case there would always be the same number of pages in both, but I guess the solution should handle where the number of pages differs.
I'll keep an eye on the reusing chrome issue as well. That sounds like a really cool improvement too.
-
Slow pdf-utils merge with "Render for every page"
A scenario I'm investigating is having a report with a header that reflects the information of the page it's on. I've used the new pdf-utils & the {{{pdfCreatePagesGroup ...}}} functionality to technically get what I want, but it is too slow for production.
I've just done some basic profiling, and my 60page base report renders:
- in 6s with static header/footer
- in 90s with dynamic header/footer by merge with "Render for every page" turned on
Digging around in the pdf-utils merge code, it's rendering a report for every page (which makes sense).
I next had the idea to try rendering a second 60page report that consists of just the dynamic page headers and merging it to the base report with "Render for every page" turned off. I was speculating that it would run in about 2x the time rather than 15x. But that only prints page 1 of the 2nd report onto each page of the base report because it restarts (so it's effectively a static header).
What I was wondering is if there's a way to render the base report, then merge a 2nd report over top of it and don't restart on page 1 of the 2nd report for each page of the base? i.e. page N of the final report has page N of the base report and page N of the 2nd report.
Or if there isn't currently, if that's something on the roadmap? Taking a peak around in the pdf-utils code, it appears to be possible, but would need a clear UI and api to select that option.
-
RE: Access to linked asset denied in v2
Ah, thanks very much for this. I didn't catch it when reading over the migration notes. This change worked.
-
Access to linked asset denied in v2
I've just migrated from jsreport 1 -> 2. In v1 I added a linked asset that points to highcharts installed via npm. My config file contains "assets": { "allowedFiles": "**/*.*" }
In v2, reports that don't use highcharts seem to work, but when I try to run anything that references the asset, or even just click on the asset in jsreport studio, I get:
Request to file /app/node_modules/highcharts/highcharts.js denied. Please allow it by setting config { "assets": { "allowedFiles": "**/foo.js" } }
(in case it's relevant, the entire jsreport installation is in a folder called /app/ in the running container.)
Any ideas why I might be seeing this?
-
RE: child template extension crashes with basic test
Thanks for that other example as another way to do it.
-
RE: child template extension crashes with basic test
Ah, just noticed the bold text in the child template description. Changing from phantom-pdf to html fixed the problem completely.
-
child template extension crashes with basic test
With a vanilla installation, I added a parent template called "test-parent" with the following contents:
TEST PARENT TEMPLATE
{#child test-child}
And a child template called "test-child" with the following contents:
TEST CHILD TEMPLATE
When I try to run test-parent, I get:
2017-06-22T22:14:22.187Z - info: Starting rendering request 35 (user: null) requestId=35 2017-06-22T22:14:22.188Z - info: Rendering template {shortid:S1fRkTtXb, recipe:phantom-pdf,engine:handlebars} requestId=35 2017-06-22T22:14:22.189Z - debug: Data item not defined for this template. requestId=35 2017-06-22T22:14:22.190Z - debug: Resources not defined for this template. requestId=35 2017-06-22T22:14:22.194Z - debug: Rendering child template test-child 2017-06-22T22:14:22.195Z - info: Starting rendering request 36 (user: null) requestId=36 2017-06-22T22:14:22.195Z - info: Rendering template {shortid:SknRJpKmW, recipe:phantom-pdf,engine:handlebars} requestId=36 2017-06-22T22:14:22.196Z - debug: Inline data specified. requestId=36 2017-06-22T22:14:22.200Z - debug: Resources not defined for this template. requestId=36 2017-06-22T22:14:22.201Z - debug: Rendering engine handlebars requestId=36 2017-06-22T22:14:22.407Z - debug: Compiled template not found in the cache, compiling timestamp=Thu Jun 22 2017 16:14:22 GMT-0600 (MDT), requestId=36 2017-06-22T22:14:22.408Z - debug: Replaced images [] requestId=36 2017-06-22T22:14:22.408Z - debug: Executing recipe phantom-pdf requestId=36 2017-06-22T22:14:24.253Z - debug: Converting in dedicated phantomjs 1.9.8 timestamp=Thu Jun 22 2017 16:14:23 GMT-0600 (MDT), requestId=36 2017-06-22T22:14:24.254Z - debug: Request file:///%2Fvar%2Ffolders%2F9j%2F526ljypd2fn8gs759gc_qbyw0000gn%2FT%2Fjsreport-temp%2F24ea9b90-5798-11e7-9ee8-d7865700aac6html.html timestamp=Thu Jun 22 2017 16:14:24 GMT-0600 (MDT), requestId=36 2017-06-22T22:14:24.255Z - debug: phantom-pdf recipe finished with 1 pages generated requestId=36 2017-06-22T22:14:24.255Z - debug: Skipping storing report. requestId=36 2017-06-22T22:14:24.256Z - info: Rendering request 36 finished in 2062 ms requestId=36 2017-06-22T22:14:24.257Z - debug: Rendering engine handlebars requestId=35 2017-06-22T22:14:24.459Z - error: Error when processing render request Error during rendering report: Lexical error on line 8. Unrecognized text. ...r (��)/Producer (��Qt 4.8.4 \ ----------------------^ Error: Lexical error on line 8. Unrecognized text. ...r (��)/Producer (��Qt 4.8.4 \ ----------------------^ ...
Any ideas?
-
RE: Image rendering in content but not header
Thanks for all the quick communication btw. I'll take a look at that. I'm also looking at doing a more SOA approach where we use the jsreport server and call out from out own app, which has its own advantages.
-
RE: Image rendering in content but not header
I tried the full regular path (/Users/mikecullingham/Documents/dev/span/utilities/report-test/public/images/home.jpg) trying dataURI & link encoding types with the same result both times.
-
RE: Image rendering in content but not header
I think so. Using a basic node-express app, I've added the following endpoint.
I've tried:
- fileAsset equals the absolute path as listed below, as link or dataURI, and with the rootUrlForLinks present or missing
- fileAsset equals the '/images/home.jpg' with the rootUrlForLinks, and I can access that image via "http://localhost:3000/images/home.jpg"
I'm not sure if there's additional work I need to do to preload the assets. But in all cases I get Error during rendering report: Asset ~/Documents/dev/span/utilities/report-test/public/images/home.jpg not found.
I'm probably missing something obvious. I can get it to work in the standalone jsreport server, but not when using jsreport as a library.
router.get('/', function(req, res, next) { const fileAsset = '~/Documents/dev/span/utilities/report-test/public/images/home.jpg'; const invoiceTemplate = `<h1>BODY</h1><img src='{#asset ${fileAsset} @encoding=link}' style='display: none;'></img> <h1> Invoice </h1>`; jsreport.render({ template: { content: invoiceTemplate, engine: 'jsrender', recipe: 'phantom-pdf', phantom: { header: `<img src='{#asset ${fileAsset} @encoding=link}' width="135" height="25"/> <span>My Great Report</span>`, footer: '<span>{#pageNum}/{#numPages}</span>', }, assets: { publicAccessEnabled: true, searchOnDiskIfNotFoundInStore: true, rootUrlForLinks: "http://localhost:3000", } }, data: { }, }).then(function(out) { console.log('SUCCESS!'); out.stream.pipe(res); }).catch(function(e) { console.log('error '); console.log(e); res.end(e.message); }); });
-
RE: Image rendering in content but not header
Very strange. I can link to your image directly and the report renders fine, but if I download it and put it into public/images folder (a vanilla node-express test app), it doesn't render in the header.
Are there any end-to-end examples of using the asset option when I'm using jsreport as a library? When I use {#asset images/home.jpg @encoding=link} I'm seeing:
Error: Asset images/home.jpg not found at /Users/mikecullingham/Documents/dev/span/utilities/report-test/node_modules/jsreport-assets/lib/assets.js:148:15
-
RE: Image rendering in content but not header
Saw that. And I'm including it in the template content above with display: none, but it still wasn't working. Wondering if you had any insight about additional settings that might cause this.
-
Image rendering in content but not header
I'm currently trying out jsreport as a library within an existing application. I've read the advice in https://jsreport.net/learn/phantom-pdf, but I'm still having trouble rendering an image in the header. It renders fine in the body.
I'm planning to look at the base64 encoded method next to see if that will work for me, but in the mean time, any advice?
const jsreport = require('jsreport'); router.get('/jsreport', (req, res) => { const headerImageUrl = 'http://www.planwallpaper.com/static/images/abstract-colourful-cool-wallpapers-55ec7905a6a4f.jpg'; const invoiceTemplate = `<img src='${headerImageUrl}' style="display: none;"></img> <h1> Invoice </h1> <div><span>from: {{:from}}</span></div> <div><span>to: {{:to}}</span></div> <div><span>price: \${{:price}}</span></div> <div style='page-break-before: always;'></div> <h1>Hello from Page 2</h1>`; jsreport.render({ template: { content: invoiceTemplate, engine: 'jsrender', recipe: 'phantom-pdf', phantom: { header: `<img src='${headerImageUrl}' width="135" height="25"/> <span>My Great Report</span>`, footer: '<span>{#pageNum}/{#numPages}</span>', } }, data: { from: 'Bob Barker', to: 'Amy Adams', price: 41.99, }, }).then(function(out) { console.log('SUCCESS!'); out.stream.pipe(res); }).catch(function(e) { console.log('error '); console.log(e); res.end(e.message); }); });