Arch Linux上使用 pandoc 将 markdown 转为 pdf 以及如何查看本机的中文字体 fc-list :lang=zh

41 篇文章 1 订阅

Intro

自己平时写文档主要是用md写,但是甲方和乙方有时候说喜欢pdf或者word. docsify没的自带的pdf转换,最基本的王者就是这个pandoc了

博客原文地址

pandoc

一个文档格式转换大神级工具,支持HTML、CSL YAML、Ebooks、Interactive notebook formats、Word processor formats

Pandoc installing

For PDF output, you’ll need LaTeX. We recommend installing TeX Live via your package manager. (On Debian/Ubuntu, apt-get install texlive.)

如果想输出为pdf,需要安装 LaTeX 引擎

install

# 安装pandoc
sudo pacman -S pandoc

# 安装texlive和中文支持
sudo pacman -S texlive-core texlive-langchinese
test
$ pandoc --version
pandoc 2.11.4
Compiled with pandoc-types 1.22, texmath 0.12.1.1, skylighting 0.10.3,
citeproc 0.3.0.9, ipynb 0.1.0.1
User data directory: /home/kearney/.local/share/pandoc or /home/kearney/.pandoc
Copyright (C) 2006-2021 John MacFarlane. Web:  https://pandoc.org
This is free software; see the source for copying conditions. There is no
warranty, not even for merchantability or fitness for a particular purpose.

demo

$ tex '\empty Hello world!\bye'
This is TeX, Version 3.14159265 (TeX Live 2020/Arch Linux) (preloaded format=tex)
[1]
Output written on texput.dvi (1 page, 224 bytes).
Transcript written on texput.log.

$ pdftex '\empty Hello world!\bye'
pdftex: error while loading shared libraries: libpoppler.so.108: cannot open shared object file: No such file or directory
# emm版本问题后面升级解决了这个问题,网上搜的基本是ls软连接,不能治本

中文问题继续往下说,如果在demo里直接加中文会报错Missing character: There is no � in font cmr10!

在这里插入图片描述

Demo: markdown

quickstart.md 的内容

# 快速入门

## 环境准备

软件使用需要满足的前置条件

## 安装

软件的安装方法

## 设置

软件的设置

除了输入输出的文件名,还有latex引擎,当然最主要的是中文字体,如何查看本机上的中文字体?

pandoc quickstart.md -o quickstart.md.pdf --pdf-engine=xelatex -V CJKmainfont='Sarasa UI SC' 

在这里插入图片描述

Pandoc 使用及踩坑 点半久 Edited on 2019-08-31
使用 fc-list :lang=zh 命令查看一下你自己系统上都安装了哪些中文字体:
每一行第一个冒号到其后第一个逗号之间的内容

卸载

万一呢

