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 Flutter Scanner SDK.
Supported file types
- BMP
- JPG
- JPEG
- PNG
- TIFF
- HEIC
Initialization
Initialize the Docutain Flutter SDK as described here.
File Import
If your simple goal is to import image files and generate a non-searchable (includes no text) PDF file from it, use the DocutainSdkDocument
class.
try {
bool rcImport =
await DocutainSdkDocument.loadFile(filePath);
if (!rcImport) {
//an error occured
var error = await DocutainSdk.getLastError();
} else {
//generate a PDF from the imported file
File? pdfFile = await DocutainSdkDocument.writePDF(
path, 'SamplePDF');
}
} on PlatformException catch (exception) {
if (exception.code == "SecurityException") {
//file is encrypted and password was wrong or empty
//provide the correct password in the loadFile() method
}
}
If you want to create a searchable PDF (includes text), or get the detected data or text of the imported file, use the DocutainSdkDocumentDataReader
class.
try {
bool rcImport =
await DocutainSdkDocumentDataReader.loadFile(filePath);
if (!rcImport) {
//an error occured
var error = await DocutainSdk.getLastError();
} else {
//generate a searchable PDF from the imported file
File? pdfFile = await DocutainSdkDocument.writePDF(
path, 'SamplePDF');
//get the detected text
final text =
await DocutainSdkDocumentDataReader.getText();
//get the detected data
final data =
await DocutainSdkDocumentDataReader.analyze();
}
} on PlatformException catch (exception) {
if (exception.code == "SecurityException") {
//file is encrypted and password was wrong or empty
//provide the correct password in the loadFile() method
}
}