How to create a PDF from a view to be downloaded or shared

I want to create an app, where after the user adds some text and an image to a View, they have the ability to share that View in PDF format as a report.


Is there any simple way that a View can be converted / translated into a PDF without having to manually code all the relevant margines, etc.?


I am a novice developer, so any example code would be appreciated.


Xcode 11.3, Swift 5.


Thanks in advance.

Replies

You have to create the pdf, in a way very similar to printing.


Is it an iOS or MacOS App ?


I once gave some explanations in this post, if that may help:

https://forums.developer.apple.com/message/360883#360883