Save PDFs to Server in iOS

PSPDFKit automatically saves a modified file-based document to your device’s local storage. You can also customize the autosaving behavior or manually save the changes.

After the document is saved, you can upload the PDF file to your remote server using URLSession’s uploadTask(with:fromFile:) method. The example below shows how to manually save a PDF and upload it to your remote server:

let fileURL = Bundle.main.url(forResource: "Document", withExtension: "pdf")!
let document = Document(url: fileURL)

// Modify the document.
// ...

// Manually save the document.

// Upload the PDF file to your remote server using `URLSession`:
let session = URLSession.shared
let serverURL = URL(string: "")!
var request = URLRequest(url: serverURL)
request.httpMethod = "POST"
let task = session.uploadTask(with: request, fromFile: document.fileURL!)