Comments (8)
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.
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.
It should.
from phantom-html-to-pdf.
@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.
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.
@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.
@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.
@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)
- Blurred, overlapping text when generating a PDF HOT 1
- PDF image not shown and format issue HOT 1
- Module not found: Can't resolve 'cluster' in... HOT 1
- Table Header HOT 1
- "file" argument must be a non-empty string HOT 3
- is this repo dead HOT 1
- phantomjs in electron
- occasionally I get "phantom manager could not start all workers" error HOT 4
- error occurs in electron (workerErrors) HOT 1
- Local Language Support
- fix footer
- Background color with gradient isn't working when generating via Mobile
- No support for phantom debug option
- No support for specifying TLS version
- Error: spawn EACCES HOT 5
- Cant render chinese character HOT 2
- How to do the page break in the pdf? HOT 1
- This library doesn't seem to support OnResourceRequested HOT 1
- Custom Headers is not working
- Update lodash version
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from phantom-html-to-pdf.