Comments (31)
Sorry, for the bug. The default timeout is currently 10 seconds, which is a bit low for some computers.
On what hardware are you working? Anyways, I'll change the default to 30s.
Also I should document the options a bit better (or make a better api of the module).
The markdown-pdf
module just uses the defaults, which writes a file in phantom to a tmp directory and reads that file back to a buffer in node.
It's faster to pass { width: "210mm", height: "297mm", border: "10mm", filename: /path}
as option which will save the file directly at the desired destination.
So can you try to use.
pdf.create(inputHtml, {file: outputPath, width: '210mm', height: '297mm', border: '10mm', timeout: 30000}, function(err, buffer) {
if (err) return console.log(err);
console.log("Converted successfully. Output in " + outputPath);
});
from node-html-pdf.
I'm still getting the timeout. Both at 30 and 90 seconds.
I'm working on a:
HP Z420 Workstation
Intel(R) Xeon(R) CPU E5-1620 v2 @3.70Ghz 64-Bit
20 GB Ram
Can't imagine the machine is the problem. ;)
from node-html-pdf.
Still timing out at 10 minutes. I can't imagine the converting a single line of html is gonna take that much time.
from node-html-pdf.
Hehe, absolutely not.
I use phantoms' system.stdin method to pass the html from the node process.
Apparently that's the problem on windows.
Because phantomjs itself is synchronous there's no other event and the script fails with a timeout.
As an alternative I can write the html to file and read that file in phantomjs.
Or pass the html differently to phantomjs. But I'll have to elaborate that.
So there's no windows support for now :(
I'm sorry
from node-html-pdf.
Alright. Thanks for looking into it!
from node-html-pdf.
Hmm. It should work: https://groups.google.com/d/msg/phantomjs/GbndcSYaBWc/AznZfhT03zYJ
I have to investigate into this. But sadly I don't have a windows system.
from node-html-pdf.
How can I execute the pdf_as_a4_portrait.coffee?
Doing it with Phantomjs.exe gets me a SyntaxError: Parse error
.
from node-html-pdf.
Okay that was case of PBKAC. Using Phantomjs.exe I can produce a pdf with pdf_as_a4_portrait.coffee.
So the problem is somewhere between node and phantom.js.
from node-html-pdf.
Sorry for the late reply.
To create a pdf the command on unix is:
echo '<html></html>' | phantomjs pdf_as_a4_portrait.coffee HTMLBUFFERSIZE '{"width":"210mm", "height": "297mm"}'
from node-html-pdf.
@mpkorstanje I've updated some parts of the script. I'm passing the html differently to the process. So it's possible that it works now on windows.
Can you check out the windows-support
branch?
edit:
I guess you still have to pass the destination file name directly as option. Otherwise a wrong tmp path is generated which is not working on windows.
from node-html-pdf.
I'll try and have a look at that tonight.
from node-html-pdf.
Okay. Running pdf_as_a4_portrait.coffee
creates an empty pdf. But that might be because I can't figure out pipes on windows.
How do I package this and install it in node?
from node-html-pdf.
Try to execute the tests. Are those working in the windows-support
branch?
Just run npm test
from node-html-pdf.
They time out sadly.
> [email protected] test C:\Users\mpkorstanje\workspace\node-html-pdf
> grunt test
Running "mochaTest:test" (mochaTest) task
html-pdf
#create()
V throws error when passing null (1ms)
V throws error when passing undefined
V throws error when passing empty string (1ms)
1) does not throw an error when succeeding
2) returns a buffer
3) returns a pdf buffer
4) works with a custom page size and footer
5) works with custom html and css
3 passing (6s)
5 failing
1) html-pdf #create() does not throw an error when succeeding:
Error: timeout of 2000ms exceeded
at [object Object].<anonymous> (C:\Users\mpkorstanje\workspace\node-html-pdf\node_modules\mocha\lib\runnable.js:158:19)
at Timer.listOnTimeout [as ontimeout] (timers.js:112:15)
2) html-pdf #create() returns a buffer:
Should be a buffer
+ expected - actual
+true
-false
at Context.<anonymous> (C:\Users\mpkorstanje\workspace\node-html-pdf\test\create.coffee:48:28)
at callFn (C:\Users\mpkorstanje\workspace\node-html-pdf\node_modules\mocha\lib\runnable.js:250:21)
at Test.Runnable.run (C:\Users\mpkorstanje\workspace\node-html-pdf\node_modules\mocha\lib\runnable.js:243:7)
at Runner.runTest (C:\Users\mpkorstanje\workspace\node-html-pdf\node_modules\mocha\lib\runner.js:373:10)
at C:\Users\mpkorstanje\workspace\node-html-pdf\node_modules\mocha\lib\runner.js:451:12
at next (C:\Users\mpkorstanje\workspace\node-html-pdf\node_modules\mocha\lib\runner.js:298:14)
at C:\Users\mpkorstanje\workspace\node-html-pdf\node_modules\mocha\lib\runner.js:308:7
at next (C:\Users\mpkorstanje\workspace\node-html-pdf\node_modules\mocha\lib\runner.js:246:23)
at Object._onImmediate (C:\Users\mpkorstanje\workspace\node-html-pdf\node_modules\mocha\lib\runner.js:275:5)
at processImmediate [as _immediateCallback] (timers.js:345:15)
3) html-pdf #create() returns a pdf buffer:
TypeError: Cannot call method 'toString' of undefined
at Context.<anonymous> (C:\Users\mpkorstanje\workspace\node-html-pdf\test\create.coffee:52:32)
at callFn (C:\Users\mpkorstanje\workspace\node-html-pdf\node_modules\mocha\lib\runnable.js:250:21)
at Test.Runnable.run (C:\Users\mpkorstanje\workspace\node-html-pdf\node_modules\mocha\lib\runnable.js:243:7)
at Runner.runTest (C:\Users\mpkorstanje\workspace\node-html-pdf\node_modules\mocha\lib\runner.js:373:10)
at C:\Users\mpkorstanje\workspace\node-html-pdf\node_modules\mocha\lib\runner.js:451:12
at next (C:\Users\mpkorstanje\workspace\node-html-pdf\node_modules\mocha\lib\runner.js:298:14)
at C:\Users\mpkorstanje\workspace\node-html-pdf\node_modules\mocha\lib\runner.js:308:7
at next (C:\Users\mpkorstanje\workspace\node-html-pdf\node_modules\mocha\lib\runner.js:246:23)
at Object._onImmediate (C:\Users\mpkorstanje\workspace\node-html-pdf\node_modules\mocha\lib\runner.js:275:5)
at processImmediate [as _immediateCallback] (timers.js:345:15)
4) html-pdf #create() works with a custom page size and footer:
Error: timeout of 2000ms exceeded
at [object Object].<anonymous> (C:\Users\mpkorstanje\workspace\node-html-pdf\node_modules\mocha\lib\runnable.js:158:19)
at Timer.listOnTimeout [as ontimeout] (timers.js:112:15)
5) html-pdf #create() works with custom html and css:
Error: timeout of 2000ms exceeded
at [object Object].<anonymous> (C:\Users\mpkorstanje\workspace\node-html-pdf\node_modules\mocha\lib\runnable.js:158:19)
at Timer.listOnTimeout [as ontimeout] (timers.js:112:15)
Warning: Task "mochaTest:test" failed. Use --force to continue.
Aborted due to warnings.
npm ERR! Test failed. See above for more details.
npm ERR! not ok code 0
from node-html-pdf.
I believe you're doing the tests on the master branch.
I've increased the test timeout to 10 seconds on windows-support
So please execute that:
git checkout windows-support
npm install
npm test
Anyways. Thanks for your patience.
from node-html-pdf.
You were correct. Checked out the wrong branch.
Test passed. I've got pdfs for the test files. It works now. Cheers!
html-pdf
#create()
V throws error when passing null (1ms)
V throws error when passing undefined
V throws error when passing empty string
V does not throw an error when succeeding (679ms)
V buffer must be returned when no filename specified (641ms)
V returns a pdf buffer (613ms)
V saves the pdf to a destination (648ms)
V works with a custom page size and footer (720ms)
V works with custom html and css (749ms)
from node-html-pdf.
Nice. So I'll merge this & it will land in the markdown-pdf module after they incorporate it.
from node-html-pdf.
Awesome! Will you poke the issue at markdown-pdf when you merge your fixes?
from node-html-pdf.
cc: @harshbhatt @marcbachmann
This issue is rearing its head again. Do you have any idea what could be going on?
markdown-pdf
is requiring 0.3.0
; I believe this is the correct version.
Let me know if there's anything I can help with!
from node-html-pdf.
Is this still an issue? Please try to run those phantomjs tests: https://github.com/Medium/phantomjs
I currently can't test the script on windows. If the problem still exists, please create a new issue.
from node-html-pdf.
The scripts here? Can you help me out in doing so - still new to using npm and nodejs - would apprecaite it.
from node-html-pdf.
@harshbhatt here you go
git clone [email protected]:Medium/phantomjs.git
cd phantomjs
NODE_ENV=development npm install
npm test
from node-html-pdf.
Thanks @marcbachmann, appreciate it.
After cloning the repo, I ran set NODE_ENV=development
and ran npm test
after that. Here is what I got:
from node-html-pdf.
Apparently npm doesn't set the PATH variable on windows. So it can't execute nodeunit
.
Is there a ./node_modules/.bin/nodeunit
file?
Try to run that using .\node_modules\.bin\nodeunit test\tests.js
from node-html-pdf.
Does anybody know a CI platform that supports Windows? 😄
edit: oh, there is one: http://www.appveyor.com/pricing
from node-html-pdf.
@harshbhatt did you execute npm install?
from node-html-pdf.
@marcbachmann I did, but nothing happened.
I did set nodejs as a PATH variable so after some digging, ran npm install nodeunit -g
and tried npm test
again, then had to run npm install which
after which I finally got:
Sorry about the noob-ness here - not familiar with nodejs as you can probably tell 😄
from node-html-pdf.
You still need to execute npm install
. During npm install
, it downloads phantomjs which is needed for the tests. That's why it fails.
from node-html-pdf.
I just tested the module on Windows 8.1. There are no dependencies like on linux.
from node-html-pdf.
I'm not sure I follow. As far as I understood, I had npm installed and I installed phantomjs using npm install phantomjs
found here.
from node-html-pdf.
I'm sporadically receiving this error, which appears related to this thread:
[Error: html-pdf: PDF generation timeout. Phantom.js script did not exit.]
It worked just fine yesterday, not working today with no change in that part of my code. I'm on version 1.5.0
var html = ejs.renderFile(appRoot + '/path/to/file', {
var: var
}, function (err, result) {
if (result) {
html = result
console.log(html)
var options = {format: 'Letter'}
var filename = bcrypt.hashSync(jobInfo[0].customer)
pdf.create(html, options).toFile(appRoot + '/public/uploads/invoices/WO-' + opID + "-" + filename + '.pdf', function(err, res){
do some other stuff
}
from node-html-pdf.
Related Issues (20)
- Background color not applying those area where no html
- Image not showing when uploaded on vps server
- QR code not visible over generated pdf post ami upgrade HOT 2
- Fonts don't work properly on server HOT 4
- stream (.toStream) not generated after deploying to k8s HOT 2
- The download pdf always have an empty page at last HOT 1
- html-pdf: Unknown Error throw new ERR_INVALID_ARG_TYPE(name, 'string', value); Docker HOT 1
- Pdf saved in TMP directory HOT 1
- Is watermark possible in pdf? HOT 3
- Not able to resize the chebox size while generating the pdf
- Syntax for forcing a page break HOT 2
- Potential injection vulnerability in node-html-pdf
- Page overflow with white line
- PDF Creation Error: spawn /root/pando-app/node_modules/phantomjs-prebuilt/lib/phantom/bin/phantomjs ENOENT HOT 1
- The answer to how to resolve Windows error of phantomjs ENOENT issue
- Error: spawn E2BIG
- error HOT 2
- Error: spawn C:\home\site\wwwroot\node_modules\phantomjs-prebuilt\lib\phantom\bin\phantomjs ENOENTat
- This package has been deprecated HOT 1
- Some Images from urls are not rendered HOT 1
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 node-html-pdf.