Closed vishnuravi closed 8 months ago
@vishnuravi Thank you for sharing this feature request!
Here is some additional context for anyone who would like to implement this feature, here are some hints on how
The consent view in this module already exposes the PKDrawing
of the signature view as a private property that can be used to obtain the image representation of the drawing and then inserted in a PDF: https://github.com/StanfordSpezi/SpeziOnboarding/blob/main/Sources/SpeziOnboarding/ConsentView.swift#L52.
The size of the view can be retrieved using the following view preference: https://github.com/StanfordSpezi/SpeziViews/blob/main/Sources/SpeziViews/Views/Drawing/CanvasView.swift#L121.
We can imagine multiple different mechanisms to do so
The second possibility might be a bit more challenging as we need to create a PDF from a SwiftUI view of undetermined size, but several new APIs might be able to help us with that, e.g.,: https://www.hackingwithswift.com/quick-start/swiftui/how-to-render-a-swiftui-view-to-a-pdf
Please use the comments under this issue to discuss the best approach to addressing this issue, and feel free to share some first drafts of a PR for discussion if you want to address this issue.
@vishnuravi @philippzagar I am not sure what the current state with this issue is. Feel free to provide an update how things are going here?
@vishnuravi I would like to clean up the following branch in the Spezi Module to ensure that we moved everything to different modules and prioritize important issues: https://github.com/StanfordSpezi/Spezi/tree/create-pdf. Can you move that over here for a draft PR and/or something that you or @philippzagar can work on?
In addition to that, I would suggest that we drop any ideas of a closure, based approach but rather focus on adding a Standard
constraint that must be present if the Consent View is used to export a PDF.
One additional link that I would like to share https://developer.apple.com/documentation/swiftui/imagerenderer#Rendering-to-a-PDF-context, that API might be very useful here.
In addition to that, I would suggest to investigate
We can then add an additional PDF page with the signature and names using a custom view that we render in a PDF and append it at the end using https://developer.apple.com/documentation/swiftui/imagerenderer#Rendering-to-a-PDF-context.
I deleted the create-pdf
branch on the https://github.com/StanfordSpezi/Spezi repository. The approach I was trying there doesn't work. I would start over with this new approach you have suggested @PSchmiedmayer . @philippzagar are you interested in trying this out?
Sorry for the late response, I was sick the last couple of days.
Thanks @PSchmiedmayer for adding lots of additional resources that may be useful! 🚀
Also, thanks for clarifying to not use a closure-based approach but to add the exported file to the Standard
👍
@vishnuravi I already built an implementation that enables the export of MD onboarding texts including signature. However, I'm not yet happy with the API design there, will look at that closer this and next week. The goal is to merge a first implementation (probably only for MD at first) next week. Sadly, the SwiftUI ImageRenderer has quite a lot of limitations actually rendering larger/more complex SwiftUI views, therefore a UIKit-based approach (as @PSchmiedmayer outlined) might be the right approach here. Will investigate that.
Sounds great; thank you @philippzagar! 👍
Problem
Currently, although the user can view and sign a consent document, there is no way to save or export this document.
Solution
Add functionality to save and/or export a signed consent document, ideally in the form of a PDF.
Code of Conduct