Skip to main content

PDF Creation

The Docutain SDK for iOS comes with the ability to create searchable and non-searchable PDF documents either from a scanned document with Docutain's Scanner SDK or imported file.

Initialization

Initialize Docutain's iOS SDK as described here.

Create a PDF

In order to create a PDF document, first a document needs to be scanned with Docutain's Scanner SDK or imported.

After that you can generate the PDF document.

tip

Generating the PDF is blazingly fast, but it may still take some time depending on the number of pages and the performance of the device. To avoid blocking the UI thread, we recommend running the PDF creation in a background thread.

import DocutainSdk

//...
//scan or import file
//...

if let pdfUrl = Document.writePDF(fileUrl: path, fileName: "Test"){
//do something with the generated pdf file
} else{
//error occured
let error = DocutainSDK.getLastError()
}

PDF Page Format

You can specify the PDF page format by providing the appropriate value:

let pdfUrl = Document.writePDF(fileUrl: path, fileName: "Test", pageFormat: .A4)

PDF Compression

You can specify a maximum file size for the PDF. If the uncompressed PDF would exceed the maximum file size you have set, it will get compressed until the maximum file size is reached. Please be aware, that if the PDF gets compressed, the quality decreases and the PDF generation will take longer. In order to set a maximum file size, set the maxSizeKB parameter to your desired size. It needs to be set in KB, so if you want 10MB for example, set it to 10 * 1024. Please check below example:

let pdfUrl = Document.writePDF(fileUrl: path, fileName: "Test", maxSizeKB: 10 * 1024)