```bash
$ sudo pacman -Rs pandoc
正在检查依赖关系...

软件包 (127) ghc-libs-8.10.4-1  haskell-aeson-1.5.6.0-7  haskell-aeson-pretty-0.8.8-145
             haskell-ansi-terminal-0.11-94  haskell-asn1-encoding-0.9.6-97  haskell-asn1-parse-0.9.5-97
             haskell-asn1-types-0.3.4-76  haskell-assoc-1.0.2-66  haskell-async-2.2.3-15
             haskell-attoparsec-0.13.2.5-12  haskell-base-compat-0.11.2-4
             haskell-base-compat-batteries-0.11.2-87  haskell-base-orphans-0.8.4-76
             haskell-base16-bytestring-1.0.1.0-35  haskell-base64-bytestring-1.2.0.1-42
             haskell-basement-0.0.11-10  haskell-bifunctors-5.5.10-47  haskell-blaze-builder-0.4.2.1-2
             haskell-blaze-html-0.9.1.2-98  haskell-blaze-markup-0.8.2.8-4  haskell-byteable-0.1.1-22
             haskell-case-insensitive-1.2.1.0-78  haskell-cereal-0.5.8.1-9  haskell-citeproc-0.3.0.9-1
             haskell-cmdargs-0.10.21-1  haskell-colour-2.3.5-152  haskell-commonmark-0.1.1.4-11
             haskell-commonmark-extensions-0.2.0.4-42  haskell-commonmark-pandoc-0.2.0.1-81
             haskell-comonad-5.0.8-61  haskell-conduit-1.3.4.1-5  haskell-conduit-extra-1.3.5-117
             haskell-connection-0.3.1-108  haskell-cookie-0.4.5-9  haskell-cryptonite-0.28-18
             haskell-data-default-0.7.1.1-128  haskell-data-default-class-0.1.2.0-21
             haskell-data-default-instances-containers-0.0.1-33
             haskell-data-default-instances-dlist-0.0.1-141
             haskell-data-default-instances-old-locale-0.0.1-33  haskell-data-fix-0.3.1-14
             haskell-digest-0.0.1.2-22  haskell-distributive-0.6.2.1-65  haskell-dlist-1.0-64
             haskell-doclayout-0.3-85  haskell-doctemplates-0.9-30  haskell-emojis-0.1-86
             haskell-erf-2.0.0.0-21  haskell-errors-2.3.0-59  haskell-file-embed-0.0.13.0-3
             haskell-glob-0.10.1-67  haskell-haddock-library-1.9.0-118  haskell-hashable-1.3.1.0-13
             haskell-hourglass-0.2.12-121  haskell-hslua-1.3.0.1-17  haskell-hslua-module-system-0.2.2.1-72
             haskell-hslua-module-text-0.3.0.1-60  haskell-hsyaml-0.2.1.0-91  haskell-http-4000.3.15-130
             haskell-http-client-0.7.6-7  haskell-http-client-tls-0.3.5.3-398  haskell-http-types-0.12.3-143
             haskell-hxt-9.3.1.21-18  haskell-hxt-charproperties-9.5.0.0-1
             haskell-hxt-regex-xmlschema-9.2.0.7-2  haskell-hxt-unicode-9.0.2.4-22
             haskell-indexed-traversable-0.1.1-3  haskell-integer-logarithms-1.0.3.1-3
             haskell-ipynb-0.1.0.1-184  haskell-jira-wiki-markup-1.3.3-6  haskell-juicypixels-3.3.5-77
             haskell-memory-0.15.0-88  haskell-mime-types-0.1.0.9-11  haskell-mono-traversable-1.0.15.1-118
             haskell-network-3.1.2.1-40  haskell-network-uri-2.6.4.1-8  haskell-old-locale-1.0.0.7-27
             haskell-old-time-1.1.0.3-27  haskell-pandoc-types-1.22-63  haskell-pem-0.2.4-153
             haskell-primitive-0.7.1.0-106  haskell-quickcheck-2.14.2-124  haskell-random-1.2.0-178
             haskell-resourcet-1.2.4.2-70  haskell-safe-0.3.19-5  haskell-scientific-0.3.6.2-92
             haskell-sha-1.6.4.4-16  haskell-skylighting-0.10.3-3  haskell-skylighting-core-0.10.3-3
             haskell-socks-0.6.1-98  haskell-split-0.2.3.4-120  haskell-splitmix-0.1.0.3-82
             haskell-streaming-commons-0.2.2.1-68  haskell-strict-0.4.0.1-40  haskell-syb-0.7.2.1-31
             haskell-tagged-0.8.6.1-2  haskell-tagsoup-0.14.8-101  haskell-temporary-1.3-228
             haskell-texmath-0.12.1.1-18  haskell-text-conversions-0.3.1-56  haskell-text-icu-0.7.0.1-37
             haskell-th-abstraction-0.4.2.0-2  haskell-th-compat-0.1.2-1  haskell-these-1.1.1.1-67
             haskell-time-compat-1.9.5-40  haskell-tls-1.5.5-12  haskell-transformers-compat-0.6.6-3
             haskell-typed-process-0.2.6.0-102  haskell-unicode-transforms-0.3.7.1-51
             haskell-uniplate-1.6.13-44  haskell-unliftio-core-0.2.0.1-6
             haskell-unordered-containers-0.2.13.0-51  haskell-utf8-string-1.0.2-25
             haskell-uuid-types-1.0.3-97  haskell-vector-0.12.2.0-40  haskell-vector-algorithms-0.8.0.4-40
             haskell-x509-1.7.5-132  haskell-x509-store-1.6.7-131  haskell-x509-system-1.6.6-199
             haskell-x509-validation-1.6.11-131  haskell-xml-1.3.14-27  haskell-xml-conduit-1.9.1.0-6
             haskell-xml-types-0.3.8-5  haskell-zip-archive-0.4.1-106  haskell-zlib-0.6.2.3-8  lua53-5.3.6-1
             pandoc-2.11.4-7

....

Refer

Pandoc

TeX Live (简体中文) - Arch WiKi

libpoppler.so.76: cannot open shared object file: No such file or directory carolynlmk 2019-01-25:已经有了libpoppler.so.19库,这个更新。所以通过建立19到18链接来暂时避免

Mangaro下安装TextLive遇到的问题 Tender_Li 2020-02-06:建立19到18链接,没有证明自己有没有存在这个库。。

error while loading shared libraries: libpoppler.so.101: cannot open shared object file: No such file or directory 2020

After check the directory /usr/lib/ I found there is no libpoppler.so.101, instead, we get libpoppler.so.102. Then I checked the pamac history and found the poppler related packages were updated from 0.90.1-1 to 20.08.1-1. I think this is why libpoppler.so updated from 101 to 102.
The problem here is, after the update, pdf-tools tries to rebuild itself. However, it does not really do the rebuild, which I don’t know why. (maybe make does not find the change of source code so it just skips all the rebuild. sorry, I only know little about compile.)
So, what I did is go to pdf-tools’ directory which is path/to/.emacs.d/elpa/pdf-tools-xxx/build and run make clean to remove these object files manually. I also did make clean in the server subdirectory under build, but I am not sure if it is necessary. Then reopen emacs and let it rebuild the pdf-tools (or run pdf-tools-install, to rebuild it manually).

所以问题无法确定是不是升级导致的

phodal/ebook-boilerplate:A Markdown convert to Ebook arrow_right html、mobi、epub、pdf、rtf Template

Shieber / Text2docx2pdf :linux下三个工具软件,可在命令行实现txt转docx,txt转pdf,docx转pdf。依赖python-docx

mstamy2/PyPDF2:PyPDF2 是一个纯 Python PDF 库,能够分割、合并、裁剪和转换 PDF 文件页面

Python 爬虫:把廖雪峰的教程转换成 PDF 电子书:pdfkit、wkhtmltopdf

英强 / MD2File:Java - 文档导出工具类,能将markdown格式的内容,转为office word,PDF,HTML等等格式的文档。不使用markdown格式的内容,直接调用MD2File的api,生成word,pdf等文档也是可以的。 另外,还可以将MD2File作为markdown转HTML的工具类。

Pandoc 使用及踩坑 点半久 Edited on 2019-08-31:Nice note, 不过同样是pacman安装的,我的没有sty文件问题。。或许是因为我安装了中文加持包的缘故吧

End

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值