You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

26 lines
729 B
Swift

//
// PDFManager.swift
// surveys-example
//
// Created by Juan David López Regalado on 27/06/24.
//
import Foundation
import ResearchKit
guard let stepResult = taskViewController.result.result(forIdentifier: "WebViewStepIdentifier") as? ORKStepResult else {
return
}
if let webViewStepResult = stepResult.results?.first as? ORKWebViewStepResult, let html = webViewStepResult.htmlWithSignature {
let htmlFormatter = ORKHTMLPDFWriter()
htmlFormatter.writePDF(fromHTML: html) { data, error in
let pdfURL = FileManager.default.temporaryDirectory
.appendingPathComponent("consentTask")
.appendingPathExtension("pdf")
try? data.write(to: pdfURL)
}
}