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

How can we send this spreadsheet to printer? #2

Open
syedqamara opened this issue Apr 16, 2016 · 2 comments
Open

How can we send this spreadsheet to printer? #2

syedqamara opened this issue Apr 16, 2016 · 2 comments

Comments

@syedqamara
Copy link

I have create a spread sheet view and want to print this using UIActivityController but i don't know how to do that?

@Moody3939
Copy link

Try this in your view controller. It will allow you're user to print the spreadsheet (as a PDF), send it through email and stuff like that.

let pdfData = NSMutableData()

UIGraphicsBeginPDFContextToData(pdfData, view.frame, nil)

UIGraphicsBeginPDFPage()

guard let pdfContext = UIGraphicsGetCurrentContext() else { return }

view.layer.renderInContext(pdfContext)

UIGraphicsEndPDFContext()

let controller = UIActivityViewController(activityItems: [pdfData], applicationActivities: nil)

controller.popoverPresentationController?.sourceView = self.view

presentViewController(controller, animated: true, completion: nil)

Apologies for it being in Swift. I'm no good at Obj-C

@syedqamara
Copy link
Author

Thanks for your code. I will appreciate your effort that you have made for me.
I'll translate it into Obj-C.
Once Again Thank you.

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

2 participants