{"id":57551,"date":"2023-07-10T01:34:15","date_gmt":"2023-07-09T17:34:15","guid":{"rendered":"http:\/\/lrxjmw.cn\/?p=57551"},"modified":"2023-07-10T01:34:15","modified_gmt":"2023-07-09T17:34:15","slug":"wkhtmltopdf-linux-pdf","status":"publish","type":"post","link":"https:\/\/lrxjmw.cn\/wkhtmltopdf-linux-pdf.html","title":{"rendered":"\u4e00\u6b3e\u5728Linux \u4e2d\u5c06\u7f51\u9875\u8f6c\u6210 PDF \u7684\u667a\u80fd\u5de5\u5177"},"content":{"rendered":"\n\n\n
\u5bfc\u8bfb<\/td>\nwkhtmltopdf \u662f\u4e00\u4e2a\u5f00\u6e90\u3001\u7b80\u5355\u800c\u6709\u6548\u7684\u547d\u4ee4\u884c shell \u7a0b\u5e8f\uff0c\u5b83\u53ef\u4ee5\u5c06\u4efb\u4f55 HTML \uff08\u7f51\u9875\uff09\u8f6c\u6362\u4e3a PDF \u6587\u6863\u6216\u56fe\u50cf\uff08jpg\u3001png \u7b49\uff09\u3002
\n<\/strong><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n

wkhtmltopdf \u662f\u7528 C++ \u7f16\u5199\u7684\uff0c\u5e76\u5728 GNU\/GPL \uff08\u901a\u7528\u516c\u5171\u8bb8\u53ef\u8bc1\uff09\u4e0b\u53d1\u5e03\u3002\u5b83\u4f7f\u7528 WebKit \u6e32\u67d3\u5f15\u64ce\u5c06 HTML \u9875\u9762\u8f6c\u6362\u4e3a PDF \u6587\u6863\u4e14\u4e0d\u4f1a\u4e22\u5931\u9875\u9762\u7684\u8d28\u91cf\u3002\u8fd9\u662f\u4e00\u4e2a\u7528\u4e8e\u5b9e\u65f6\u521b\u5efa\u548c\u5b58\u50a8\u7f51\u9875\u5feb\u7167\u7684\u975e\u5e38\u6709\u7528\u4e14\u53ef\u4fe1\u8d56\u7684\u89e3\u51b3\u65b9\u6848\u3002<\/p>\n

\"wkhtmltopdf\uff1a\u4e00\u4e2a<\/p>\n

wkhtmltopdf \u7684\u529f\u80fd<\/strong><\/div>\n
    \n
  1. \u5f00\u6e90\u5e76\u4e14\u8de8\u5e73\u53f0\u3002<\/li>\n
  2. \u4f7f\u7528 WebKit \u5f15\u64ce\u5c06\u4efb\u610f HTML \u7f51\u9875\u8f6c\u6362\u4e3a PDF \u6587\u4ef6\u3002<\/li>\n
  3. \u6dfb\u52a0\u9875\u7709\u548c\u9875\u811a\u7684\u9009\u9879<\/li>\n
  4. \u76ee\u5f55\u751f\u6210 \uff08TOC\uff09 \u9009\u9879\u3002<\/li>\n
  5. \u63d0\u4f9b\u6279\u91cf\u6a21\u5f0f\u8f6c\u6362\u3002<\/li>\n
  6. \u901a\u8fc7\u7ed1\u5b9a libwkhtmltox \u6765\u652f\u6301 PHP \u6216 Python\u3002<\/li>\n<\/ol>\n

    \u5728\u672c\u6587\u4e2d\uff0c\u6211\u4eec\u5c06\u4ecb\u7ecd\u5982\u4f55\u5728 Linux \u7cfb\u7edf\u4e0b\u4f7f\u7528 tar \u5305\u6765\u5b89\u88c5 wkhtmltopdf\u3002<\/p>\n

    \u5b89\u88c5 Evince (PDF \u6d4f\u89c8\u5668)<\/strong><\/div>\n

    \u8ba9\u6211\u4eec\u5728 Linux \u7cfb\u7edf\u4e2d\u5b89\u88c5 evince\u00a0(\u4e00\u4e2a\u00a0PDF\u00a0\u9605\u8bfb\u5668)\u6765\u6d4f\u89c8 PDF \u6587\u4ef6\u3002<\/p>\n

    $ sudo yum install evince             [RHEL\/CentOS and Fedora]\r\n$ sudo dnf install evince             [On Fedora 22+ versions]\r\n$ sudo apt-get install evince         [On Debian\/Ubuntu systems]\r\n<\/pre>\n
    \u4e0b\u8f7d wkhtmltopdf \u6e90\u7801\u6587\u4ef6<\/strong><\/div>\n

    \u4f7f\u7528wget \u547d\u4ee4\u6839\u636e\u4f60\u7684 Linux \u67b6\u6784\u6765\u4e0b\u8f7d wkhtmltopdf \u6e90\u7801\u6587\u4ef6\uff0c\u6216\u8005\u4f60\u4e5f\u53ef\u4ee5\u5728wkhtmltopdf \u4e0b\u8f7d\u9875\u4e0b\u8f7d\u6700\u65b0\u7684\u7248\u672c\uff08\u76ee\u524d\u6700\u65b0\u7684\u7a33\u5b9a\u7248\u662f 0.12.4\uff09<\/p>\n

    \u5728 64 \u4f4d Linux \u7cfb\u7edf\u4e2d\uff1a<\/p>\n

    $ wget http:\/\/download.gna.org\/wkhtmltopdf\/0.12\/0.12.4\/wkhtmltox-0.12.4_linux-generic-amd64.tar.xz\r\n<\/pre>\n

    \u5728 32 \u4f4d Linux \u7cfb\u7edf\u4e2d\uff1a<\/p>\n

    $ wget http:\/\/download.gna.org\/wkhtmltopdf\/0.12\/0.12.4\/wkhtmltox-0.12.4_linux-generic-i386.tar.xz\r\n<\/pre>\n
    \u5728 Linux \u4e2d\u5b89\u88c5 wkhtmltopdf<\/strong><\/div>\n

    \u4f7f\u7528tar \u547d\u4ee4\u89e3\u538b\u6587\u4ef6\u5230\u5f53\u524d\u76ee\u5f55\u4e2d\u3002<\/p>\n

    ------ On 64-bit Linux OS ------\r\n$ sudo tar -xvf wkhtmltox-0.12.4_linux-generic-amd64.tar.xz \r\n------ On 32-bit Linux OS ------\r\n$ sudo tar -xvzf wkhtmltox-0.12.4_linux-generic-i386.tar.xz \r\n<\/pre>\n

    \u4e3a\u4e86\u80fd\u4ece\u4efb\u610f\u8def\u5f84\u6267\u884c\u7a0b\u5e8f\uff0c\u5c06 wkhtmltopdf \u5b89\u88c5\u5230\/usr\/bin\u76ee\u5f55\u4e0b\u3002<\/p>\n

    $ sudo cp wkhtmltox\/bin\/wkhtmltopdf \/usr\/bin\/\r\n<\/pre>\n
    \u5982\u4f55\u4f7f\u7528 wkhtmltopdf\uff1f<\/strong><\/div>\n

    \u6211\u4eec\u4f1a\u770b\u5230\u5982\u4f55\u5c06\u8fdc\u7a0b\u7684 HTML \u9875\u9762\u8f6c\u6362\u6210 PDF \u6587\u4ef6\u3001\u9a8c\u8bc1\u4fe1\u606f\u3001\u4f7f\u7528 evince \u5728 GNOME \u684c\u9762\u4e2d\u6d4f\u89c8\u521b\u5efa\u7684\u6587\u4ef6\u3002<\/p>\n

    \u5c06 HTML \u7f51\u9875\u8f6c\u6210 PDF \u6587\u4ef6<\/strong><\/span><\/div>\n

    \u8981\u5c06\u4efb\u610f HTML \u9875\u9762\u8f6c\u6362\u6210 PDF\uff0c\u8fd0\u884c\u4e0b\u9762\u7684\u547d\u4ee4\u3002\u5b83\u4f1a\u5728\u5f53\u524d\u76ee\u5f55\u4e0b\u5c06\u9875\u9762\u8f6c\u6362\u621010-Sudo-Configurations.pdf\u3002<\/p>\n

    # wkhtmltopdf http:\/\/www.tecmint.com\/sudoers-configurations-for-setting-sudo-in-linux\/ 10-Sudo-Configurations.pdf\r\n<\/pre>\n

    \u793a\u4f8b\u8f93\u51fa\uff1a<\/p>\n

    Loading pages (1\/6)\r\nCounting pages (2\/6)\r\nResolving links (4\/6)\r\nLoading headers and footers (5\/6)\r\nPrinting pages (6\/6)\r\nDone\r\n<\/pre>\n
    \u6d4f\u89c8\u751f\u6210\u7684 PDF \u6587\u4ef6<\/strong><\/span><\/div>\n

    \u4e3a\u4e86\u9a8c\u8bc1\u521b\u5efa\u7684\u6587\u4ef6\uff0c\u4f7f\u7528\u4e0b\u9762\u7684\u547d\u4ee4\u3002<\/p>\n

    $ file 10-Sudo-Configurations.pdf\r\n<\/pre>\n

    \u793a\u4f8b\u8f93\u51fa\uff1a<\/p>\n

    10-Sudo-Configurations.pdf: PDF document, version 1.4\r\n<\/pre>\n
    \u6d4f\u89c8\u751f\u6210\u7684 PDF \u6587\u4ef6\u7ec6\u8282<\/strong><\/span><\/div>\n

    \u8981\u6d4f\u89c8\u751f\u6210\u7684\u6587\u4ef6\u4fe1\u606f\uff0c\u8fd0\u884c\u4e0b\u9762\u7684\u547d\u4ee4\u3002<\/p>\n

    $ pdfinfo 10-Sudo-Configurations.pdf\r\n<\/pre>\n

    \u793a\u4f8b\u8f93\u51fa\uff1a<\/p>\n

    Title:          10 Useful Sudoers Configurations for Setting 'sudo' in Linux\r\nCreator:        wkhtmltopdf 0.12.4\r\nProducer:       Qt 4.8.7\r\nCreationDate:   Sat Jan 28 13:02:58 2017\r\nTagged:         no\r\nUserProperties: no\r\nSuspects:       no\r\nForm:           none\r\nJavaScript:     no\r\nPages:          13\r\nEncrypted:      no\r\nPage size:      595 x 842 pts (A4)\r\nPage rot:       0\r\nFile size:      697827 bytes\r\nOptimized:      no\r\nPDF version:    1.4\r\n<\/pre>\n
    \u6d4f\u89c8\u521b\u5efa\u7684\u6587\u4ef6<\/strong><\/span><\/div>\n

    \u5728\u684c\u9762\u4e2d\u4f7f\u7528 evince \u67e5\u770b\u6700\u65b0\u751f\u6210\u7684 PDF \u6587\u4ef6\u3002<\/p>\n

    $ evince 10-Sudo-Configurations.pdf\r\n<\/pre>\n

    \u793a\u4f8b\u622a\u56fe\uff1a
    \n\u5728\u6211\u7684 Linux Mint 17 \u4e2d\u770b\u8d77\u6765\u5f88\u68d2\u3002
    \n\"wkhtmltopdf\uff1a\u4e00\u4e2a<\/p>\n

    \u7ed9 PDF \u521b\u5efa\u9875\u9762\u7684\u76ee\u5f55<\/strong><\/div>\n

    \u8981\u521b\u5efa\u4e00\u4e2a PDF \u6587\u4ef6\u7684\u76ee\u5f55\uff0c\u4f7f\u7528 toc \u9009\u9879\u3002<\/p>\n

    $ wkhtmltopdf toc http:\/\/www.tecmint.com\/sudoers-configurations-for-setting-sudo-in-linux\/ 10-Sudo-Configurations.pdf\r\n<\/pre>\n

    \u793a\u4f8b\u8f93\u51fa\uff1a<\/p>\n

    Loading pages (1\/6)\r\nCounting pages (2\/6)\r\nLoading TOC (3\/6)\r\nResolving links (4\/6)\r\nLoading headers and footers (5\/6)\r\nPrinting pages (6\/6)\r\nDone\r\n<\/pre>\n

    \u8981\u67e5\u770b\u5df2\u521b\u5efa\u6587\u4ef6\u7684 TOC\uff0c\u518d\u6b21\u4f7f\u7528 evince\u3002<\/p>\n

    $ evince 10-Sudo-Configurations.pdf\r\n<\/pre>\n

    \u793a\u4f8b\u622a\u56fe\uff1a<\/p>\n

    \u770b\u4e00\u4e0b\u4e0b\u9762\u7684\u56fe\u3002\u5b83\u4e0a\u770b\u53bb\u6bd4\u4e0a\u9762\u7684\u66f4\u597d\u3002<\/p>\n

    \"wkhtmltopdf\uff1a\u4e00\u4e2a<\/p>\n

    wkhtmltopdf \u9009\u9879\u53ca\u4f7f\u7528<\/strong><\/span><\/div>\n

    \u66f4\u591a\u5173\u4e8e wkhtmltopdf \u7684\u4f7f\u7528\u53ca\u9009\u9879\uff0c\u4f7f\u7528\u4e0b\u9762\u7684\u5e2e\u52a9\u547d\u4ee4\u3002\u5b83\u4f1a\u663e\u793a\u51fa\u6240\u6709\u53ef\u7528\u7684\u9009\u9879\u3002<\/p>\n

    $ wkhtmltopdf --help\r\n<\/pre>\n
    \n

    via: http:\/\/www.tecmint.com\/wkhtmltopdf-convert-website-html-page-to-pdf-linux\/<\/a><\/p>\n

    \u4f5c\u8005\uff1aRavi Saive<\/a> \u8bd1\u8005\uff1ageekpi<\/a> \u6821\u5bf9\uff1awxy<\/a><\/p>\n

    \u672c\u6587\u7531 LCTT<\/a> \u539f\u521b\u7f16\u8bd1\uff0cLinux\u4e2d\u56fd<\/a> \u8363\u8a89\u63a8\u51fa<\/p>\n

    \n

    \u539f\u6587\u6765\u81ea\uff1ahttps:\/\/linux.cn\/article-8362-1.html<\/a><\/p>\n

    \u672c\u6587\u5730\u5740\uff1ahttp:\/\/lrxjmw.cn\/wkhtmltopdf-linux-pdf.html<\/a>\u7f16\u8f91\u5458\uff1a\u90ed\u5efa\u9e4f\uff0c\u5ba1\u6838\u5458\uff1a\u9004\u589e\u5b9d<\/span><\/p>\n<\/blockquote>\n","protected":false},"excerpt":{"rendered":"

    wkhtmltopdf \u662f\u4e00\u4e2a\u5f00\u6e90\u3001\u7b80\u5355\u800c\u6709\u6548\u7684\u547d\u4ee4\u884c shell \u7a0b\u5e8f\uff0c\u5b83\u53ef\u4ee5\u5c06\u4efb\u4f55 HTML \uff08\u7f51\u9875\uff09\u8f6c\u6362\u4e3a PDF \u6587\u6863\u6216\u56fe\u50cf\uff08jpg\u3001png \u7b49\uff09\u3002<\/p>\n","protected":false},"author":323,"featured_media":57567,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[55],"tags":[],"class_list":["post-57551","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-thread"],"acf":[],"_links":{"self":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/57551","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/users\/323"}],"replies":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/comments?post=57551"}],"version-history":[{"count":14,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/57551\/revisions"}],"predecessor-version":[{"id":276971,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/57551\/revisions\/276971"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media\/57567"}],"wp:attachment":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media?parent=57551"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/categories?post=57551"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/tags?post=57551"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}