I get Error Phantom-pdf recipe was not found and then another error when using jsreport node module

1.7k views Asked by At

When I run this I get an error

GET /pdfreport - - ms - -
WARRNING! '$data.ObjectID' not supported as computed Key!
WARRNING! '$data.ObjectID' not supported as computed Key!
WARRNING! '$data.ObjectID' not supported as computed Key!
WARRNING! '$data.ObjectID' not supported as computed Key!
WARRNING! '$data.ObjectID' not supported as computed Key!
Recipe phantom-pdf was not found.
GET /pdfreport - - ms - -
{ [Error: ENOENT, unlink '/var/folders/r0/l6_3z9g55x95s7dp34yt3scw0000gn/T/xcrun_db']
  errno: 34,
  code: 'ENOENT',
  path: '/var/folders/r0/l6_3z9g55x95s7dp34yt3scw0000gn/T/xcrun_db' }

I have my node express route setup like this:

app.route('/pdfreport')
    .get(function (req, res) {

        var jsreport = require('jsreport');
        jsreport.bootstrapper(jsreport.renderDefaults).start().then(function(conf) {
                conf.reporter.render({
                    template: {
                        content: "<h1>Hello world</h1>",
                        phantom: {
                            header: "<p>some header</p>",
                            orientation: "portrait",
                            width: "300px"
                        }
                    }
                }).then(function(out) {
                    out.result.pipe(res);
                }).fail(function(e) {
                    console.log(e);
                });
        });
    });

I am not sure how to resolve this error. I have looked online for the Recipe phantom-pdf was not found.

1

There are 1 answers

0
Jan Blaha On BEST ANSWER

This is fixed in the latest 0.2.3 version, just do npm install jsreport and it should work.

Some hints:

You should turn on logger to investigate these issues:

jsreport.renderDefaults.logger.providerName = "console";

You should not bootstrap jsreport for every request if there is no reason for it. You can maybe consider using a render shortcut which cache single instance for you:

app.route('/pdfreport')
    .get(function (req, res) {
        require('jsreport').render({
                    template: {
                        content: "<h1>Hello world</h1>",
                        phantom: {
                            header: "<p>some header</p>",
                            orientation: "portrait",
                            width: "300px"
                        }
                    }
                }).then(function(out) {
                    out.result.pipe(res);
                }).fail(function(e) {
                    console.log(e);
                });
  });

Documentation is here