I created a pdf file with pictures on three pages.
And now I am trying to add UISimpleTextPrintFormatter on each page
But can only add to the first page
addPrintFormatter(formatter, startingAtPageAtIndex: 0)
When I change startingAtPageAtIndex: 0 to 1, Xcode generates next error:
Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[__NSArrayM objectAtIndex:]: index 1 beyond bounds [0 .. 0]'
It seems like my text sees only the first page.
Please, help
This is my code:
class PrintPageRenderer: UIPrintPageRenderer {
let authorName: NSString
let data: Data
init(authorName: String, data: Data) {
self.authorName = authorName
self.data = data
super.init()
self.headerHeight = 0.5 * POINTS_PER_INCH
let formatter = UISimpleTextPrintFormatter(text: "My Text")
formatter.perPageContentInsets = UIEdgeInsets(top: POINTS_PER_INCH, left: POINTS_PER_INCH,
bottom: POINTS_PER_INCH, right: POINTS_PER_INCH * 3.5)
addPrintFormatter(formatter, startingAtPageAtIndex: 1)
}