Using the PDFKit I have created a pdf document within my app. I can successfully show it in a preview and from the preview controller I use the following code to present the user the share actions:
@objc func shareAction(_ sender: UIBarButtonItem)
{
if let data = documentData
{
let vc = UIActivityViewController(activityItems: [data], applicationActivities: [])
present(vc, animated: true, completion: nil
}
}
documentData contains the created pdf document.
When the user selects "Save to Files" the document gets the default name "PDF Document.pdf", which the user can change.
How can I provide a different default filename ?
Not a real answer but rather a workaround that I figured out:
Rather than using the in-memory-copy
dataof the PDF, I can write it to the apps tmp folder:The share action would then look like:
Now the user gets "myfilename.pdf" shown as default filename when he chooses the "Save to Files" action.