PDFDocument
public class PDFDocument : CustomStringConvertible
This object holds the information about the document and also all PDF objects.
This is the main structure to create new documents. It is the base for the PDFGenerator to generate the PDF output
-
Holds all layout information
Declaration
Swift
public var layout: PDFPageLayout -
Holds all document information
Declaration
Swift
public var info: PDFInfo -
Holds all pagination information
Declaration
Swift
public var pagination: PDFPagination -
Holds strong references to all text styles
Declaration
Swift
public var styles: [PDFTextStyle] -
Configuration for document/paper background
Declaration
Swift
public var background: PDFDocumentBackground
-
Creates a new document with the given
layoutDeclaration
Swift
public init(layout: PDFPageLayout)Parameters
layoutLayout information for document
-
Creates a new document with a predefined
PDFPageFormatDeclaration
Swift
public init(format: PDFPageFormat)Parameters
layoutPredefined page formats
-
Adds a empty space in the given container, between the previous and the next element
Declaration
Swift
public func add(_ container: PDFContainer = PDFContainer.contentLeft, space: CGFloat)Parameters
containerContainer where the space will be set
spaceSpace distance in points
-
Adds a horizontal line spearator to the given container. The line starts at the left indentation and ends at the right indentation. Customize by adjusting parameter
style.Declaration
Swift
public func addLineSeparator(_ container: PDFContainer = PDFContainer.contentLeft, style: PDFLineStyle)Parameters
containerContainer where the space will be set
styleStyle of line
-
Adds an image to the given container.
Declaration
Swift
public func add(_ container: PDFContainer = PDFContainer.contentLeft, image: PDFImage)Parameters
containerContainer where the space will be set
imageImage object
-
Adds an image row to the given container. This image row will fill the full available width between left indentation and right indentation.
Declaration
Swift
public func add(_ container: PDFContainer = PDFContainer.contentLeft, imagesInRow images: [PDFImage], spacing: CGFloat = 5.0)Parameters
containerContainer where the space will be set
imagesArray of images, from left to right
spacingHorizontal distance between images
-
Shorthand public function to add a String text to the given container
Declaration
Swift
public func add(_ container: PDFContainer = PDFContainer.contentLeft, text: String, lineSpacing: CGFloat = 1.0)Parameters
containerContainer where the space will be set
imagesArray of images, from left to right
spacingHorizontal distance between images
-
Adds an text object to the given container
Declaration
Swift
public func add(_ container: PDFContainer = PDFContainer.contentLeft, textObject: PDFSimpleText)Parameters
containerContainer where the space will be set
textObjectSimple text object
-
Shorthand public function to add a attributed String text to the given container
Declaration
Swift
public func add(_ container: PDFContainer = PDFContainer.contentLeft, attributedText: NSAttributedString)Parameters
containerContainer where the space will be set
textAn attributed string
-
Adds an attributed text object to the given container
Declaration
Swift
public func add(_ container: PDFContainer = PDFContainer.contentLeft, attributedTextObject: PDFAttributedText)Parameters
containerContainer where the space will be set
textObjectAttributed text object
-
Set font in given container. This text color will be used when adding a
PDFSimpleTextDeclaration
Swift
public func set(_ container: PDFContainer = PDFContainer.contentLeft, font: Font)Parameters
containerContainer where the font will be set
fontFont of text
-
Reset text color in given container to default.
Declaration
Swift
public func resetFont(_ container: PDFContainer = PDFContainer.contentLeft)Parameters
containerContainer whose text color will be reset
-
Set text color in given container. This text color will be used when adding a
PDFSimpleTextDeclaration
Swift
public func set(_ container: PDFContainer = PDFContainer.contentLeft, textColor: Color)Parameters
containerContainer where the text color will be set
colorColor of the text
-
Reset text color in given container to default.
Declaration
Swift
public func resetTextColor(_ container: PDFContainer = PDFContainer.contentLeft)Parameters
containerContainer whose text color will be reset
-
Adds a table object to the document in the defined container
Declaration
Swift
public func add(_ container: PDFContainer = PDFContainer.contentLeft, table: PDFTable)Parameters
containerContainer where the table color will be added
colorTable to add to document
-
Adds a list object to the document in the defined container
Declaration
Swift
public func add(_ container: PDFContainer = PDFContainer.contentLeft, list: PDFList)Parameters
containerContainer where the text color will be set
colorColor of the text
-
Adds a section object to the document
Declaration
Swift
public func add(section: PDFSection)Parameters
sectionSection
-
Change the indentation in a container, use the parameter
leftto define from which side.Declaration
Swift
public func set(_ container: PDFContainer = PDFContainer.contentLeft, indent: CGFloat, left: Bool)Parameters
containerContainer whose indentation should be changed
indentPoints from the side
leftIf
truethen the left side indentation is set, else the right indentation is set -
Change the absolute top offset in a container
Declaration
Swift
public func set(_ container: PDFContainer = PDFContainer.contentLeft, absoluteOffset: CGFloat)Parameters
containerContainer whose current absoilute offset should be changed
absoluteOffsetPoints from the top
-
Creates a new page by adding a page break object
Declaration
Swift
public func createNewPage() -
Adds a new style to the list of known styles
Declaration
Swift
public func add(style: PDFTextStyle) -> PDFTextStyleParameters
styleDefinition of the text style
-
Adds a table of content
Declaration
Swift
public func add(tableOfContent: PDFTableOfContent)Parameters
tableOfContentOptions of the table of content
-
Starts a column section with automatic wrapping
Declaration
Swift
public func enable(_ container: PDFContainer = PDFContainer.contentLeft, columns: Int, widths: [CGFloat], spacings: [CGFloat]) -
Finishes a column section
Declaration
Swift
public func disableColumns(_ container: PDFContainer = PDFContainer.contentLeft, addPageBreak: Bool = true) -
Adds a group
Declaration
Swift
public func add(_ container: PDFContainer = PDFContainer.contentLeft, group: PDFGroup)Parameters
containerContainer where the group will be added
groupInstance of
PDFGroupto add -
Replaces current master group with the given one.
See
PDFDocument/masterGroupfor details.Declaration
Swift
public func set(master group: PDFMasterGroup)Parameters
masterInstance of
PDFMasterGroup, -
Adds an external document to the document
Declaration
Swift
public func add(externalDocument doc: PDFExternalDocument)Parameters
docInstance of
PDFExternalDocument
View on GitHub
Install in Dash