Git Product home page Git Product logo

Comments (27)

saten avatar saten commented on June 27, 2024 1

after some more reading, the problem might be related to the command actually not being executed, but I can't see the problem right now

(maybe ree related?)

edit: working without ree. so?

from pdfkit.

ctaintor avatar ctaintor commented on June 27, 2024

You probably need to make the config.wkhtmltopdf be an absolute path to the executable.

from pdfkit.

futureshocked avatar futureshocked commented on June 27, 2024

I tried with absolute path, restarted the server, but got the same error.

from pdfkit.

futureshocked avatar futureshocked commented on June 27, 2024

This solution worked so that PDFKit doesn't crash (http://stackoverflow.com/questions/3468234/rails-3-wkhtmltopdf-command-failed-when-using-pdfkit-to-create-pdf-documents):
PDFKit.configure do |config|
config.default_options[:ignore_load_errors] = true
end

But now, any PDF document I try to create comes out blank. What could be causing this?

from pdfkit.

jdpace avatar jdpace commented on June 27, 2024

Could you post the HTML that your using to generate the PDF? The wkhtmltopdf binary may not be able to download some resources mentioned in the HTML. This can be especially true in development where you only have one server running.

What happens is a request for a PDF comes in and wkhtmltopdf needs to download a file to generate the pdf, issues a request, but that request sits behind the original request which is trying to create the pdf.

from pdfkit.

saten avatar saten commented on June 27, 2024

Hi,
I've got the same issue here. Adding a trailing space in the path to the executable seems to help, so I would recommend to check for a missing space somewhere in pdfkit

config.wkhtmltopdf = '/usr/bin/wkhtmltopdf '

from pdfkit.

jcbpl avatar jcbpl commented on June 27, 2024

@jdpace, I'm having that problem; the binary is not able to download some resources and so the process just seems to hang. Is there any way to work around that in development?

Thanks,
Jake

from pdfkit.

nishandan avatar nishandan commented on June 27, 2024

hi,
i am having problem as follows,

"command failed: /usr/local/bin/wkhtmltopdf--margin-right0.75in--page-sizeA4--margin-top0.75in--margin-bottom0.75in--disable-smart-shrinking--encodingUTF-8--margin-left0.75in--quiet--"

how can i overcome this issue? Please suggest solution ASAP..

Thanks
Nishandan

from pdfkit.

 avatar commented on June 27, 2024

Hi, sorry for the late reply. I looked at the HTML in the page I'm trying to convert to PDF, and there's only the standard Rails Javascript files referenced, plus a CSS file. I also tried Saten's first recommendation (trailing space), with no luck.

Anything else I can try?

from pdfkit.

ctaintor avatar ctaintor commented on June 27, 2024

We had a weird instance where using 14px fonts caused wkhtmltopdf to crash on a linux box. You might be having a similar issue. Just try reducing the complexity of what you're rendering (maybe render it without the css) and see if that works. If it works without css, then put your css back in and start removing things in the css until it works. That's what we did -- and, strangely, changing the font size to 13px made all the difference. Go figure.

from pdfkit.

jdpace avatar jdpace commented on June 27, 2024

@nishandan - What happens when you run wkhtmltopdf directly? Note that command that was output was formatted badly. Try /usr/local/bin/wkhtmltopdf - test.pdf then type in some HTML and then hit ctrl+d.

from pdfkit.

nishandan avatar nishandan commented on June 27, 2024

when i execute the following command via terminal its working.

wkhtmltopdf www.google.com google.pdf

but when i access through the application using PDFKit gem it gives.

when i went through the source its raising from pdfkit.rb file in the following line
raise "command failed: #{command}" if result.to_s.strip.empty?. that means the result is empty(result = pdf.gets(nil)).

following error is displaying on web page
"command failed: /usr/local/bin/wkhtmltopdf--margin-right0.75in--page-sizeA4--margin-top0.75in--margin-bottom0.75in--disable-smart-shrinking--encodingUTF-8--margin-left0.75in--quiet--"

from pdfkit.

jdpace avatar jdpace commented on June 27, 2024

Is wkhtmltopdf installed at that location? What happens when you run /usr/local/bin/wkhtmltopdf www.google.com google.pdf

from pdfkit.

nishandan avatar nishandan commented on June 27, 2024

i did installation manually. that means i downloaded wkhtmltopdf and moved it to that location.

when i execute it generates pdf file.
/usr/local/bin/wkhtmltopdf www.google.com google.pdf

through the application, it worked properly on ubuntu 10.04 version. but not working on 9.10. is there any dependency libraries?

from pdfkit.

saten avatar saten commented on June 27, 2024

@nishandan: which ruby are you using?

from pdfkit.

 avatar commented on June 27, 2024

I have the same problem in Rails 2 but I get a little more info

It says the error is coming from Ghostscript

