http://code.google.com/p/wkhtmltopdf/
Description
Simple shell utility to convert html to pdf using the webkit rendering engine, and qt.Introduction
Searching the web, I have found several command line tools that allow you to convert a HTML-document to a PDF-document, however they all seem to use their own, and rather incomplete rendering engine, resulting in poor quality. Recently QT 4.4 was released with a WebKit widget (WebKit is the engine of Apples Safari, which is a fork of the KDE KHtml), and making a good tool became very easy.
環境
CentOS 6.x x64
下載
wget http://wkhtmltopdf.googlecode.com/files/wkhtmltopdf-0.11.0_rc1-static-amd64.tar.bz2
解開就有一個檔案
wkhtmltopdf-amd64
說明
./wkhtmltopdf-amd64
執行
./wkhtmltopdf-amd64 http://ssorc.tw output.pdf
產出過程
Loading pages (1/6) ** (process:14365): DEBUG: NP_Initialize===========> ] 84% ** (process:14365): DEBUG: NP_Initialize succeeded ** (process:14365): DEBUG: NP_Initialize ** (process:14365): DEBUG: NP_Initialize succeeded ** (process:14365): DEBUG: NP_Initialize ** (process:14365): DEBUG: NP_Initialize succeeded ** (process:14365): DEBUG: NP_Initialize ** (process:14365): DEBUG: NP_Initialize succeeded QPixmap: Cannot create a QPixmap when no GUI is being used ] 89% Counting pages (2/6) Resolving links (4/6) Loading headers and footers (5/6) Printing pages (6/6) QPixmap: Cannot create a QPixmap when no GUI is being used ] Page 1 of 5 QPixmap: Cannot create a QPixmap when no GUI is being used QPixmap: Cannot create a QPixmap when no GUI is being used ] Page 3 of 5 QPixmap: Cannot create a QPixmap when no GUI is being used QPixmap: Cannot create a QPixmap when no GUI is being used QPixmap: Cannot create a QPixmap when no GUI is being used QPixmap: Cannot create a QPixmap when no GUI is being used QPixmap: Cannot create a QPixmap when no GUI is being used QPixmap: Cannot create a QPixmap when no GUI is being used ] Page 4 of 5 QPixmap: Cannot create a QPixmap when no GUI is being used QPixmap: Cannot create a QPixmap when no GUI is being used QPixmap: Cannot create a QPixmap when no GUI is being used QPixmap: Cannot create a QPixmap when no GUI is being used QPixmap: Cannot create a QPixmap when no GUI is being used QPixmap: Cannot create a QPixmap when no GUI is being used QPixmap: Cannot create a QPixmap when no GUI is being used QPixmap: Cannot create a QPixmap when no GUI is being used QPixmap: Cannot create a QPixmap when no GUI is being used QPixmap: Cannot create a QPixmap when no GUI is being used QPixmap: Cannot create a QPixmap when no GUI is being used QPixmap: Cannot create a QPixmap when no GUI is being used QPixmap: Cannot create a QPixmap when no GUI is being used QPixmap: Cannot create a QPixmap when no GUI is being used QPixmap: Cannot create a QPixmap when no GUI is being used QPixmap: Cannot create a QPixmap when no GUI is being used QPixmap: Cannot create a QPixmap when no GUI is being used QPixmap: Cannot create a QPixmap when no GUI is being used QPixmap: Cannot create a QPixmap when no GUI is being used QPixmap: Cannot create a QPixmap when no GUI is being used QPixmap: Cannot create a QPixmap when no GUI is being used QPixmap: Cannot create a QPixmap when no GUI is being used QPixmap: Cannot create a QPixmap when no GUI is being used QPixmap: Cannot create a QPixmap when no GUI is being used QPixmap: Cannot create a QPixmap when no GUI is being used QPixmap: Cannot create a QPixmap when no GUI is being used QPixmap: Cannot create a QPixmap when no GUI is being used QPixmap: Cannot create a QPixmap when no GUI is being used===] Page 5 of 5 QPixmap: Cannot create a QPixmap when no GUI is being used QPixmap: Cannot create a QPixmap when no GUI is being used QPixmap: Cannot create a QPixmap when no GUI is being used Done
雖說有一些疑似錯誤訊息,但pdf內容看起來無礙
圖片 (我的網站) (變成像在使用手機瀏覽的寬度)
圖片(tw.yahoo.com) (好像比較正常)
它可以帶一些參數
-g : 把內容呈現是灰的
toc : table of content
ref: http://www.cyberciti.biz/open-source/html-to-pdf-freeware-linux-osx-windows-software/
留言