{"id":6231,"date":"2021-01-15T22:50:52","date_gmt":"2021-01-15T14:50:52","guid":{"rendered":"https:\/\/vip.fxxkpython.com\/?p=6231"},"modified":"2021-02-07T21:34:31","modified_gmt":"2021-02-07T13:34:31","slug":"%e5%a6%82%e4%bd%95%e6%8a%8a%e7%bd%91%e9%a1%b5%e7%a7%92%e5%8f%98-pdf%ef%bc%8c-%e7%84%b6%e5%90%8e%e6%85%a2%e6%85%a2%e7%9c%8b%ef%bc%9f","status":"publish","type":"post","link":"https:\/\/vip.fxxkpython.com\/?p=6231","title":{"rendered":"\u5982\u4f55\u628a\u7f51\u9875\u79d2\u53d8 PDF\uff0c \u7136\u540e\u6162\u6162\u770b\uff1f"},"content":{"rendered":"\n<h2>\u745e\u58eb\u519b\u5200\uff1f<\/h2>\n\n\n\n<p>\u4e0d\u77e5\u9053\u4f60\u5bf9\u5404\u79cd\u6587\u4ef6\u7684\u683c\u5f0f\u8f6c\u6362\u9700\u6c42\u5927\u4e0d\u5927\uff0c\u5bf9\u4e8e\u6211\u6765\u8bf4\u662f\u633a\u9700\u8981\u7684\uff0c\u6bd4\u5982\u6709\u65f6\u5019\u6211\u5728 MarkDown \u5199\u7684\u6587\u7ae0\u6216\u8005\u6587\u6863\uff0c\u6211\u9700\u8981\u5c06\u5b83\u4eec\u8f6c\u5316\u6210\u4e0d\u540c\u7684\u6587\u4ef6\u5f62\u5f0f\u6765\u7ed9\u522b\u4eba\u9605\u8bfb\uff0c\u6bd4\u5982\u7f51\u9875\uff0c\u6bd4\u5982 PDF\uff0c\u7535\u5b50\u4e66\u7684 epub \u7b49\u7b49\u7684\u683c\u5f0f\uff0c\u751a\u81f3\u6211\u8fd8\u60f3\u8981\u5b83\u4eec\u5728\u4e0d\u540c\u7684\u683c\u5f0f\u4e4b\u95f4\u80fd\u591f\u4e92\u76f8\u8f6c\u6362\u3002\u4f60\u60f3\u4e0d\u60f3\uff0c\u628a\u5728\u7ebf\u7684\u7f51\u9875\u53d8\u6210 PDF\uff0c \u7136\u540e\u6162\u6162\u770b\uff1f\u4eca\u5929\u5c0f\u5e05b\u60f3\u8981\u7ed9\u4f60\u4ecb\u7ecd\u7684\u662f\u4e00\u4e2a\u5f00\u6e90\u7684\u795e\u5668\u2014\u2014pandoc\u3002\u5b83\u81ea\u79f0\u662f\u4e00\u628a\u6587\u4ef6\u683c\u5f0f\u8f6c\u6362\u7684\u300c\u745e\u58eb\u519b\u5200\u300d\uff0c\u56e0\u4e3a\u51e0\u4e4e\u4f60\u80fd\u591f\u60f3\u5230\u7684\u7528\u6807\u8bb0\u8bed\u8a00\u5199\u7684\u6587\u4ef6\uff0c\u90fd\u80fd\u901a\u8fc7 pandoc \u8fdb\u884c\u8f6c\u6362\u3002If you need to convert files from one markup format into another, pandoc is your swiss-army knife.\u90a3\u4e48\uff0c\u600e\u4e48\u901a\u8fc7 pandoc \u6765\u5b9e\u73b0\u6211\u4eec\u9700\u8981\u7684\u6587\u4ef6\u683c\u5f0f\u8f6c\u5316\u5462\uff1f<\/p>\n\n\n\n<h2>\u5b89\u88c5\u4e00\u6ce2\u5457\uff5e<\/h2>\n\n\n\n<p>\u6839\u636e\u4f60\u4f7f\u7528\u7684\u64cd\u4f5c\u7cfb\u7edf\uff0c\u4f60\u53ef\u4ee5\u5230 GitHub \u4e0a\u4e0b\u8f7d\u76f8\u5e94\u7684\u7248\u672c\uff1ahttps:\/\/github.com\/jgm\/pandoc\/releases\/tag\/2.11.3.2<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/pic2.zhimg.com\/80\/v2-66a65d9219c57090ab3db3976fcc72bb_1440w.png\" alt=\"\"\/><\/figure>\n\n\n\n<p>\u4f60\u4e5f\u53ef\u4ee5\u4f7f\u7528\u547d\u4ee4\u7684\u65b9\u5f0f\u8fdb\u884c\u5b89\u88c5:Mac OS \u53ef\u4ee5\u8fd9\u6837\u5b89\u88c5\uff1abrew install pandoc\u5982\u679c\u4f60\u662f Windows \u7528\u6237\u4e5f\u53ef\u4ee5\u4f7f\u7528 choco \u8fdb\u884c\u5b89\u88c5\uff1achoco install pandocUbuntu \u53ef\u4ee5\u8fd9\u4e48\u5b89\u88c5\uff1asudo apt-get install pandoc\u7136\u540e\u4f60\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\uff0c\u53ef\u4ee5\u770b\u5230\u7248\u672c\u53f7\u5c31\u8bf4\u660e\u4f60\u5b89\u88c5\u6210\u529f\u4e86\uff1apandoc &#8211;version<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/pic4.zhimg.com\/80\/v2-5ac6223f47961cda28e6a1ddbcfb996f_1440w.png\" alt=\"\"\/><\/figure>\n\n\n\n<h2>\u5982\u4f55\u4f7f\u7528 pandoc \uff1f<\/h2>\n\n\n\n<p>pandoc \u7684\u547d\u4ee4\u662f\u8fd9\u6837\u4f7f\u7528\u7684\uff1apandoc [\u9009\u9879] [\u8f93\u5165\u6587\u4ef6] &#8230;<\/p>\n\n\n\n<h2>\u5c06 markdown \u8f6c\u5316\u4e3a HTML<\/h2>\n\n\n\n<p>\u6bd4\u5982\u6211\u60f3\u628a\u6211\u73b0\u5728\u5199\u7684 markdown \u662f\u8fd9\u6837\u7684\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/pic4.zhimg.com\/80\/v2-84fd96dffb07355ee0e5a56f637cf8f8_1440w.png\" alt=\"\"\/><\/figure>\n\n\n\n<p>\u60f3\u8981\u628a\u5b83\u8f6c\u5316\u6210 HTML\uff0c\u5c31\u53ef\u4ee5\u8fd9\u6837\uff1apandoc -s &#8211;metadata title=&#8217;\u5e05b\u8bb2pandoc&#8217; -o out.html Desktop\/pandoc.md\u8fd9\u6837\u5c31\u53ef\u4ee5\u628a\u6211\u684c\u9762\u4e0a\u7684 md \u76f4\u63a5\u8f6c\u51fa html \u6587\u4ef6\u4e86\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/pic2.zhimg.com\/80\/v2-bd838d7e4695dfb48c06c9775624619c_1440w.png\" alt=\"\"\/><\/figure>\n\n\n\n<p>\u4e00\u884c\u547d\u4ee4\u5c31\u641e\u5b9a\u4e86\uff0c\u5176\u4e2d \u300c -s &#8211;metadata title=&#8217;\u5e05b\u8bb2pandoc&#8217; -o out.html \u300d\u5c31\u662f\u300c\u9009\u9879\u300d\uff1a<\/p>\n\n\n\n<ul><li>-s \u6307\u7684\u662f\u544a\u8bc9pandoc\u6211\u8981\u751f\u6210\u6709\u6548\u7684 HTML \u6587\u4ef6<\/li><li>&#8211;metadata title \u6307\u7684\u662f\u8bf4\u660e HTML \u7684 title<\/li><li>-o \u6307\u7684\u662f\u6211\u4eec\u8981\u8f93\u51fa\u7684\u6587\u4ef6<\/li><\/ul>\n\n\n\n<p>\u800c\u5728\u6700\u540e\u9762\u7684 \u300cDesktop\/pandoc.md\u300d\u5c31\u662f\u300c\u8f93\u5165\u6587\u4ef6\u300d\u3002<\/p>\n\n\n\n<h2>pandoc \u9009\u9879\u5728\u54ea\u554a\uff1f<\/h2>\n\n\n\n<p>\u53ef\u80fd\u4f60\u8981\u95ee\u4e86\uff0c\u8fd9\u4e9b\u300c\u9009\u9879\u300d\u5728\u54ea\u91cc\u53ef\u4ee5\u5f97\u5230\uff0c\u5206\u522b\u90fd\u662f\u4ec0\u4e48\u610f\u601d\uff1f\u6709\u4e24\u4e2a\u5730\u65b9\u4f60\u53ef\u4ee5\u67e5\u8be2\u5f97\u5230\uff0c\u4e00\u4e2a\u662f\u5728\u4f60\u7684\u7ec8\u7aef\u4e2d\u4f7f\u7528 man \u547d\u4ee4\uff1aman pandoc\u5f80\u4e0b\u62c9\u4f60\u5c31\u53ef\u4ee5\u770b\u5230\u5404\u79cd\u9009\u9879\u7684\u610f\u601d\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/pic4.zhimg.com\/80\/v2-cce6950733cabd5aab56eabf9bcfaca6_1440w.webp\" alt=\"\"\/><\/figure>\n\n\n\n<p>\u53e6\u4e00\u4e2a\u5730\u65b9\u4f60\u53ef\u4ee5\u901a\u8fc7\u5728\u7ebf\u6587\u6863\u67e5\u8be2\uff0c\u5730\u5740\u5728\u8fd9\uff1ahttps:\/\/pandoc.org\/MANUAL.html#options\u5185\u5bb9\u90fd\u662f\u4e00\u6837\u7684\uff0c\u4e0d\u8fc7\u7f51\u9875\u66f4\u52a0\u65b9\u4fbf\u67e5\u9605\u3002<\/p>\n\n\n\n<h2>\u5c06 HTML \u8f6c\u5316\u4e3a PDF<\/h2>\n\n\n\n<p>\u6211\u4eec\u518d\u6765\u73a9\u4e00\u4e0b\uff0c\u5c06 HTML \u6587\u4ef6\u8f6c\u5316\u4e3a PDF\uff0c\u56e0\u4e3a pandoc \u5728\u8f6c\u5316\u4e3a PDF \u6587\u4ef6\u7684\u65f6\u5019\uff0c\u9700\u8981\u7528\u5230 pdf \u5f15\u64ce\uff0cpandoc \u9ed8\u8ba4\u4f7f\u7528\u7684\u662f pdflatex\uff0c\u5982\u679c\u4f60\u6ca1\u6709\u5b89\u88c5\u53ef\u4ee5\u5148\u5b89\u88c5\u4e00\u6ce2\u3002brew install basictexpandoc \u652f\u6301\u7684 pdf \u5f15\u64ce\u6709\u5f88\u591a\uff0c\u6bd4\u5982\uff1apdflatex, lualatex, xelatex, latexmk, tectonic, wkhtmltopdf, weasyprint, prince, context\u4f60\u53ef\u4ee5\u6839\u636e\u81ea\u5df1\u7684\u9700\u8981\uff0c\u9009\u62e9\u5bf9\u5e94\u7684\u5f15\u64ce\uff0c\u6bd4\u5982\u6211\u4eec\u628a\u521a\u521a\u751f\u6210\u7684 HTML \u6587\u4ef6\u76f4\u63a5\u8f6c\u5316\u4e3a PDF\uff0c\u5c31\u53ef\u4ee5\u8fd9\u6837\uff1apandoc &#8211;pdf-engine=xelatex -o out.pdf out.html -V mainfont=STXihei\u8fd9\u91cc\u6211\u4eec\u4f7f\u7528\u7684 pdf \u5f15\u64ce\u662f xelatex\uff0c\u4f7f\u7528\u7684\u4e2d\u6587\u5b57\u4f53\u662f\u7ec6\u9ed1\uff0c\u8fd0\u884c\u5f97\u5230\u7684 pdf \u662f\u8fd9\u6837\u5b50\u7684\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/pic4.zhimg.com\/80\/v2-108143a239de4369556615c073ca9773_1440w.gif\" alt=\"\"\/><\/figure>\n\n\n\n<p>\u662f\u4e0d\u662f\u5f88\u65b9\u4fbf\uff0c\u8fd8\u6709\u5f88\u591a\u5176\u4ed6\u7684\u6587\u4ef6\u683c\u5f0f\uff0c\u4f60\u90fd\u53ef\u4ee5\u901a\u8fc7 pandoc \u8fdb\u884c\u8f6c\u5316\uff0c\u4f60\u8fd8\u53ef\u4ee5\u5bf9\u5176\u6307\u5b9a\u6837\u5f0f\uff0c\u6a21\u677f\u7b49\u64cd\u4f5c\uff0c\u4f60\u90fd\u53ef\u4ee5\u5728\u8fd9\u91cc\u627e\u5230\uff1ahttps:\/\/pandoc.org\/MANUAL.html\u3002<\/p>\n\n\n\n<h2>Python \u4f7f\u7528 Pandoc<\/h2>\n\n\n\n<p>\u5982\u679c\u4f60\u60f3\u5728 Python \u4e2d\u4f7f\u7528 pandoc \uff0c\u4e5f\u4e0d\u662f\u4e0d\u884c\uff0c\u4f60\u53ef\u4ee5\u5b89\u88c5 pypandoc \u8fd9\u4e2a\u5e93\uff0c\u7136\u540e\u4f7f\u7528\u4e5f\u662f\u5f88\u7b80\u5355\uff0c\u50cf\u8fd9\u6837\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/pic2.zhimg.com\/80\/v2-fbe416ead13bd5bf0778ba260904a0a9_1440w.png\" alt=\"\"\/><\/figure>\n\n\n\n<p>OK\uff0c\u4ee5\u4e0a\u5c31\u662f\u4eca\u5929\u5c0f\u5e05b\u7ed9\u4f60\u5e26\u6765\u7684\u5206\u4eab\uff0c\u5e0c\u671b\u5bf9\u4f60\u6709\u5e2e\u52a9\uff01\u6700\u540e\uff0c\u4e00\u76f4\u575a\u6301\u539f\u521b\u5206\u4eab\u4e0d\u6613\uff0c\u5982\u679c\u5bf9\u4f60\u6709\u5e2e\u52a9\u7684\u8bdd\u70b9\u4e2a\u8d5e\u652f\u6301\u4e00\u4e0b\u5457\uff0c\u8fd9\u6837\u6211\u624d\u6709\u52a8\u529b\u7ed9\u4f60\u4e00\u76f4\u5206\u4eab\u4e2a\u4e0d\u505c\u561b\uff0c\u597d\u4e86\uff0c\u6211\u4eec\u4e0b\u56de\u89c1\uff0cpeace\uff01<\/p>\n\n\n\n<h2><\/h2>\n","protected":false},"excerpt":{"rendered":"<p>\u745e\u58eb\u519b\u5200\uff1f \u4e0d\u77e5\u9053\u4f60\u5bf9\u5404\u79cd\u6587\u4ef6\u7684\u683c\u5f0f\u8f6c\u6362\u9700\u6c42\u5927\u4e0d\u5927\uff0c\u5bf9\u4e8e\u6211\u6765\u8bf4\u662f\u633a\u9700\u8981\u7684\uff0c\u6bd4\u5982\u6709\u65f6\u5019\u6211\u5728 MarkDown \u5199\u7684\u6587\u7ae0\u6216\u8005\u6587\u6863\uff0c\u6211\u9700\u8981\u5c06\u5b83\u4eec\u8f6c\u5316\u6210\u4e0d\u540c\u7684\u6587\u4ef6\u5f62\u5f0f\u6765\u7ed9\u522b\u4eba\u9605\u8bfb\uff0c\u6bd4\u5982\u7f51\u9875\uff0c\u6bd4\u5982 PDF\uff0c\u7535\u5b50\u4e66\u7684 epub \u7b49\u7b49\u7684\u683c\u5f0f\uff0c\u751a\u81f3\u6211\u8fd8\u60f3\u8981\u5b83\u4eec\u5728\u4e0d\u540c&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[303,343],"tags":[516,517],"_links":{"self":[{"href":"https:\/\/vip.fxxkpython.com\/index.php?rest_route=\/wp\/v2\/posts\/6231"}],"collection":[{"href":"https:\/\/vip.fxxkpython.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/vip.fxxkpython.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/vip.fxxkpython.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/vip.fxxkpython.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=6231"}],"version-history":[{"count":2,"href":"https:\/\/vip.fxxkpython.com\/index.php?rest_route=\/wp\/v2\/posts\/6231\/revisions"}],"predecessor-version":[{"id":6238,"href":"https:\/\/vip.fxxkpython.com\/index.php?rest_route=\/wp\/v2\/posts\/6231\/revisions\/6238"}],"wp:attachment":[{"href":"https:\/\/vip.fxxkpython.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=6231"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/vip.fxxkpython.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=6231"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/vip.fxxkpython.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=6231"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}