html 转pdf 推荐

pylist 842 4

http://wkhtmltopdf.org/ 9 Convert HTML to PDF using Webkit (QtWebKit)

wkhtmltopdf http://google.com google.pdf

xhtml2pdf

https://pypi.python.org/pypi/xhtml2pdf/ 2

sudo apt-get install wkhtmltopdf

页眉页脚

CSS代码:style="page-break-before:always;” 控制打印是否分页  
--header-html 页眉  
--footer-html 页脚  
--header-spacing 页眉距内容距离  
--footer-spacing 页脚距内容距离  
wkhtmltopdf -T 15mm --header-spacing 5 --outline cover http://image.baidu.com --header-html a.html --header-line --footer-center "[page]/[topage]" --footer-line toc --toc-header-text "目录" http://www.baidu.com t2.pdf 
该主题到 2016-05-06 18:02:47 共 4 条回复
p
pylist #
/usr/local/bin/wkhtmltopdf -T 15mm --header-spacing 5 --header-html header.html --footer-right "[page]/[toPage]"  --outline cover cover.html http://wiki.baidu.cn/show/html/id/23 eoe-wiki-slug-23.pdf 
p
pylist #

参数

wkhtmltopdf --javascript-delay 1000 --page-size Letter --encoding utf-8 --print-media-type --disable-external-links --image-quality 100 --margin-left 5mm --margin-right 5mm --margin-top 5mm --margin-bottom 5mm
a
admin #

wkhtmltopdf: cannot connect to X server

1. Download wkhtmltopdf. http://code.google.com/p/wkhtmltopdf/downloads/list
2. Extract it and move it to /usr/bin/
3. Rename it to wkhtmltopdf so that now you have an executable at /usr/bin/wkhtmltopdf
4. Set permissions: sudo chmod a+x /usr/bin/wkhtmltopdf
4. Install required support packages. sudo apt-get install openssl build-essential xorg libssl-dev
5. Check to see if it works: run wkhtmltopdf http://www.google.com test.pdf. If it works, then you are done -- make sure to make a symbolic link as per INSTRUCTIONS.txt. If you get the error "Cannot connect to X server" then continue to number 6.
6. We need to run it headless on a 'virtual' x server. We will do this with a package called xvfb. sudo apt-get install xvfb
7. We need to write a little shell script to wrap wkhtmltopdf in xvfb. Make a file called wkhtmltopdf.sh and add the following:
xvfb-run -a -s "-screen 0 640x480x16" wkhtmltopdf $*
8. Move this shell script to /usr/bin, and set permissions: sudo chmod a+x /usr/bin/wkhtmltopdf.sh
9. Finally, make your symbolic link in /sites/all/modules/print/lib. Command is ln -s /usr/bin/wkhtmltopdf.sh wkhtmltopdf
a
admin #
xvfb-run wkhtmltoimage --format png --quality 100 --no-debug-javascript --height 800 http://facebook.com/ fb.png

登录发表评论

桂公网安备 45122402000014号