PdfPug
stable
  • Vision
  • Tutorial
  • API Documentation
    • PdfReport
    • Header
    • Paragraph
    • List
    • Table
    • Image
    • Segment
    • LineBreak
    • Message Box
    • PageBreak
    • Progress Bar
    • Table of Contents
    • Enums
    • Text Formatters
    • Layouts
    • Theme
  • Changelog
  • Contributing Guide
PdfPug
  • Docs »
  • API Documentation »
  • Header
  • Edit on GitLab

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 or size parameter. Do not set both! Doing so will result in a ValueError being raised! By default, header tier is set to HeaderTier.h1. When setting size, be sure to set tier 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
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)
../_images/header_tiers.png
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

../_images/block_header.png
dividing = 'dividing'¶

The header is formatted to divide itself from the content below it using a horizontal line

../_images/dividing_header.png
Next Previous

© Copyright 2019, Nekhelesh Ramananthan Revision 07fed971.

Built with Sphinx using a theme provided by Read the Docs.