HTML to PDF tool Wkhtmltopdf installation and use

Water spinach

Need to finish reading

5

minute

Speed ​​reading only takes 2 minutes

Here is a recommended tool for converting HTML to PDF, Wkhtmltopdf, which is installed and used as follows.

1

   

Install under Centos7

system message:

system: Centos7.6     CPU architecture: X86     system structure: 64 bit

In version0.12.4Officially, there is a general-purpose x86 compiled installation package, which can be used after decompression, but the new version is not built, but it does not matter. There is an RPM package under Centos7.

Download the installation package:

$ wget https://github.com/wkhtmltopdf/wkhtmltopdf/releases/download/0.12.5/wkhtmltox-0.12.5-1.centos7.x86_64.rpm

Package dependency installation:

$ yum -y install fontconfig libX11 libXext libXrender xorg-x11-fonts-75dpi xorg-x11-fonts-Type1

installation:

$ rpm -ivh wkhtmltox-0.12.5-1.centos7.x86_64.rpm 
In preparation...##############################[100%]
 Installation...wkhtmltox-1:0.12.5-1.centos7 ############################## [100 %]

It can be used by default:

$ /usr/local/bin/wkhtmltopdf -V
wkhtmltopdf 0.12.5 (with patched qt)

If the generated characters are all squares, then you need to installstandard PostScript fonts:

$ yum -y install urw-fonts openssl-devel

Tips: If Chinese is not displayed, you need to copy the fonts under windows, such as simsun.ttc, msyh.ttf or msyhbd.ttf to the Linux system/usr/share/fontsUnder contents.

2

   

Compile and install under UOS20 under Arm architecture

system message:

system: Uos20     CPU architecture: ARM     system structure: 64 bit

Download source code:

$ wget https://github.com/wkhtmltopdf/wkhtmltopdf/archive/0.12.5.tar.gz

Installation dependencies:

$ apt-get install qt5-default qtcreator  libqtwebkit-dev libqt5webkit5-dev qt5-qmake  libqt5svg5* libqt5xml5 libqt5xmlpatterns5 libqt5xmlpatterns5-dev -y

$ ln -s /usr/lib/aarch64-linux-gnu/qt5/bin/qmake /usr/bin/qmake

Compile:

tar zxf wkhtmltopdf-0.12.5.tar.gz
cd wkhtmltopdf-0.12.5
mkdir /data/app/wkhtmltopdf

qmake PREFIX=/data/app/wkhtmltopdf
make
make install


3

   

Use test

$ /data/app/wkhtmltopdf/bin/wkhtmltopdf https://www.baidu.com ./baidu.pdf
Loading page (1/2)
QNetworkReplyHttpImplPrivate::_q_startOperation was called more than once QUrl("https://www.baidu.com/")
Printing pages (2/2)
Done
                                                        
$ /data/app/wkhtmltopdf/bin/wkhtmltoimage https://www.baidu.com ./baidu.png
Loading page (1/2)
QNetworkReplyHttpImplPrivate::_q_startOperation was called more than once QUrl("https://www.baidu.com/")
Rendering (2/2)
Done

result:

Recommended reading

stamp"Read the original"Let's charge together!

Intelligent Recommendation

Use of HTML export PDF wkhtmltopdf snappy

Download and installwkhtmltoxpdf Choose your own system version to download and install Prompt to install other dependencies installation: wkhtmltoxpdf's support for Chinese is not good enough, so you...

Use wkhtmltopdf python html to transfer PDF

Use wkhtmltopdf python html to transfer PDF Article catalog Use wkhtmltopdf python html to transfer PDF Foreword First, the environment Second, installation and configuration 1. First install pdfkit0....

C # Use wkhtmltopdf to convert HTML pages into PDF

There are many ways to turn the HTML page to PDF. Here is a use of WKHTMLTOPDF using the program to transform, personally test, but also First you need to download the WKHTMLTOPDF download address: In...

HTML is converted into a PDF tool -Wkhtmltopdf, Python generates PDF (PDFKIT library)

Article catalog First, HTML is converted into PDF tools - Wkhtmltopdf 1. What is wkhtmltopdf 2. How to use it? 3. Frequently Asked Questions error while loading shared libraries: libjpeg.so.62: cannot...

Linux operating system, use wkhtmltopdf tool to generate pdf files from html web pages

Recently, I encountered a requirement in my work. I needed to turn the table drawn on the front end into a pdf file. I tried many methods and PHP extensions, but I was not very satisfied. Finally I fo...

More Recommendation

html learning-convert html web pages into pdf format tool wkhtmltopdf

1. Software download URL click to download TIPS: Choose stable version, choose 32-bit or 64-bit according to your computer system 2. Installation You can manually select the installation path. After t...

Wkhtmltopdf export html to pdf

1, use the background Recently, the company needs to generate pdf and download the contents of the html page. I tried many methods and did not have satisfactory results. Later, I found the software wk...

Go-wkhtmltopdf to html as pdf

Go-wkhtmltopdf to html as pdf: go get -u github.com/SebastiaanKlippert/go-wkhtmltopdf vi /etc/profile export GOPATH=/usr/lib/go/bin :wq source /etc/profile vi a1.go package main import ( "fmt&quo...

html to pdf error wkhtmltopdf

Personal environment configuration Problem description When converting multiple html files into pdf, prompt: This version of wkhtmltopdf is build against an unpatched version of QT I found the followi...

Convert Html to PDF [wkhtmltopdf]

Today I am going to write a resume, and then happily entered a "free" online resume writing website, and started creating resumes. write. . . save. . . download. . . [Please activate members...

Copyright  DMCA © 2018-2026 - All Rights Reserved - www.programmersought.com  User Notice

Top