Skip to main content

File Import

You can import images or PDF files into Docutain and do a bunch of things with them, same as after a successful document scan with Docutain's iOS Scanner SDK.

iOS PDF Creation

iOS Text Detection

iOS Data Extraction

Supported file types

  • PDF
  • BMP
  • JPG
  • JPEG
  • PNG
  • TIFF
  • HEIC

Initialization

Initialize the Docutain iOS SDK as described here.

File Import

Depending on what you want to achieve, you either need to use the Document class or the DocumentDataReader class.

If your simple goal is to import image files and generate a (non-searchable) PDF file from it, use the Document class. For everything else, use the DocumentDataReader class.

Load an image file and generate a non-searchable PDF:

import DocutainSdk

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

If you want to create searchable (including text) PDF files, or get the text of the loaded document or get the analyzed data from it, you need to use the DocumentDataReader class.

import DocutainSdk

if(DocumentDataReader.loadFile(fileUrl: url)){
let text = DocumentDataReader.getText()
let documentData = DocumentDataReader.analyze()
if let pdfUrl = Document.writePDF(fileUrl: path, fileName: "Test"){
//do something with the generated pdf file
} else{
//error occured
let error = DocutainSDK.getLastError()
let errorCode = DocutainSDK.getLastErrorCode()
if(errorCode == .passwordNotValid){
//the file is encrypted and no password or the wrong password was entered
//you can provide the password in the DocumentDataReader.loadFile() method.
}
}
} else{
//error occured
let error = DocutainSDK.getLastError()
}