Giter Club home page Giter Club logo

Comments (8)

pofider avatar pofider commented on July 20, 2024

Can you try to use dedicated-process strategy?
https://github.com/pofider/phantom-html-to-pdf#global-options

Also, please try to find the phantomjs executable in node_modules and run it. Does it start?

from phantom-html-to-pdf.

gerhardcit avatar gerhardcit commented on July 20, 2024

I also solved it by doing this
npm install phantomjs-prebuilt
and then

var conversion = require("phantom-html-to-pdf")({
        phantomPath: require("phantomjs-prebuilt").path, 
        timeout: 5000
    });

but if I deploy to Ubuntu will this still work?

from phantom-html-to-pdf.

pofider avatar pofider commented on July 20, 2024

It should.

from phantom-html-to-pdf.

gerhardcit avatar gerhardcit commented on July 20, 2024

@pofider
Running this on ubuntu 16.04
node 6.10.2

package.json contains

   "phantom-html-to-pdf": "^0.5.0",
   "phantomjs-prebuilt": "^2.1.14",

Init code

var conversion = require("phantom-html-to-pdf")({
    phantomPath: require("phantomjs-prebuilt").path
});

I'm using phantomPath because on mac that's the only way for it to work as mentioned above.

exec code

 conversion({
                html: htmlText,
                footer: '<div style="text-align:center">{#pageNum}/{#numPages}</div>',
                paperSize: {
                    format: 'A4',
                    orientation: 'portrait',
                    margin: '1cm'
                }
            }, function (err, pdf) {
                if (err) {
                   console.log(err)
                    cb(err);
                }
                else {
                    console.log(pdf.logs);
                    console.log(pdf.numberOfPages);
                    cb(null, pdf);
                }
            });

getting this error

 ERROR | UNCAUGHT | Sun Apr 23 2017 21:46:26 GMT+0000 (UTC) | TypeError: Bad argument
  at TypeError (native)
  at ChildProcess.spawn (internal/child_process.js:294:26)
  at ChildProcess.spawn (/usr/lib/node_modules/pm2/node_modules/async-listener/index.js:120:29)
  at exports.spawn (child_process.js:378:9)
  at Object.exports.execFile (child_process.js:143:15)
  at /home/ubuntu/apps/theapp-api/node_modules/phantom-workers/lib/phantomWorker.js:92:43
  at Server.<anonymous> (/home/ubuntu/apps/theapp-api/node_modules/phantom-workers/lib/phantomWorker.js:17:9)
   at emitNone (events.js:86:13)
  at Server.emit (events.js:185:7)
  at emitCloseNT (net.js:1558:8)

$ phantomjs -v
produces this:

Fontconfig warning: ignoring UTF-8: not a valid region tag
1.9.8

Anything you can possible help me with?

from phantom-html-to-pdf.

pofider avatar pofider commented on July 20, 2024

Try to run this

apt-get install -y libfontconfig1 libfontconfig1-dev

We use this dockerfile to run this package on ubuntu https://github.com/jsreportonline/phantom-pdf/blob/master/Dockerfile
Just that it could help you to look inside.

from phantom-html-to-pdf.

gerhardcit avatar gerhardcit commented on July 20, 2024

@pofider here is a basic test. That I cannot get running on a basic machine fresh after setup.
https://github.com/gerhardcit/phantom-html-to-pdf-test

Would one expect that to work on a fresh Ubuntu machine setup?
Is there something about phantomjs that I don't know about?

from phantom-html-to-pdf.

gerhardcit avatar gerhardcit commented on July 20, 2024

@pofider, I tested that on a clean Ubuntu server.. just node and nginx.. perfect..
But not on the dev mac..
So what is compatibility with prebuilt about?

This pops up on mac with same node version

ERROR | UNCAUGHT | Mon Apr 24 2017 22:12:36 GMT+0200 (SAST) | TypeError: Bad argument
    at TypeError (native)
    at ChildProcess.spawn (internal/child_process.js:289:26)
    at exports.spawn (child_process.js:380:9)
    at Object.exports.execFile (child_process.js:143:15)
    at /Users/gerhard/Documents/projects/dev/phantom-test/node_modules/phantom-workers/lib/phantomWorker.js:92:43
    at Server.<anonymous> (/Users/gerhard/Documents/projects/dev/phantom-test/node_modules/phantom-workers/lib/phantomWorker.js:17:9)
    at emitNone (events.js:86:13)
    at Server.emit (events.js:185:7)
    at emitCloseNT (net.js:1553:8)
    at _combinedTickCallback (internal/process/next_tick.js:71:11)

from phantom-html-to-pdf.

gerhardcit avatar gerhardcit commented on July 20, 2024

@pofider , signing this off.
I had experimented with html5-to-pdf which uses electron, and that did not go well.
So after all that, this is a config that works.

"dependencies": {
    "express": "^4.15.2",
    "phantom-html-to-pdf": "^0.5.0",
    "phantomjs-prebuilt": "^2.1.14"
  }

and

var conversion = require("phantom-html-to-pdf")({
    phantomPath: require("phantomjs-prebuilt").path
});

on Development Mac and on Ubuntu 16.04
Closing this ticket.

from phantom-html-to-pdf.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.