Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Any way to change font SIZE? #36

Closed
caldwbr opened this issue Jan 20, 2019 · 1 comment
Closed

Any way to change font SIZE? #36

caldwbr opened this issue Jan 20, 2019 · 1 comment

Comments

@caldwbr
Copy link

caldwbr commented Jan 20, 2019

I'd like the title of my pdf to be a larger font - is there any way to achieve this?

@caldwbr
Copy link
Author

caldwbr commented Jan 20, 2019

I figured it out. You must use NSAttributedString, as below for example:

    let A4paperSize = CGSize(width: 595, height: 842)
    let pdf = SimplePDF(pageSize: A4paperSize, pageMargin: 20.0)
    pdf.setContentAlignment(.center)
    pdf.addImage(UIImage(named: "bizzybooksbee")!)
    let titleIncomeStatement = String(selectedYear) + " Income Statement"
    let font = UIFont.systemFont(ofSize: 36)
    let paragraphStyle = NSMutableParagraphStyle()
    paragraphStyle.alignment = .center
    let titleAttributes: [NSAttributedStringKey: Any] = [
        .font: font,
        .paragraphStyle: paragraphStyle
    ]
    let attributedTitleIncomeStatement = NSAttributedString(string: titleIncomeStatement, attributes: titleAttributes)
    pdf.addAttributedText(attributedTitleIncomeStatement)
    pdf.addText("Created with Bizzy Books")
    pdf.addLineSeparator()
    pdf.setContentAlignment(.left)
    pdf.addText("Income: " + String(income))

@caldwbr caldwbr closed this as completed Jan 20, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant