2017-12-01 3 views
0

Ich versuche, ein PDF mit Hilfe von Phamton-HTML-zu-PDF und EJS für Templating zu erstellen. Die Setup-Arbeit war in meinem lokalen Entwickler-Env, aber nicht in der Produktion. Das Problem ist, dass in meinem Server Prod die PDF erstellt wird, aber es ist leer.Phantom-Manager konnte nicht alle Arbeiter starten

const ejs = require('ejs'); 
 
const fs = require('fs'); 
 
const conversion = require("phantom-html-to-pdf")({ 
 
\t \t phantomPath: require("phantomjs-prebuilt").path 
 
}); 
 

 

 

 
function createPdf (data, template, directory) { 
 

 
\t var options = {}; 
 
\t var html = ejs.renderFile(__dirname + `/template/${template}.ejs`, {data: data}, options, function(err, str){ 
 
\t \t if(err){ 
 
\t \t \t return err 
 
\t \t } 
 
\t  return str 
 
\t }); 
 

 
\t var filepath = null 
 

 
\t conversion({ html: html, printDelay: 5000}, (err, pdf) => { 
 
\t \t var output = fs.createWriteStream(`documents/${directory}/${data.Référence}.pdf`) 
 
\t \t pdf.stream.pipe(output); 
 
\t }); 
 
} 
 

 
module.exports = createPdf;

{ Error: phantom manager could not start all workers.. 
at /home/website/group-auto.com/node_modules/phantom-workers/lib/phantomManager.js:66:47 
at /home/website/group-auto.com/node_modules/phantom-workers/lib/phantomWorker.js:115:24 
at /home/website/group-auto.com/node_modules/phantom-workers/lib/phantomWorker.js:140:20 
at Socket.<anonymous> (/home/website/group-auto.com/node_modules/phantom-workers/lib/checkPortStatus.js:45:9) 
at emitOne (events.js:96:13) 
at Socket.emit (events.js:188:7) 
at TCP._handle.close [as _onclose] (net.js:497:12) 


[ { Error: Command failed: /home/website/group-auto.com/node_modules/phantom-workers/node_modules/phantomjs/lib/phantom/bin/phantomjs --ignore-ssl-errors=yes --web-security=false --ssl-protocol=any /home/website/group-auto.com/node_modules/phantom-html-to-pdf/lib/scripts/serverScript.js 
/home/website/group-auto.com/node_modules/phantom-workers/node_modules/phantomjs/lib/phantom/bin/phantomjs: 1: /home/website/group-auto.com/node_modules/phantom-workers/node_modules/phantomjs/lib/phantom/bin/phantomjs: Syntax error: word unexpected (expecting ")") 

    at ChildProcess.exithandler (child_process.js:198:12) 
    at emitTwo (events.js:106:13) 
    at ChildProcess.emit (events.js:191:7) 
    at maybeClose (internal/child_process.js:920:16) 
    at Socket.<anonymous> (internal/child_process.js:351:11) 
    at emitOne (events.js:96:13) 
    at Socket.emit (events.js:188:7) 
    at Pipe._handle.close [as _onclose] (net.js:497:12) 
    killed: false, 
    code: 2, 
    signal: null, 
    cmd: '/home/website/group-auto.com/node_modules/phantom-workers/node_modules/phantomjs/lib/phantom/bin/phantomjs --ignore-ssl-errors=yes --web-security=false --ssl-protocol=any /home/website/group-auto.com/node_modules/phantom-html-to-pdf/lib/scripts/serverScript.js' }, 

Ich habe keine Ahnung, wo für Fehler suchen, helfen Sie bitte

Antwort

0

Sie haben in Ihrem Server 'libfontconfig' zu installieren.

  • macOS sierra Aktualisierung funktioniert nur mit phantomjs2.
  • Linux muss möglicherweise zusätzlich fontconfig-Paket installieren.

  • Centos - sudo yum install -y fontconfig

  • Debian/Ubuntu - sudo apt-get install -y libfontconfig

Verwandte Themen