PDFElement

protocol PDFElement

A protocol for elements to create a PDF page from a Song

  • shoudPageBreak(rect:pageRect:) Default implementation

    Check if a PDFElement fits on the current page or if it should break

    Default Implementation

    Check if a PDFElement fits on the current page or if it should break

    Declaration

    Swift

    func shoudPageBreak(rect: CGRect, pageRect: CGRect) -> Bool

    Parameters

    rect

    The available rectangle

    Return Value

    Bool if the page should break

  • draw(rect:calculationOnly:pageRect:) Default implementation

    Draw the PDFElement

    Default Implementation

    Draw the PDFElement

    Declaration

    Swift

    func draw(rect: inout CGRect, calculationOnly: Bool, pageRect: CGRect)

    Parameters

    rect

    The available rectangle

    calculationOnly

    Bool if only the Bounding Rect should be calculated

    pageRect

    The size of the page

  • Calculate the Rect Bounds for an PDFElement array

    Default Implementation

    Calculate the Rect Bounds for an PDFElement array

    Declaration

    Swift

    func calculateDraw(rect: CGRect, elements: [PDFElement], pageRect: CGRect) -> CGRect

    Parameters

    rect

    The available rectangle

    elements

    The PDFElement array

    Return Value

    The available rectangle after the drawing

  • stringToMarkdown(_:) Default implementation

    Convert a string into Markdown

    Default Implementation

    Convert a string into Markdown

    Declaration

    Swift

    func stringToMarkdown(_ text: String) -> NSAttributedString

    Parameters

    text

    The text as String

    Return Value

    The Markdown text as NSAttributedString

  • textPadding Extension method

    The default padding for text

    Note

    Static because it is used in inits

    Declaration

    Swift

    var textPadding: CGFloat
  • textDrawingOptions Extension method

    The default text drawing options

    Declaration

    Swift

    var textDrawingOptions: NSString.DrawingOptions
  • padding(_:) Extension method

    Add padding to a PDFElement

    Declaration

    Swift

    func padding(_ size: CGFloat) -> PDFElement

    Parameters

    size

    The size of the padding

    Return Value

    A modified PDFElement

  • clip(_:) Extension method

    Add a clip shape around a PDFElement

    Declaration

    Swift

    func clip(_ shape: PDFBuild.ShapeStyle) -> PDFElement

    Parameters

    shape

    The style of the shape

    Return Value

    A modified PDFElement