Closed StefaniOSApps closed 6 years ago
The string is converted into a text element using the following:
let simpleText = PDFSimpleText(text: pagination.style.format(page: currentPage, total: totalPages))
let textObject = PDFAttributedTextObject(text: simpleText)
I didn't think of the styling. Should we add custom styling properties to the pagination
or just change it to simple text and let it use the footer style?
Ok its works
let simpleText = PDFSimpleText(text: pagination.style.format(page: currentPage, total: totalPages))
let textObject = PDFAttributedTextObject(attributedText: PDFAttributedText(text:NSAttributedString(string: simpleText.text, attributes: [NSAttributedStringKey.font: UIFont(name: "ArialMT", size: 12)])))
Can you pass the font and font size when the page numbers are generated?
looks like
document.pagination = PDFPagination(container: .footerRight,
font: UIFont(name: "ArialMT", size: 12),
style: PDFPaginationStyle.customClosure(
{(page, total) -> String
in return "\(page) | \(total)"
}))
I added the option to pass an a dictionary of attributes. You can now do the following:
document.pagination = PDFPagination(container: .footerRight, style: PDFPaginationStyle.customClosure() { (page, total) -> String in
return "\(page) / \(total)"
}, range: (1, 20), hiddenPages: [3, 7], textAttributes: [
.font: UIFont.boldSystemFont(ofSize: 15.0),
.foregroundColor: UIColor.green
])
how can i set a custom font @ page numbering?
document.setFont(.footerRight, font: UIFont(name: "ArialMT", size: 12.0)!)
is not working