Problems with phantomjs and webshot on Live Server

I recently added functionality to create pdfs from dynamic data using this great tutorial from @ryanswapp. It worked great on my development server, but once I pushed it to my live site, I started getting the following errors:

[server.ip] { [Error: ENOENT, open ‘file.pdf’] errno: 34, code: ‘ENOENT’, path: ‘file.pdf’ }[server.ip]

and

[server.ip] /app/programs/server/npm/npm-container/node_modules/webshot/node_modules/phantomjs/lib/phantom/bin/phantomjs: 4: /app/programs/server/npm/npm-container/node_modules/webshot/node_modules/phantomjs/lib/phantom/bin/phantomjs: [server.ip] Syntax error: Unterminated quoted string[server.ip]

I’m using a Digital Ocean server running Ubuntu, using mup to deploy. I’m no unix expert, but I think this is an issue with file system permissions on my server. Does anyone have any suggestions as to how I might be able to diagnose? Many thanks

Hey @bsbechtel, I had the same problem with one of my packages - the problem is in a wrong PhantomJS binary.

Also, I’m not familiar with the mentioned tutorial (and packages it uses) but you can try with letting mup to install PhantomJS for you:

...
// Install PhantomJS on the server
  "setupPhantom": true,
...

Hey @miro, thanks for sharing. I use mup as well, and found out it was an issue with the path to phantomjs in my webshot call. I wasn’t using any phantomPath (per the webshot docs), which then defaults to an npm installation. Instead, I set the phantomPath option to where mup installs phantomjs, and it worked:

"phantomPath": "/usr/bin/phantomjs"

Hopefully that’s helpful for others going forward!

I have a question about phantomPath, its using the path inside the host or inside docker image? @bsbechtel

This was relative to the docker image (or Galaxy server in my case now). For Galaxy, I believe I also had to add these settings:

    phantomConfig: {
      "ignore-ssl-errors": "true",
      "ssl-protocol": "any"
    },

Hopefully that helps!

can you share your complete config? i am facing an error since 2 weeks ago @bsbechtel

These are my webshot options:

      var options = {
        // "phantomPath": "/usr/bin/phantomjs",
        "paperSize": {
          "format": "Letter",
          "orientation": "portrait",
          "margin": "0",
          "header": {
            "height": "250px",
            "contents": ""
          },
          "footer": {
            "height": "260px",
            "contents": ""
          }
        },
        siteType: 'html',
        phantomConfig: {
          "ignore-ssl-errors": "true",
          "ssl-protocol": "any"
        },
      };

It’s worth noting here that my phantomPath is commented out. I believe that’s for my development machine, but I could have it mixed up. It’s been a while since I’ve working on this project. Maybe try removing your phantomPath and see if it works. Good luck!