How to install wkhtmltopdf on a linux based (shared hosting) web server

后端 未结 11 1705
刺人心
刺人心 2020-11-30 17:58

I have tried in all ways to get wkhtmltopdf installed on our web server but unfortunately it is not getting installed. I cannot access user/bin folder as st

相关标签:
11条回答
  • 2020-11-30 18:59

    Shared hosting no ssh or shell access?

    Here is how i did it;

    1. Visit https://wkhtmltopdf.org/downloads.html and download the appropriate stable release for Linux. For my case I chose 32-bit which is wkhtmltox-0.12.4_linux-generic-i386.tar.xz
    2. Unzip to a folder on your local drive.
    3. Upload the folder to public_html (or whichever location fits your need) using an FTP program just like any other file(s)
    4. Change the binary paths in snappy.php file to point the appropriate files in the folder you just uploaded. Bingo! there you have it. You should be able to generate PDF files.
    0 讨论(0)
  • 2020-11-30 19:00

    Place the wkhtmltopdf executable on the server and chmod it +x.

    Create an executable shell script wrap.sh containing:

    #!/bin/sh
    export HOME="$PWD"
    export LD_LIBRARY_PATH="$PWD/lib/"
    exec $@ 2>/dev/null
    #exec $@ 2>&1 # debug mode
    

    Download needed shared objects for that architecture and place them an a folder named "lib":

    • lib/libfontconfig.so.1
    • lib/libfontconfig.so.1.3.0
    • lib/libfreetype.so.6
    • lib/libfreetype.so.6.3.18
    • lib/libX11.so.6 lib/libX11.so.6.2.0
    • lib/libXau.so.6 lib/libXau.so.6.0.0
    • lib/libxcb.so.1 lib/libxcb.so.1.0.0
    • lib/libxcb-xlib.so.0
    • lib/libxcb-xlib.so.0.0.0
    • lib/libXdmcp.so.6
    • lib/libXdmcp.so.6.0.0
    • lib/libXext.so.6 lib/libXext.so.6.4.0

    (some of them are symlinks)

    … and you're ready to go:

    ./wrap.sh ./wkhtmltopdf-amd64 --page-size A4 --disable-internal-links --disable-external-links "http://www.example.site/" out.pdf
    

    If you experience font problems like squares for all the characters, define TrueType fonts explicitly:

    @font-face {
      font-family:Trebuchet MS;
      font-style:normal;
      font-weight:normal;
      src:url("http://www.yourserver.tld/fonts/Trebuchet_MS.ttf");
      format(TrueType);
    }
    
    0 讨论(0)
  • 2020-11-30 19:01

    Version 12.5 of wkhtmltopdf only lists DEB files on their download page now. Being a mac user and not knowing much linux or what DEB files were I couldn't use the solutions posted.

    This page helped me get past the knew twist of downloading a DEB file: http://www.g-loaded.eu/2008/01/28/how-to-extract-rpm-or-deb-packages/

    Basically what I did was:

    1. Downloaded from https://wkhtmltopdf.org/downloads.html
    2. Unzipped the DEB file.
    3. Unzipped data.tar.xz
    4. Uploaded the binary in the unzipped 'usr' folder from step 3 (usr/local/bin/wkhtmltopdf)

    Then I found out that the 'exec' function was disabled on my host. So make sure you can specifically run 'exec' if you're using PHP to run this. "Can I run the wkhtmltopdf binary" isn't specific enough. My fault.

    0 讨论(0)
  • 2020-11-30 19:02

    If its ubuntu then go ahead with this, already tested.:--

    first, installing dependencies

    sudo aptitude install openssl build-essential xorg libssl-dev
    

    for 64bits OS

    wget http://wkhtmltopdf.googlecode.com/files/wkhtmltopdf-0.9.9-static-amd64.tar.bz2 
    tar xvjf wkhtmltopdf-0.9.9-static-amd64.tar.bz2
    mv wkhtmltopdf-amd64 /usr/local/bin/wkhtmltopdf
    chmod +x /usr/local/bin/wkhtmltopdf
    

    for 32bits OS

    wget http://wkhtmltopdf.googlecode.com/files/wkhtmltopdf-0.9.9-static-i386.tar.bz2 
    tar xvjf wkhtmltopdf-0.9.9-static-i386.tar.bz2
     mv wkhtmltopdf-i386 /usr/local/bin/wkhtmltopdf
    chmod +x /usr/local/bin/wkhtmltopdf
    
    0 讨论(0)
  • 2020-11-30 19:02

    List of stable versions wkhtmltopdf: http://wkhtmltopdf.org/downloads.html

    Installing wkhtmltopdf on Debian 8.2 (jessie) x64:

    sudo apt-get install xfonts-75dpi
    sudo apt-get install xfonts-base
    sudo wget http://download.gna.org/wkhtmltopdf/0.12/0.12.2.1/wkhtmltox-0.12.2.1_linux-jessie-amd64.deb
    sudo dpkg -i wkhtmltox-0.12.2.1_linux-jessie-amd64.deb
    
    0 讨论(0)
提交回复
热议问题