4

I am doing this code and stuck to make the pdf with survey result. Can anyone help to make an pdf file of result of survey task. Thanks in advance.

 func taskViewController(taskViewController: ORKTaskViewController,
    didFinishWithReason reason: ORKTaskViewControllerFinishReason,
    error: NSError?) {
        let taskResult = taskViewController.result
        if reason  == ORKTaskViewControllerFinishReason.Completed
        {

           // var data = NSKeyedArchiver.archivedDataWithRootObject(taskViewController.result)
            //here how can i get the text of steps and results?
            NSUserDefaults.standardUserDefaults().setBool(true, forKey: kSurveyCompleted)
            NSUserDefaults.standardUserDefaults().synchronize()
        }
        if reason  == ORKTaskViewControllerFinishReason.Discarded
        {

            NSUserDefaults.standardUserDefaults().setBool(false, forKey: kSurveyCompleted)
            NSUserDefaults.standardUserDefaults().synchronize()
        }

}

Nakul Sharma
  • 600
  • 1
  • 16
  • 23

1 Answers1

1

You can use pdf library like this: https://github.com/techprimate/TPPDF It's easy to create a table inside the PDF and fill it with field/value row. If you use iOS 11, there is PDFKit "inside".