-
Notifications
You must be signed in to change notification settings - Fork 0
/
pdffill.sty
120 lines (120 loc) · 4.25 KB
/
pdffill.sty
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
%%
%% This is file `pdffill.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% pdffill.dtx (with options: `package')
%% _____________________________________________________________
%% The pdffill package for LaTeX
%% Copyright (c) 2011-2019 Kazuki Maeda <[email protected]>
%%
%% Distributable under the MIT License:
%% http://www.opensource.org/licenses/mit-license.php
%%
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{pdffill}
[2019/01/29 fill in PDF]
\RequirePackage{tikz}
\RequirePackage{expl3,xparse}
\ExplSyntaxOn
\RequirePackage{pdfpages}
\keys_define:nn {pdffill} {
page .int_set:N = \l_pf_page_int,
draft .bool_set:N = \l_pf_draft_bool,
draft .default:n = true,
draftcolor .tl_set:N = \l_pf_draftcolor_tl,
grid .bool_set:N = \l_pf_grid_bool,
grid .default:n = true,
gridcolor .tl_set:N = \l_pf_gridcolor_tl,
tics .dim_set:N = \l_pf_tics_dim,
gridstep .int_set:N = \l_pf_gridstep_int,
labelstep .int_set:N = \l_pf_labelstep_int,
}
\tl_new:N \g_pf_defaultoption_tl
\dim_new:N \l_pf_tmpx_dim
\dim_new:N \l_pf_tmpy_dim
\dim_new:N \l_pf_gridstep_dim
\int_set:Nn \l_pf_page_int \c_one
\tl_set:Nn \l_pf_draftcolor_tl {red}
\tl_set:Nn \l_pf_gridcolor_tl {blue!40}
\dim_set:Nn \l_pf_tics_dim {2mm}
\int_set:Nn \l_pf_gridstep_int \c_one
\int_set:Nn \l_pf_labelstep_int \c_ten
\ProvideDocumentCommand \pfdefaultoption { m } {
\tl_gset:Nn \g_pf_defaultoption_tl {#1}
}
\ProvideDocumentCommand \pfnode { O{} u(u,u) +m } {
\bool_if:NTF \l_pf_draft_bool {
\node[#1,draw=\l_pf_draftcolor_tl] at (#3, #4) {#5};
\draw[draw=\l_pf_draftcolor_tl,fill=\l_pf_draftcolor_tl]
(#3, #4) circle (0.5mm);
} {
\node[#1] at (#3, #4) {#5};
}
}
\cs_generate_variant:Nn \keys_set:nn {nx}
\ProvideDocumentCommand \pdffill { O{} m +m } {
\group_begin:
\keys_set:nx {pdffill} {\g_pf_defaultoption_tl,#1}
\tl_set:Nn \l_pf_picturecommand_tl {
\put(0, 0){\noindent
\begin{tikzpicture}[inner~sep=0pt,overlay]
#3
\bool_if:NT \l_pf_grid_bool {
\dim_set:Nn \l_pf_gridstep_dim
{1cm * \l_pf_gridstep_int}
\draw[color=\l_pf_gridcolor_tl,densely~dotted,step=\l_pf_tics_dim]
(0, 0) grid (\paperwidth, \paperheight);
\draw[color=\l_pf_gridcolor_tl,densely~dotted,
step=\l_pf_gridstep_dim,thick]
(0, 0) grid (\paperwidth, \paperheight);
\dim_set:Nn \l_pf_tmpy_dim {\l_pf_gridstep_dim / 2}
\dim_while_do:nNnn \l_pf_tmpy_dim < \paperheight {
\dim_set:Nn \l_pf_tmpx_dim \l_pf_gridstep_dim
\int_set_eq:NN \l_tmpa_int \l_pf_gridstep_int
\dim_while_do:nNnn \l_pf_tmpx_dim < \paperwidth {
\node[color=\l_pf_gridcolor_tl] at (\l_pf_tmpx_dim, \l_pf_tmpy_dim)
{\scriptsize \int_use:N \l_tmpa_int};
\dim_add:Nn \l_pf_tmpx_dim \l_pf_gridstep_dim
\int_add:Nn \l_tmpa_int \l_pf_gridstep_int
}
\dim_add:Nn \l_pf_tmpy_dim {\l_pf_gridstep_dim * \l_pf_labelstep_int}
}
\dim_set:Nn \l_pf_tmpx_dim {\l_pf_gridstep_dim / 2}
\dim_while_do:nNnn \l_pf_tmpx_dim < \paperwidth {
\dim_set:Nn \l_pf_tmpy_dim \l_pf_gridstep_dim
\int_set_eq:NN \l_tmpa_int \l_pf_gridstep_int
\dim_while_do:nNnn \l_pf_tmpy_dim < \paperheight {
\node[color=\l_pf_gridcolor_tl] at (\l_pf_tmpx_dim, \l_pf_tmpy_dim)
{\scriptsize \int_use:N \l_tmpa_int};
\dim_add:Nn \l_pf_tmpy_dim \l_pf_gridstep_dim
\int_add:Nn \l_tmpa_int \l_pf_gridstep_int
}
\dim_add:Nn \l_pf_tmpx_dim {\l_pf_gridstep_dim * \l_pf_labelstep_int}
}
}
\end{tikzpicture}
}
}
\includepdf[pages=\int_use:N \l_pf_page_int,
picturecommand=\l_pf_picturecommand_tl,
fitpaper]
{#2}
\group_end:
}
\ProvideDocumentCommand \splitboxes { O{c} m m } {
\tl_map_inline:nn {#3} {\hbox_to_wd:nn {#2} {
\bool_if:nT {\str_if_eq_p:nn {#1} {c} || \str_if_eq_p:nn {#1} {r}} {
\tex_hss:D
}
##1
\bool_if:nT {\str_if_eq_p:nn {#1} {c} || \str_if_eq_p:nn {#1} {l}} {
\tex_hss:D
}
}
}
}
\endinput
%%
%% End of file `pdffill.sty'.