0
I am unable to install jsPDF in my nodejs with npm. I have npm install node-jspdf
to work with nodejs, but does not install because it gives problem when running the file install.sh
. Even specifying the version of the package gives problem. So I downloaded the zip from Node-jspdf (indicated in the file install.sh
), unzipped and created the necessary folders, indicated in the same installation file. When running the app the module is not located. However I was able to generate a PDF referencing the module directly, but I don’t know if it works for later:
HOW THE APP WORKED IN PRINCIPLE:
var fs = require('fs');
var path = './jsPDF/';
jsPDF = require(path + 'jspdf');
var doc = new jsPDF();
doc.text('Hello world!', 10, 10);
fs.writeFile('teste.pdf', doc.output());
The PDF is created correctly in the local folder. But I intend to have it sent to the browser. But if I use the example of Githud, as shown below, the error "Navigator is not defined":
SO THE APP GAVE ERROR
var fs = require('fs');
var path = './jsPDF/';
jsPDF = require(path + 'jspdf');
var doc = new jsPDF();
doc.text('Hello world!', 10, 10);
doc.save('Test.pdf', function(err){console.log('saved!');}); // <<<<<<==== Gera o erro
Questions: 1) Can I use jspdf indicating the module path directly and saving the file the way it worked? 2) Wouldn’t this "Navigator is not defined" error be because I’m just running a script? I guess running via browser will stop the problem...
you have the most updated version of Node? seems not. type
node -v
and say what the version is– guijob
Npm: '4.4.4', Ode: '6.10.2'
– wBB
tried to install the
node-jspdf
?navigator
is a browser variable– guijob
yes, I did as you indicated
npm install node-jspdf --save
. There is error in the fileinstall.sh
, but I opened it and I did what I needed. So I created the file with the default "hello word" code, as indicated on the Node-jspdf page, but it gives this error. Then I executed the code as indicated above (what worked), with this exception of having to indicate the relative path, being then the two doubts pending...– wBB