PDFListItem

public class PDFListItem : PDFDocumentObject
extension PDFListItem: CustomDebugStringConvertible
extension PDFListItem: CustomStringConvertible

An item used in a PDFList

By configuring the symbol it is possible to mix the symbols used by list items.

 let document = PDFDocument(format: .a4)

 let items = [
     "Simple text drawing",
     "Advanced text drawing using AttributedString",
     "Multi-layer rendering by simply setting the offset",
     "Fully calculated content sizing",
     "Automatic page wrapping",
     "Customizable pagination",
     "Fully editable header and footer",
     "Simple image positioning and rendering",
     "Image captions"
 ]

 // Simple bullet point list
 let featureList = PDFList(indentations: [
     (pre: 10.0, past: 20.0),
     (pre: 20.0, past: 20.0),
     (pre: 40.0, past: 20.0)
 ])

 // By adding the item first to a list item with the dot symbol, all of them will inherit it
 featureList
     .addItem(PDFListItem(symbol: .dot)
     .addItems(items.map { PDFListItem(content: $0) })
 document.add(list: featureList)

 document.add(space: 20)

 // Numbered list with unusual indentation
 let weirdIndentationList = PDFList(indentations: [
     (pre: 10.0, past: 20.0),
     (pre: 40.0, past: 30.0),
     (pre: 20.0, past: 50.0)
 ])

 weirdIndentationList.addItems(items.enumerated().map { arg in
     PDFListItem(symbol: .numbered(value: "\(arg.offset + 1)"), content: arg.element)
 })
 document.add(list: weirdIndentationList)
  • Weak reference to the parent list item, used to implement the list symbol inherit

    Declaration

    Swift

    public weak var parent: PDFListItem?
  • Text content of this list item, calculated and rendered using PDFSimpleText

    Declaration

    Swift

    public var content: String?
  • List of PDFListItem nested in this instance

    Declaration

    Swift

    public var children: [PDFListItem]?
  • Symbol used for this list item

    Declaration

    Swift

    public var symbol: PDFListItemSymbol
  • Creates a new list item

    Declaration

    Swift

    public init(
        symbol: PDFListItemSymbol = PDFListItemSymbol.inherit,
        content: String? = nil
    )

    Parameters

    symbol

    See symbol for details, defaults to inherit

    content

    See content, defaults to nil

  • Appends the given items to the list of nested items

    Declaration

    Swift

    @discardableResult
    public func addItems(_ items: [PDFListItem]) -> PDFListItem

    Parameters

    items

    Items to append

    Return Value

    Reference to this instance, useful for chaining

  • Adds the given item to the list of nested items

    Declaration

    Swift

    @discardableResult
    public func addItem(_ item: PDFListItem) -> PDFListItem

    Parameters

    item

    Item to add

    Return Value

    Reference to this instance, useful for chaining

  • Sets the content of this list item

    Declaration

    Swift

    @discardableResult
    public func setContent(_ content: String) -> PDFListItem

    Parameters

    content

    See content for details

    Return Value

    Reference to this instance, useful for chaining

Copying

  • nodoc

    Declaration

    Swift

    public var copy: PDFListItem { get }

Equatable

CustomDebugStringConvertible

  • nodoc

    Declaration

    Swift

    public var debugDescription: String { get }

CustomStringConvertible

  • nodoc

    Declaration

    Swift

    public var description: String { get }