{"id":1411,"date":"2021-02-26T02:01:23","date_gmt":"2021-02-26T02:01:23","guid":{"rendered":"https:\/\/www.ipcpu.com\/?p=1411"},"modified":"2021-04-26T02:01:55","modified_gmt":"2021-04-26T02:01:55","slug":"wkhtmltopdf","status":"publish","type":"post","link":"https:\/\/c.ipcpu.com\/2021\/02\/wkhtmltopdf\/","title":{"rendered":"wkhtmltopdf\u4e00\u6b3e\u80fd\u628aHTML\u9875\u9762\u4fdd\u5b58\u4e3aPDF\u7684\u8f6f\u4ef6"},"content":{"rendered":"

wkhtmltopdf\u4e00\u6b3e\u80fd\u628aHTML\u9875\u9762\u4fdd\u5b58\u4e3aPDF\u7684\u8f6f\u4ef6.md
\n<\/p>\n

\u4e00\u3001\u7b80\u4ecb<\/h2>\n

wkhtmltopdf \u548c wkhtmltoimage \u662f\u4e00\u4e2a\u4f7f\u7528 Qt WebKit \u5f15\u64ce\u505a\u6e32\u67d3\u7684\uff0c\u80fd\u591f\u628ahtml \u6587\u6863\u8f6c\u6362\u6210 pdf \u6587\u6863 \u6216 \u56fe\u7247(image) \u7684\u547d\u4ee4\u884c\u5de5\u5177\u3002\uff08\u5f3a\u8c03\u4e00\u4e0b\uff1a\u662f \u201c\u547d\u4ee4\u884c\u5de5\u5177\u201d \uff09<\/p>\n

\u652f\u6301\u591a\u4e2a\u5e73\u53f0\uff0c\u53ef\u5728win\uff0clinux\uff0cos x \u7b49\u7cfb\u7edf\u4e0b\u8fd0\u884c\u3002<\/p>\n

\u5b98\u65b9\u7f51\u7ad9\uff1ahttps:\/\/wkhtmltopdf.org\/<\/a>
\n\u5b98\u65b9github\uff1a
https:\/\/github.com\/wkhtmltopdf\/wkhtmltopdf<\/a><\/p>\n

\u4e8c\u3001\u5b89\u88c5<\/h2>\n

\u5b98\u65b9\u5728github\u4e0a\u76842018\u5e740.12.5\u7248\u672c\u4e2d\u63d0\u4f9b\u4e86RPM\u5305\u5b89\u88c5\u65b9\u5f0f\uff0c\u5b89\u88c5\u5b8c\u5c31\u53ef\u4ee5\u4f7f\u7528\u4e86<\/p>\n

\u4e09\u3001\u4f7f\u7528<\/h2>\n

\u4f7f\u7528\u4e5f\u5f88\u7b80\u5355\uff0c<\/p>\n

\u547d\u4ee4\u683c\u5f0f\uff1awkhtmltopdf [GLOBAL OPTION]... [OBJECT]... <\/output><\/p>\n

\n
wkhtmltopdf https:\/\/www.baidu.com  baidu.pdf<\/code><\/pre>\n<\/div>\n

\u7ed3\u679c\u5982\u4e0b
\n<\/p>\n

\u6ca1\u6709\u4e2d\u6587\uff0c\u5927\u90e8\u5206\u539f\u56e0\u662f\u6ca1\u6709\u5b57\u4f53\u652f\u6301\uff0c\u53ef\u4ee5\u5148\u5b89\u88c5\u4e0b\u5fae\u8f6f\u96c5\u9ed1\u8bd5\u8bd5\u3002<\/p>\n

\n
yum install wqy-microhei-fonts -y<\/code><\/pre>\n<\/div>\n


\n\u53ef\u4ee5\u4e86\u3002
\n\u5173\u4e8e\u5b57\u4f53\uff0c\u8fd9\u91cc\u591a\u63d2\u4e00\u5634\uff0cCentOS\u4e2d\u5b89\u88c5\u4e2d\u6587\u5b57\u4f53\u5305\u7684\u4e00\u822c\u65b9\u6cd5<\/p>\n

\n
yum install xorg-x11-font-utils fontconfig -y\n#\u62f7\u8d1d\u5b57\u4f53\u5305\u5230\/usr\/share\/fonts\u5e76\u6267\u884c\nmkfontscale && mkfontdir && fc-cache -fv<\/code><\/pre>\n<\/div>\n

\u9700\u8981\u5c0f\u8bed\u79cd\u5b57\u4f53\u7684\u53ef\u4ee5\u770b\u4e0bgoogle noto\u3002<\/p>\n

\u56db\u3001wkhtmltopdf\u7684\u7f3a\u70b9<\/h2>\n

\u5927\u5bb6\u90fd\u8bf4\u597d\u7684\u4e1c\u897f\u672a\u5fc5\u662f\u771f\u597d\uff0c\u63a5\u4e0b\u6765\u6211\u4eec\u5f00\u59cb\u8bf4\u7f3a\u70b9\u4e86<\/p>\n

4.1 \u751f\u6210\u7684pdf\u662f\u767d\u9875<\/h4>\n

VUE\u7b49\u6846\u67b6\u5f00\u59cb\u6d41\u884c\u540e\uff0cwkhtmltopdf\u7528\u5728vue\u9879\u76ee\u4e0a\u80af\u5b9a\u662f\u767d\u9875\u3002
\n\u5f15\u8d77\u7a7a\u767d\u9875\u7684\u4e3b\u8981\u539f\u56e0\u5c31\u662f\uff0c\u4f7f\u7528webpack\u6253\u5305\u7684\u9879\u76ee\uff0cindex.html\u9875\u9762\u5728\u67e5\u770b\u7684\u65f6\u5019\u662f\u4e0d\u663e\u793a\u5177\u4f53\u9875\u9762\u5185\u5bb9\u7684\uff0c\u5177\u4f53\u5185\u5bb9\u90fd\u5305\u542b\u5728\u4e00\u4e2ajs\u6587\u4ef6\u4e2d\uff0c\u53ea\u6709\u5728\u8bbf\u95ee\u5230\u5177\u4f53\u67d0\u4e2a\u9875\u9762\u8def\u7531\u7684\u65f6\u5019\u76f8\u5e94\u7684\u8d44\u6e90\u624d\u4f1a\u88ab\u8c03\u51fa\u6765\u3002\u4f46\u662fwkthtmltopdf\u53ea\u80fd\u89e3\u6790\u9759\u6001\u8d44\u6e90\uff0c\u4e0d\u4f1a\u53bb\u8fd0\u884cjs\u6587\u4ef6\u3002\u6240\u4ee5\u51fa\u6765\u7684\u662f\u767d\u9875\u3002\u540c\u6837\u7684\u5982\u679c\u9875\u9762\u4e2d\u7684\u5185\u5bb9\u5728\u9875\u9762\u5f00\u59cb\u6e32\u67d3\u65f6\u624d\u901a\u8fc7ajax\u8bf7\u6c42\u4ece\u540e\u53f0\u83b7\u53d6\uff0c\u4e5f\u662f\u65e0\u6cd5\u88abwkhtmltopdf\u83b7\u53d6\u3002<\/p>\n

\u8fd9\u91cc\u4ecb\u7ecd\u4e00\u4e2a\u5224\u65ad\u5f53\u524d\u9875\u9762\u80fd\u5426\u88abwkhtmltopdf\u6b63\u5e38\u5bfc\u51fa\u7684\u4e00\u4e2a\u65b9\u6cd5\uff1a<\/p>\n

\n

\u5c06\u5f53\u524d\u9875\u9762\u5728\u6d4f\u89c8\u5668\u4e2d\u53e6\u5b58\u4e3a\uff0c\u4fdd\u5b58\u5230\u672c\u5730\uff0c\u5982\u679c\u672c\u5730\u6587\u4ef6\u6253\u5f00\u540e\u662f\u6709\u5185\u5bb9\u7684\uff0c\u90a3\u4e48wkhtmltopdf\u5c31\u80fd\u6b63\u5e38\u5bfc\u51fa\u3002\u56e0\u4e3a\u8fd9\u4e2a\u5de5\u5177\u53ea\u4f1a\u89e3\u6790html\u4e0eCSS\uff0c\u5e76\u4e0d\u4f1a\u53bb\u8fd0\u884cjs\u6587\u4ef6\u3002<\/p>\n<\/blockquote>\n

\u90a3\u600e\u4e48\u89e3\u51b3\u5462\uff1f
\n\u53ef\u4ee5\u7528SSR\u670d\u52a1\u7aef\u6e32\u67d3\uff0c\u6216\u8005\u5728\u9875\u9762\u4e0a\u653e\u7f6e\u4e00\u4e2a\u6309\u94ae\uff0c\u5c06\u6e32\u67d3\u5b8c\u6bd5\u7684HTML\u4f20\u56de\u670d\u52a1\u5668\u7aef\u751f\u6210PDF\u3002<\/p>\n

\u53c2\u8003\u8d44\u6599<\/h2>\n

https:\/\/juejin.cn\/post\/6844903612993241101<\/a>
\n
https:\/\/www.jianshu.com\/p\/559c594678b6<\/a><\/p>\n

\u8f6c\u8f7d\u8bf7\u6ce8\u660e\uff1aIPCPU-\u7f51\u7edc\u4e4b\u8def<\/a> » wkhtmltopdf\u4e00\u6b3e\u80fd\u628aHTML\u9875\u9762\u4fdd\u5b58\u4e3aPDF\u7684\u8f6f\u4ef6<\/a><\/p>","protected":false},"excerpt":{"rendered":"

wkhtmltopdf\u4e00\u6b3e\u80fd\u628aHTML\u9875\u9762\u4fdd\u5b58\u4e3aPDF\u7684\u8f6f\u4ef6.md \u4e00\u3001\u7b80\u4ecb wkhtmltopdf \u548c wkhtmltoimage \u662f\u4e00\u4e2a\u4f7f\u7528 Qt WebKit \u5f15\u64ce\u505a\u6e32\u67d3\u7684\uff0c\u80fd\u591f\u628ahtml \u6587\u6863\u8f6c\u6362\u6210 pdf \u6587\u6863 \u6216 \u56fe\u7247(image) \u7684\u547d\u4ee4\u884c\u5de5\u5177\u3002\uff08\u5f3a\u8c03\u4e00\u4e0b\uff1a\u662f \u201c\u547d\u4ee4\u884c\u5de5\u5177\u201d \uff09 \u652f\u6301\u591a\u4e2a\u5e73\u53f0\uff0c\u53ef\u5728win\uff0clinux\uff0cos x \u7b49\u7cfb\u7edf\u4e0b\u8fd0\u884c\u3002 \u5b98\u65b9\u7f51\u7ad9\uff1ahttps:\/\/wkhtmltopdf.org\/ \u5b98\u65b9github\uff1ahttps:\/\/github.com\/wkhtmltopdf\/wkhtmltopdf \u4e8c\u3001\u5b89\u88c5 \u5b98\u65b9\u5728github\u4e0a\u76842018\u5e740.12.5\u7248\u672c\u4e2d\u63d0\u4f9b\u4e86RPM\u5305\u5b89\u88c5\u65b9\u5f0f\uff0c\u5b89\u88c5\u5b8c\u5c31\u53ef\u4ee5\u4f7f\u7528\u4e86 \u4e09\u3001\u4f7f\u7528 \u4f7f\u7528\u4e5f\u5f88\u7b80\u5355\uff0c \u547d\u4ee4\u683c\u5f0f\uff1awkhtmltopdf [GLOBAL OPTION]… [OBJECT]… wkhtmltopdf https:\/\/www.baidu.com baidu.pdf \u7ed3\u679c\u5982\u4e0b \u6ca1\u6709\u4e2d\u6587\uff0c\u5927\u90e8\u5206\u539f\u56e0\u662f\u6ca1\u6709\u5b57\u4f53\u652f\u6301\uff0c\u53ef\u4ee5\u5148\u5b89\u88c5\u4e0b\u5fae\u8f6f\u96c5\u9ed1\u8bd5\u8bd5\u3002 yum install wqy-microhei-fonts -y \u53ef\u4ee5\u4e86\u3002 \u5173\u4e8e\u5b57\u4f53\uff0c\u8fd9\u91cc\u591a\u63d2\u4e00\u5634\uff0cCentOS\u4e2d\u5b89\u88c5\u4e2d\u6587\u5b57\u4f53\u5305\u7684\u4e00\u822c\u65b9\u6cd5 yum install xorg-x11-font-utils fontconfig -y #\u62f7\u8d1d\u5b57\u4f53\u5305\u5230\/usr\/share\/fonts\u5e76\u6267\u884c mkfontscale && mkfontdir && fc-cache -fv \u9700\u8981\u5c0f\u8bed\u79cd\u5b57\u4f53\u7684\u53ef\u4ee5\u770b\u4e0bgoogle noto\u3002 […]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[3],"tags":[218],"_links":{"self":[{"href":"https:\/\/c.ipcpu.com\/wp-json\/wp\/v2\/posts\/1411"}],"collection":[{"href":"https:\/\/c.ipcpu.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/c.ipcpu.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/c.ipcpu.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/c.ipcpu.com\/wp-json\/wp\/v2\/comments?post=1411"}],"version-history":[{"count":1,"href":"https:\/\/c.ipcpu.com\/wp-json\/wp\/v2\/posts\/1411\/revisions"}],"predecessor-version":[{"id":1412,"href":"https:\/\/c.ipcpu.com\/wp-json\/wp\/v2\/posts\/1411\/revisions\/1412"}],"wp:attachment":[{"href":"https:\/\/c.ipcpu.com\/wp-json\/wp\/v2\/media?parent=1411"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/c.ipcpu.com\/wp-json\/wp\/v2\/categories?post=1411"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/c.ipcpu.com\/wp-json\/wp\/v2\/tags?post=1411"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}