Help with PDFKit and Rails App

2019-07-07 04:29发布

Working on Ubuntu 10.04 Lucid webserver (linode).

Followed these instructions to install wkhtmltopdf link (only one that worked for me.)

I can run wkhtmltopdf http://www.google.com google.pdf and it works.

Anything from my rails app generates a 500 error. apache error.log

/bin/wkhtmltopdf: symbol lookup error: /bin/wkhtmltopdf: undefined symbol: _ZN9QListData11detach_growEPii

rails log

Rendered customers/agreement_form.html.erb (15.0ms)
Completed 200 OK in 19ms (Views: 16.6ms | ActiveRecord: 0.6ms)

RuntimeError (command failed: /bin/wkhtmltopdf --encoding UTF-8 --page-size A4 --margin-top 0.5in --margin-right 0.75in --margin-bottom 0.5in --margin-left 0.75in --print-media-type --quiet - -):
  app/middleware/flash_session_cookie_middleware.rb:19:in `call'

EDIT

ldd /bin/wkhtmltopdf 
    linux-gate.so.1 =>  (0xf57fe000)
    libwkhtmltox.so.0 => /lib/libwkhtmltox.so.0 (0xb7718000)
    libQtWebKit.so.4 => /root/sources/wkqt/lib/libQtWebKit.so.4 (0xb64cd000)
    libQtSvg.so.4 => /root/sources/wkqt/lib/libQtSvg.so.4 (0xb6473000)
    libQtXmlPatterns.so.4 => /root/sources/wkqt/lib/libQtXmlPatterns.so.4 (0xb6047000)
    libQtGui.so.4 => /root/sources/wkqt/lib/libQtGui.so.4 (0xb5551000)
    libQtNetwork.so.4 => /root/sources/wkqt/lib/libQtNetwork.so.4 (0xb5423000)
    libQtCore.so.4 => /root/sources/wkqt/lib/libQtCore.so.4 (0xb517c000)
    libpthread.so.0 => /lib/tls/i686/cmov/libpthread.so.0 (0xb5163000)
    libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0xb506c000)
    libm.so.6 => /lib/tls/i686/cmov/libm.so.6 (0xb5046000)
    libgcc_s.so.1 => /lib/libgcc_s.so.1 (0xb5027000)
    libc.so.6 => /lib/tls/i686/cmov/libc.so.6 (0xb4ecd000)
    libXrender.so.1 => /usr/lib/libXrender.so.1 (0xb4ec3000)
    libfontconfig.so.1 => /usr/lib/libfontconfig.so.1 (0xb4e92000)
    libfreetype.so.6 => /usr/lib/libfreetype.so.6 (0xb4e1c000)
    libXext.so.6 => /usr/lib/libXext.so.6 (0xb4e0c000)
    libX11.so.6 => /usr/lib/libX11.so.6 (0xb4cef000)
    libz.so.1 => /lib/libz.so.1 (0xb4cda000)
    libgthread-2.0.so.0 => /usr/lib/libgthread-2.0.so.0 (0xb4cd3000)
    librt.so.1 => /lib/tls/i686/cmov/librt.so.1 (0xb4cca000)
    libglib-2.0.so.0 => /lib/libglib-2.0.so.0 (0xb4c00000)
    libpng12.so.0 => /lib/libpng12.so.0 (0xb4bdb000)
    libgobject-2.0.so.0 => /usr/lib/libgobject-2.0.so.0 (0xb4b9c000)
    libSM.so.6 => /usr/lib/libSM.so.6 (0xb4b92000)
    libICE.so.6 => /usr/lib/libICE.so.6 (0xb4b79000)
    libdl.so.2 => /lib/tls/i686/cmov/libdl.so.2 (0xb4b75000)
    /lib/ld-linux.so.2 (0xb7781000)
    libexpat.so.1 => /lib/libexpat.so.1 (0xb4b4e000)
    libxcb.so.1 => /usr/lib/libxcb.so.1 (0xb4b34000)
    libpcre.so.3 => /lib/libpcre.so.3 (0xb4b02000)
    libuuid.so.1 => /lib/libuuid.so.1 (0xb4afd000)
    libXau.so.6 => /usr/lib/libXau.so.6 (0xb4af9000)
    libXdmcp.so.6 => /usr/lib/libXdmcp.so.6 (0xb4af3000)

1条回答
姐就是有狂的资本
2楼-- · 2019-07-07 04:57

Typically, your RoR application is going to run as a different user than root: perhaps www-data, perhaps another system account.

Can that user read /root/sources/wkqt/lib/libQtSvg.so.4 and all the other libraries in that directory?

You might need to change the permissions on:

/root
/root/sources
/root/sources/wkqt
/root/sources/wkqt/lib

to allow everyone read and execute privileges. You can check permissions with ls -l; set permissions with chmod(1):

chmod 755 /root /root/sources /root/sources/wkqt /root/sources/wkqt/lib
chmod 644 /root/sources/wkqt/lib/*so*

In order to link at run time, the linker ld.so(8) needs to be able to read the libraries and all directories to get to the libraries.

查看更多
登录 后发表回答