-
Notifications
You must be signed in to change notification settings - Fork 287
/
header.py
64 lines (54 loc) · 1.6 KB
/
header.py
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
#!/usr/bin/python
"""
This example shows the functionality of the PageHeader object.
It creates a sample page with the different types of headers and footers.
.. :copyright: (c) 2016 by Vladimir Gorovikov
:license: MIT, see License for more details.
"""
# begin-doc-include
from pylatex import (
Document,
Foot,
Head,
LargeText,
LineBreak,
MediumText,
MiniPage,
PageStyle,
simple_page_number,
)
from pylatex.utils import bold
def generate_header():
geometry_options = {"margin": "0.7in"}
doc = Document(geometry_options=geometry_options)
# Add document header
header = PageStyle("header")
# Create left header
with header.create(Head("L")):
header.append("Page date: ")
header.append(LineBreak())
header.append("R3")
# Create center header
with header.create(Head("C")):
header.append("Company")
# Create right header
with header.create(Head("R")):
header.append(simple_page_number())
# Create left footer
with header.create(Foot("L")):
header.append("Left Footer")
# Create center footer
with header.create(Foot("C")):
header.append("Center Footer")
# Create right footer
with header.create(Foot("R")):
header.append("Right Footer")
doc.preamble.append(header)
doc.change_document_style("header")
# Add Heading
with doc.create(MiniPage(align="c")):
doc.append(LargeText(bold("Title")))
doc.append(LineBreak())
doc.append(MediumText(bold("As at:")))
doc.generate_pdf("header", clean_tex=False)
generate_header()