Header¶
-
class
pdfpug.modules.
Header
(text, **kwargs)¶ A header element provides a short summary of the body text
It is separated from the body element and has a strong distinct style to stand above all other elements. Headers give a sense of orientation to the reader.
This class supports a wide variety of customisation that can be applied to a header from changing the header weight to the horizontal placement, color or style.
Instantiating a header is as simple as the following,
>>> from pdfpug.modules import Header >>> intro_header = Header('Introduction')
Want to customise the header weight and color?
>>> from pdfpug.common import HeaderTier, Color >>> intro_header.tier = HeaderTier.h2 >>> intro_header.color = Color.red
Note
The header size can be set using either the
tier
orsize
parameter. Do not set both! Doing so will result in aValueError
being raised! By default, header tier is set toHeaderTier.h1
. When settingsize
, be sure to settier
to None.Parameters: - text (
str
) – Header text - sub_header (Optional[str]) – Caption (sub header) below the header
- tier (HeaderTier) – Header weight (defaults to
HeaderTier.h1
) - alignment (Alignment) – Horizontal placement (defaults to
Alignment.center
) - size (Optional[Size]) – Size of header
- color (Optional[Color]) – Color of the header text
- style (Optional[HeaderStyle]) – Visual style of header
- text (
-
class
pdfpug.common.
HeaderTier
¶ Enum Weights to set the hierarchy of a header
The weights are compatible with Markdown levels such as h1, h2, h3 etc.
>>> from pdfpug.modules import Header >>> from pdfpug.common import HeaderTier >>> h1_header = Header('h1 Header', tier=HeaderTier.h1) >>> h2_header = Header('h2 Header', tier=HeaderTier.h2) >>> h3_header = Header('h3 Header', tier=HeaderTier.h3)
-
h1
= 'h1'¶ Page level header. Equivalent to a markdown h1 header.
-
h2
= 'h2'¶ Section level header. Equivalent to a markdown h2 header.
-
h3
= 'h3'¶ Paragraph level header. Equivalent to a markdown h3 header.
-
h4
= 'h4'¶ Paragraph level header. Equivalent to a markdown h4 header.
-
h5
= 'h5'¶ Paragraph level header. Equivalent to a markdown h5 header.
-
-
class
pdfpug.common.
HeaderStyle
¶ Enum header styles
>>> from pdfpug.modules import Header >>> from pdfpug.common import HeaderStyle >>> block_header = Header('Block Header', style=HeaderStyle.block)
-
block
= 'block'¶ The header is formatted to appear inside a content block
-
dividing
= 'dividing'¶ The header is formatted to divide itself from the content below it using a horizontal line
-