generate PDF by PyLaTex

  1. using PyLaTex to generate tex file
  2. compiled by xelatex to generate PDF
  3. merge PDFs by pdftk

install texlive

ubuntu

apt-get install texlive-full

centos

no yum repo to install texlive full

Ref:https://seisman.info/install-texlive-under-linux.html

download texlive2016.iso

official url: http://mirrors.ctan.org/systems/texlive/Images/texlive2016.iso

mount iso

$ su
# mount -o loop texlive2016.iso /mnt/
# cd /mnt
# ./install-tl

print I

update texlive

$ su
# tlmgr update --self
# tlmgr update --all

using repo of aliyun

# tlmgr update --self --repository http://mirrors.aliyun.com/CTAN/systems/texlive/tlnet/
# tlmgr update --all --repository http://mirrors.aliyun.com/CTAN/systems/texlive/tlnet/

add fonts to Linux

copy fonts

directory of windows C:\Windows\Fonts

copy to linux /usr/share/fonts

update fonts

show all fonts fc-list

update cache fc-cache -f -s -v

tips of tex compiled by xelatex

demo settings of preamble

\documentclass[11pt,a4paper]{article}
\usepackage{xeCJK} %xeCJK包
\usepackage[left=0cm,bottom=0cm]{geometry}
\usepackage{ulem} % 下划线
\usepackage{color} % 设置文字RGB值
\usepackage{type1cm}
\newcommand\username{someone} % 设置变量 \username可以代替someone
\definecolor{ColorName}{RGB}{76,73,72} % 设置字体颜色
\setCJKmainfont{SimHei} %设置默认中文字体黑体
\setCJKmonofont{KaiTi} %用作另外一种字体设置
\setmainfont{Times New Roman} %设置英文字体
\begin{document}
\pagestyle{empty} % 去掉页码
\color{ColorName} % 使用上文定义的字体颜色

set location

\vspace{17.634mm}\hspace*{54.314mm}

using fonts set in preamble

\ttfamily

Refs:

  1. http://www.cs.pu.edu.tw/~wckuo/doc/latex123/node1.html

  2. http://www.ctex.org/documents/latex/graphics/graphics.html

  3. http://tex.stackexchange.com/

tips of using PyLaTex

PyLaTex 1.0.0
https://github.com/JelteF/PyLaTeX

NoEscape

from pylatex.utils import NoEscape
#doc.append(NoEscape(r'\color{ColorName}'))

arguments

from pylatex import Command
#doc.preamble.append(Command('newcommand\\username',arguments=username))

issue

merge PDF

using pdftk
Ref: http://seisman.info/introduction-to-pdftk.html