Segment

class pdfpug.modules.Segment(data, **kwargs)

A segment is used to create a grouping of related content.

Parameters:
  • data – Content to be grouped
  • segment_type (Optional[SegmentType]) – Visual style
  • aligment (Optional[Alignment]) – Horizontal alignment of all content
  • spacing (Optional[SegmentSpacing]) – Padding around the content
  • emphasis (Optional[SegmentEmphasis]) – Emphasis strength of segment
>>> from pdfpug.modules import Segment, Header, Paragraph, UnorderedList
>>> from pdfpug.common import HeaderTier
>>> segment = Segment(
...     [
...         Header('Segment', tier=HeaderTier.h3),
...         Paragraph(
...             'Segments are <b>collection views</b> that can be used to group '
...             'content together. They can contain images, headers, and any '
...             'other elements that is supported by PdfPug. Segments come in '
...             'different styles that can be used to modify it to different use '
...             'cases.'
...         ),
...         Paragraph('Some segment types are listed below,'),
...         UnorderedList(['Stacked', 'Piled', 'Vertical', 'Basic'])
...     ],
... )
../_images/segment.png

The appearance of segments can be styled for different use cases and preferences,

>>> from pdfpug.common import SegmentType
>>> segment.segment_type = SegmentType.stacked
class pdfpug.modules.Segments(segments, **kwargs)

A group of Segment can be formatted to appear together using Segments.

Parameters:
  • segments (List[Union[Segment, Segments]]) – Group of segments
  • segments_type (Optional[SegmentType]) – Visual style
  • orientation (Optional[Orientation]) – Orientation of elements
class pdfpug.common.SegmentType

Enum Segment Type

basic = 'basic'

Basic segment type with no special formatting

stacked = 'stacked'

Segment that appears to contain multiple pages which are stacked cleanly

../_images/stacked_segment.png
piled = 'piled'

Segment that appears to look like a pile of papers

../_images/piled_segment.png
vertical = 'vertical'

Segment type that formats the content to be aligned as part of a vertical group

../_images/vertical_segment.png
circular = 'circular'

Circular segment type. For a circle, ensure content has equal width and height

../_images/circular_segment.png
class pdfpug.common.SegmentSpacing

Enum Segment Spacing

compact = 'compact'

Segment will take up only as much space as is necessary

../_images/compact_segment.png
padded = 'padded'

Segment will add good amount of padding on all sides making it look more spacious

../_images/padded_segment.png
class pdfpug.common.SegmentEmphasis

Enum Segment Emphasis

secondary = 'secondary'

Lesser emphasis than the normal standard

../_images/secondary_segment.png
tertiary = 'tertiary'

Lesser emphasis than secondary elements

../_images/tertiary_segment.png