我正在考虑从 Crystal Reports 转向基于 LaTeX 的解决方案,但要求能够制作符合预印布局的 pdf(在我工作的公司中,我们使用预印发票,因此可以手动填写或打印)。
有没有办法用乳胶做到这一点?我应该需要定义:
- 字段的最大宽度。
- 该字段的位置。
- 纸张尺寸(以毫米为单位)(也有印刷的支票!)
答案1
我通常以 pdf 格式提供我们研讨会的注册表,并提供用于填写数据的 latex 代码:让我们首先有一个示例注册表(纸张尺寸- letterpaper
):
首页 (form-0):
第二页(表格-1):
现在代码:
\documentclass[letterpaper]{article}% ensure identical page size
\usepackage[charter]{mathdesign}
\usepackage[svgnames]{xcolor}
\usepackage{tikz}
\usepackage[linkbordercolor={0 0 0},colorlinks=true,linkcolor=magenta]{hyperref}
\newcommand{\setfont}[2]{{\fontfamily{#1}\selectfont #2}}
\newcommand{\mycolor}[1]{\color{NavyBlue}{#1}}
\pagestyle{empty}
\begin{document}
% Page 1
\begin{tikzpicture}[remember picture,overlay]
\node at (current page.center) {\includegraphics{form}};
\begin{scope}[shift={(current page.south west)},every node/.style={anchor=base west}]
% Grid to help find the positions (remove in final version)
\draw [help lines,xstep=.2,ystep=.2,very thin] (0,0) grid (current page.north east); % if you want finer grid
\draw [help lines,xstep=1,ystep=1,thick] (0,0) grid (current page.north east);
\draw [help lines,very thick] (0,0) grid [step=5cm] (current page.north east);
\foreach \x in {0,...,21} { \node [anchor=north] at (\x,1) {\x}; }
\foreach \y in {0,1,...,27} { \node [anchor=east] at (1,\y) {\y}; }
% Comment up to here in final version
\node at (8.5cm,21.79cm) {\mycolor{\textbf{\vrule width 12pt height 1.5pt\hspace{.08cm} \vrule width 12pt height 1.5pt \,\, Harish Kumar}}};
\node at (7.8cm,20.93cm) {\mycolor{\textbf{Degree}}};
\node at (7.8cm,20.1cm) {\mycolor{\textbf{Designation, Department}}};
\node at (7.8cm,19.27cm) {\mycolor{\textbf{XX years}}};
\node at (7.8cm,18.43cm) {\mycolor{\textbf{XXXXX XXXXX}}};
\node at (7.8cm,17.61cm) {{\textbf{\href{mailto:[email protected]}{\texttt{[email protected]}}}}};
\node at (7.8cm,16.8cm) {\mycolor{\textbf{Dr. Harish Kumar}}};
\node at (7.8cm,15.95cm) {\mycolor{\textbf{Designation, Department}}};
\node at (7.8cm,15.13cm) {\mycolor{\textbf{Institute}}};
\node at (7.8cm,14.3cm) {\mycolor{\textbf{XXX XXX}}};
\node at (8.5cm,13.5cm) {\mycolor{\textbf{$\checkmark\,\,\,\quad$ \vrule width 12pt height 2pt }}};
\node at (8.87cm,12.69cm) {\mycolor{\textbf{\vrule width 12pt height 2pt $\quad\,\,\,\checkmark$}}};
\node at (3.7cm,11.83cm) {\mycolor{\textbf{XXXXX}}};\node at (12.2cm,11.83cm) {\mycolor{\textbf{\today}}};
\node at (3.7cm,11cm) {\mycolor{\textbf{Your Bank}}}; \node at (12.3cm,11cm) {\mycolor{\textbf{Here}}};
\node at (15.4cm,9cm) {\setfont{frc}{\color{Blue}{Harish Kumar}}};
\end{scope}
\end{tikzpicture}
\clearpage
% Page 2
\begin{tikzpicture}[remember picture,overlay]
\node at (current page.center) {\includegraphics{form}};
\begin{scope}[shift={(current page.south west)},every node/.style={anchor=base west}]
% Grid to help find the positions (remove in final version)
\draw [help lines] (0,0) grid (current page.north east);
\draw [help lines,thick] (0,0) grid [step=5cm] (current page.north east);
\foreach \x in {0,...,21} { \node [anchor=north] at (\x,1) {\x}; }
\foreach \y in {0,1,...,27} { \node [anchor=east] at (1,\y) {\y}; }
% Comment up to here in final version
%
\node at (3.4cm,21.64cm) {{\mycolor{PEC}}};
\node at (3.4cm,20.8cm) {{\mycolor{\today}}};
\node at (15.9cm,19.55cm) {\setfont{frc}{\color{Blue}{Harish Kumar}}};
\node at (5.68cm,16.74cm) {\vrule width 12pt height 1pt \hspace{.08cm} \vrule width 12pt height 1pt \hspace{.2cm} \setfont{pzc}{\mycolor{\Large Harish Kumar}}};
\end{scope}
\end{tikzpicture}
\clearpage
\end{document}
您将获得以下信息:
提供网格只是为了方便定位精确坐标。在最终表单中注释以下几行:
\draw [help lines] (0,0) grid (current page.north east);
\draw [help lines,thick] (0,0) grid [step=5cm] (current page.north east);
\foreach \x in {0,...,21} { \node [anchor=north] at (\x,1) {\x}; }
\foreach \y in {0,1,...,27} { \node [anchor=east] at (1,\y) {\y}; }
% Comment up to here in final version
要得到:
注意:我上面使用的空白表格是在 上排版的letterpaper
。因此在 tex 代码中,我使用了相同的大小。请在您的 tex 代码中使用适当的纸张大小(与预印纸张相同)。
答案2
我已经这样做过几次了,因为我的笔迹太差了。我最常使用这个textpos
包,lpic
它也非常有帮助。
这是最后一个代码。它需要从合同示例(与我最初使用的略有不同)
\documentclass{scrartcl}
\usepackage[utf8]{inputenc}\usepackage[T1]{fontenc}
\usepackage[ngerman]{babel}
\usepackage[left=0cm,right=0cm,top=0cm,bottom=0cm]{geometry}
\usepackage{graphicx}
\usepackage{lpic}
\setlength{\parindent}{0pt}
\begin{document}
\begin{lpic}[]{kaufvertragprivat(0.999)} % coords(20)
\lbl[t]{41,248;\textcolor{black}{\small \textbf{Max Mustermann}}}
\lbl[t]{130,248;\textcolor{black}{\small \textbf{Martina Musterfrau}}}
\lbl[t]{55,240;\textcolor{black}{\small \textbf{Musterstr. 2, 12345 Musterstadt}}}
\lbl[t]{140,240;\textcolor{black}{\small \textbf{Musterweg 23q, 12345 Musterstadt}}}
\lbl[t]{50,230;\textcolor{black}{\small \textbf{Personalausweis, 1234567890}}}
\lbl[t]{40,160;\textcolor{black}{\small \textbf{Oranje}}}
\lbl[t]{44,150;\textcolor{black}{\small \textbf{Hollandrad}}}
\lbl[t]{41,140;\textcolor{black}{\small \textbf{28 Zoll}}}
\lbl[t]{45,131;\textcolor{black}{\small \textbf{schwarzblau}}}
\lbl[t]{40,122;\textcolor{black}{\small \textbf{12345}}}
\lbl[t]{40,100;\textcolor{black}{\small \textbf{Beleuchtung}}}
\lbl[t]{41,95;\textcolor{black}{\small \textbf{Gepäckträger}}}
\lbl[t]{41,90;\textcolor{black}{\small \textbf{Schutzbleche}}}
\lbl[t]{39,85;\textcolor{black}{\small \textbf{Kopfstütze}}}
\lbl[t]{42,80;\textcolor{black}{\small \textbf{mehr Zubehör}}}
\lbl[t]{42,75;\textcolor{black}{\small \textbf{mehr Zubehör}}}
\lbl[t]{42,70;\textcolor{black}{\small \textbf{mehr Zubehör}}}
\lbl[t]{60,59;\textcolor{black}{\small \textbf{Musterstadt, den \today}}}
\lbl[t]{167,71;\textcolor{black}{\Large \textbf{--1234--}}}
\lbl[t]{113,83;\textcolor{black}{\Large X}}
\lbl[t]{113,121;\textcolor{black}{\Large X}}
\lbl[t]{113,116;\textcolor{black}{\Large X}}
\lbl[t]{113,116;\textcolor{black}{\Large X}}
\lbl[t]{113,126;\textcolor{black}{\Large X}}
\lbl[t]{113,150;\textcolor{black}{\Large X}}
\lbl[t]{113,155;\textcolor{black}{\Large X}}
\end{lpic}
\end{document}
答案3
我很欣赏那些使用 TikZ 的人,这没有什么错,但我还要指出的是,LaTeX 图片环境也可以完美地将文本放置在页面的任何位置。