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 Xamarin Scanner SDK.

Xamarin PDF Creation

Xamarin Text Detection

Xamarin Data Extraction

Supported file types

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

Initialization

Initialize the Docutain Xamarin 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 Document class.

using Docutain.SDK.Xamarin.Forms;

if(Document.LoadFile(filePath))
{
//generate a PDF from the imported file
var destinationPath = FileSystem.CacheDirectory + "/TestPDF.pdf";
var pdfFile = Document.WritePDF(destinationPath);
if(pdfFile != null)
{
//do something with the generated pdf file
}
else
{
//error occured
var error = DocutainSDK.LastError;
}
}
else
{
//error occured
var error = DocutainSDK.LastError;
}

If you want to create a searchable PDF (includes text), or get the detected data or text of the imported file, use the DocumentDataReader class.

using Docutain.SDK.Xamarin.Forms;

if(DocumentDataReader.LoadFile(filePath))
{
//generate a searchable PDF from the imported file
var destinationPath = FileSystem.CacheDirectory + "/TestPDF.pdf";
var pdfFile = Document.WritePDF(destinationPath);
//get the detected text
var text = DocumentDataReader.GetText();
//get the detected data
var data = DocumentDataReader.Analyze();
}
else
{
//error occured
var error = DocutainSDK.LastError;
}