Chuyển file HTML thành PDF hoặc Image với Linux

Cách 1.

yum install fontconfig libXrender libXext xorg-x11-fonts-Type1 xorg-x11-fonts-75dpi freetype libpng zlib libjpeg-turbo
wget https://downloads.wkhtmltopdf.org/0.12/0.12.5/wkhtmltox-0.12.5-1.centos7.x86_64.rpm
rpm -Uvh wkhtmltox-0.12.5-1.centos7.x86_64.rpm

Cách 2

Cài đặt evince

yum install evince

Cài đặt wkhtmltopdf

wget https://github.com/wkhtmltopdf/wkhtmltopdf/releases/download/0.12.4/wkhtmltox-0.12.4_linux-generic-amd64.tar.xz

Giải nén

tar -xvf wkhtmltox-0.12.4_linux-generic-amd64.tar.xz

Copy tới /usr/bin/

cp wkhtmltox/bin/wkhtmltopdf /usr/bin/

cp wkhtmltox/bin/wkhtmltoimages /usr/bin/

Lệnh chuyển HTML thành PDF

wkhtmltopdf file.html file.pdf

Lệnh chuyển HTML thành IMAGE

wkhtmltoimages file.html file.jpeg

Nguồn: https://www.tecmint.com/wkhtmltopdf-convert-website-html-page-to-pdf-linux/

Leave a Reply

Your email address will not be published. Required fields are marked *