PDFSection
public class PDFSection : PDFDocumentObject
A multi-column section is a nested container.
Creating the section with an amount of columns and their relative width, add objects to each column and then add the whole section to the document.
When adding an object to the section column, you use the Array subscript section.columns[0]
.
You are able to give it an alignment as the first parameter, similar to the PDFContainer
but only with .left
, .center
and .right
as it is not possible to add a section to the header or footer containers.
Use enable(_:columns:widths:spacings:)
for details on how to enable multi-columns with automatic text wrapping,
allowing to split a page into multiple columns and fill it up starting at the left.
Example:
let section = PDFSection(columnWidths: [0.3, 0.4, 0.3])
section.columns[0].addText(.right, text: "right")
section.columns[1].addText(.left, text: "left")
section.columns[2].addText(.center, text: "center")
document.add(section: section)
Attention:
Do not add a PDFSection
multiple times to a PDFDocument
, as they hold some internal state, which will lead to collisions and unpredictable
framing calculations.
-
List of section columns.
Declaration
Swift
public private(set) var columns: [PDFSectionColumn] { get }
-
Horizontal margin between columns in points.
Declaration
Swift
public var columnMargin: CGFloat
-
Creates a new section with columns of the given relative widths.
Declaration
Swift
public convenience init(columnWidths: [CGFloat])
Parameters
columnWidth
Relative column widths. Values are between 0.0 and 1.0 and should sum up to 1.0.
-
Creates a new section with the given columns.
Declaration
Swift
public init(_ columns: [PDFSectionColumn])
Parameters
columns
Preconfigured section columns