Error: /unknownerror in --fill--
Operand stack:
--dict:(7/16L)
Execution stack:
%interp_exit .runexec2 --nostringval-- --nostringval-- --nostringval-- 2 %stopped_push --nostringval-- --nostringval-- --nostringval-- false 1 %stopped_push 1878 1 3 %oparray_pop 1877 1 3 %oparray_pop 1755 1 3 %oparray_pop --nostringval-- %errorexec_pop .runexec --nostringval-- --nostringval-- --nostringval-- 2
%stopped_push GPL Ghostscript 8.71 Unrecoverable error exit code 1
--nostringval-- --nostringval-- --nostringval-- false 1 %stopped_push --nostringval-- --nostringval-- --nostringval-- %array_continue --nostringval-- false 1 %stopped_push --nostringval-- %loop_continue --nostringval--
Dictionary stack:
--dict:1159/1684(ro) (G)-- --dict:1/20(G)-- --dict:75/200(L)-- -dict:108/127(ro) (G)-- -dict:288/300(ro) (G)-- --dict:22/25(L)-- --dict:6/8(L)-- --dict:21/40(L)-- --dict:1/1(ro) (G)-- --dict:7/15(L)-- --dict:1/1(ro) (G)--
Current allocation mode is local
Last OS error 11
using ruby enterprise 1.8.7

from pdfkit.

jdpace avatar jdpace commented on June 27, 2024

X11 may not be installed on that box. Can you try installing the dependencies listed on this page? Let me know if that works. I'll try to update the Readme to be more helpful in this area.

from pdfkit.

nishandan avatar nishandan commented on June 27, 2024

i am using ruby version 1.8.7

i wanted to install following libraries,

fontconfig, build-essential, xorg, openssl, libssl-dev

some libraries will be installed on some ubuntu versions. unless we have to install those.

now it is working fine on ubuntu 10.04,9.10 and 8.04.

thanks for your comments.

from pdfkit.

JonniX avatar JonniX commented on June 27, 2024

hi, had some of the problems on rails 2.3.8 and 0.10.beta5 of wkhtmltopdf (which is installed automatically). i tried the options on console and found that the 0.10beta has changed quite a bit. so it accepts other options, and seems to depend on specific orders for toc and cover.
i've created a small fix for that in pdfkit, but on some cases i still get the error, that the command has failed, while the same commandstring on console works.

from pdfkit.

tibra avatar tibra commented on June 27, 2024

I am having the same problem in production and development with unicorn:

RuntimeError (command failed: /usr/local/bin/wkhtmltopdf --page-size Letter --margin-right 0.75in --margin-top 0.75in --ignore-load-errors --margin-bottom 0.75in --disable-smart-shrinking --encoding UTF-8 --margin-left 0.75in --quiet - -):

I am using haml for the templating language. Having no images and no stylesheets included seems to work fine.

WebBrick on the other hands works just fine with both images and stylesheets.

None of the above mentioned workarounds did help.
Do you need any additional log files for this, jdpace?

from pdfkit.

tibra avatar tibra commented on June 27, 2024

I have solved the unicorn issue by putting more than one worker in my development environment. In production, this is not an issue due to multiple workers running.

It seems to render my PDF's just fine now ;-)
Thanks jdpace for the great gem!

from pdfkit.

23inhouse avatar 23inhouse commented on June 27, 2024

I had a similar problem, the pdfkit --install-wkhtmltopdf command was installing the i386 version, i need the 64bit version which is the amd64 one.

Michael Schuerig answered this problem here: http://www.ruby-forum.com/topic/216962

from pdfkit.

demersus avatar demersus commented on June 27, 2024

I have had the same problem. I tracked it down to having a url (http://whatever) in text form on the page. It will work fine if the url is part of an href in an [a] tag. But not if it is just displayed as text. Weird.
In order to find the problem, I commented out each line one at a time and tried to generate the pdf. It would always give me this error, until I removed the line that had the url. This only happens when using PDFKit. Not when using the command line form of wkhtmltopdf.

from pdfkit.

dheza avatar dheza commented on June 27, 2024

Hello guys I need some help, i was using the pdfkit version 5.0.3 and wkhtmltopdf 0.9.0, now other project in teh same server, needed to update wkhtmltopdf to version 11, and now my code is not working anymore, I'm receveing the following message:

RuntimeError (command failed: "/usr/bin/wkhtmltopdf" "--page-size" "Letter" "--margin-top" "0.75in" "--margin-right" "0.75in" "--margin-bottom" "0.75in" "--margin-left" "0.75in" "--encoding" "UTF-8" "--quiet" "-" "-"):
app/controllers/incidents_controller.rb:63:in block (2 levels) in show' app/controllers/incidents_controller.rb:45:inshow'

Some on can help me.
Thanks Andreza

from pdfkit.

ginter avatar ginter commented on June 27, 2024

getting the same error only in production
RuntimeError (command failed: /usr/local/bin/wkhtmltopdf --page-size Letter --margin-top 0.75in --margin-right 0.75in --margin-bottom 0.75in --margin-left 0.75in --encoding UTF-8 --quiet - -):

running from the command line works fine.

from pdfkit.

sigmavirus24 avatar sigmavirus24 commented on June 27, 2024

@ginter how does running that from the command line work? Is the output correct?

from pdfkit.

AlainPilon avatar AlainPilon commented on June 27, 2024

I am getting the same error as @ginter in my staging/production env. In my case, I have tracked the issue to these meta config elements:

<meta name="pdfkit-margin-top" content="0mm"/>
<meta name="pdfkit-margin-bottom" content="0mm"/>
<meta name="pdfkit-margin-right" content="0mm"/>
<meta name="pdfkit-margin-left" content="0mm"/>

If I remove them everything is fine. pdfkit 0.5.4 and wkhtmltopdf 0.10.0.rc2

from pdfkit.

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.