PDFDocument
public class PDFDocument : PDFJSONSerializable
The main class users interact with. This object holds the information about the document and also all PDF objects.
It is possible to create a JSON representation using the PDFJSONSerializable
protocol.
-
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
-
Creates a new document with the given layout
Declaration
Swift
public init(layout: PDFPageLayout)
Parameters
layout
Layout information for document
-
Creates a new document with a predefined
PDFPageFormat
Declaration
Swift
public init(format: PDFPageFormat)
Parameters
layout
Predefined page formats
-
Adds a empty space in the given container, between the previous and the next element
Declaration
Swift
public func addSpace(_ container: PDFContainer = PDFContainer.contentLeft, space: CGFloat)
Parameters
container
Container where the space will be set, defaults to
PDFContainer.contentLeft
space
Space 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
container
Container where the space will be set, defaults to
PDFContainer.contentLeft
style
Style of line
-
Adds an image to the given container.
Declaration
Swift
public func addImage(_ container: PDFContainer = PDFContainer.contentLeft, image: PDFImage)
Parameters
container
Container where the space will be set, defaults to
PDFContainer.contentLeft
image
Image 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 addImagesInRow(_ container: PDFContainer = PDFContainer.contentLeft, images: [PDFImage], spacing: CGFloat = 5.0)
Parameters
container
Container where the space will be set, defaults to
PDFContainer.contentLeft
images
Array of images, from left to right
spacing
Horizontal distance between images
-
Shorthand function to add a String text to the given container
Declaration
Swift
public func addText(_ container: PDFContainer = PDFContainer.contentLeft, text: String, lineSpacing: CGFloat = 1.0)
Parameters
container
Container where the space will be set, defaults to
PDFContainer.contentLeft
images
Array of images, from left to right
spacing
Horizontal distance between images
-
Adds an text object to the given container
Declaration
Swift
public func addText(_ container: PDFContainer = PDFContainer.contentLeft, textObject: PDFSimpleText)
Parameters
container
Container where the space will be set, defaults to
PDFContainer.contentLeft
textObject
Simple text object
-
Shorthand function to add a attributed String text to the given container
Declaration
Swift
public func addAttributedText(_ container: PDFContainer = PDFContainer.contentLeft, text: NSAttributedString)
Parameters
container
Container where the space will be set, defaults to
PDFContainer.contentLeft
text
An attributed string
-
Adds an attributed text object to the given container
Declaration
Swift
public func addAttributedText(_ container: PDFContainer = PDFContainer.contentLeft, textObject: PDFAttributedText)
Parameters
container
Container where the space will be set, defaults to
PDFContainer.contentLeft
textObject
Attributed text object
-
Set font in given container. This text color will be used when adding a
PDFSimpleText
Declaration
Swift
public func setFont(_ container: PDFContainer = PDFContainer.contentLeft, font: UIFont)
Parameters
container
Container where the font will be set, defaults to
PDFContainer.contentLeft
font
Font of text
-
Reset text color in given container to default.
Declaration
Swift
public func resetFont(_ container: PDFContainer = PDFContainer.contentLeft)
Parameters
container
Container whose text color will be reset, defaults to
PDFContainer.contentLeft
-
Set text color in given container. This text color will be used when adding a
PDFSimpleText
Declaration
Swift
public func setTextColor(_ container: PDFContainer = PDFContainer.contentLeft, color: UIColor)
Parameters
container
Container where the text color will be set, defaults to
PDFContainer.contentLeft
color
Color of the text
-
Reset text color in given container to default.
Declaration
Swift
public func resetTextColor(_ container: PDFContainer = PDFContainer.contentLeft)
Parameters
container
Container whose text color will be reset, defaults to
PDFContainer.contentLeft
-
Adds a table object to the document in the defined container
Declaration
Swift
public func addTable(_ container: PDFContainer = PDFContainer.contentLeft, table: PDFTable)
-
Adds a list object to the document in the defined container
Declaration
Swift
public func addList(_ container: PDFContainer = PDFContainer.contentLeft, list: PDFList)
-
Adds a section object to the document
Declaration
Swift
public func addSection(_ section: PDFSection)
-
Change the indentation in a container, use the parameter
left
to define from which side.Declaration
Swift
public func setIndentation(_ container: PDFContainer = PDFContainer.contentLeft, indent: CGFloat, left: Bool)
Parameters
container
Container whose indentation should be changed, defaults to
PDFContainer.contentLeft
indent
Points from the side
left
If
true
then the left side indentation is set, else the right indentation is set -
Change the absolute top offset in a container
Declaration
Swift
public func setAbsoluteOffset(_ container: PDFContainer = PDFContainer.contentLeft, offset: CGFloat)
Parameters
container
Container whose current absoilute offset should be changed, defaults to
PDFContainer.contentLeft
offset
Points from the top
-
Creates a new page
Declaration
Swift
public func createNewPage()