Skip to main content

File Import

You can import images or PDF files into Docutain and do a bunch of things with them.

Windows PDF Creation

Windows Text Detection

Windows Data Extraction


Besides PDF files, the following image file types are currently supported:

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

The Docutain Windows SDK needs to be initialized prior to using any functionality of it as described here.


In order to import a file, use the Document.Load() method.

The following shows an example importing a file that got picked from an OpenFileDialog and generating a PDF out of it:

//open file dialog to pick a file
using (OpenFileDialog ofd = new OpenFileDialog())
{
ofd.Filter = "Supported files (*.PDF; *.JPG; *.JPEG; *.PNG; *.TIF; *.TIFF; *.HEIC)|*.PDF; *.JPG; *.JPEG; *.PNG; *.TIF; *.TIFF; *.HEIC";
ofd.Filter += "|PDF files (*.PDF)|*.PDF|JPG files (*.JPG; *.JPEG)|*.JPG; *.JPEG|PNG files (*.PNG)|*.PNG|TIF files (*.TIF; *.TIFF)|*.TIF; *.TIFF|HEIC files (*.HEIC)|*.HEIC";
ofd.FilterIndex = 1;
ofd.RestoreDirectory = false;

if (ofd.ShowDialog() == DialogResult.OK)
{
//load a document from selected file path
if (!await Docutain.SDK.Windows.Document.Load(ofd.FileName))
{
string error = DocutainSDK.GetLastError();
...
return;
}
//generate PDF from currently loaded document and save it to the selected path
string filePathGeneratedPDF = Docutain.SDK.Windows.Document.WritePDF(filePathPDF, false, Docutain.SDK.Windows.Document.PDFPageFormat.FitToPages);
if (string.IsNullOrEmpty(filePathGeneratedPDF))
{
string error = DocutainSDK.GetLastError();
...
}
}
}

Sample for getting the detected text and the analyzed data:

if (await Docutain.SDK.Windows.Document.Load(file))
{
string text = Document.Text(-1);
string documentData = Document.Analyze();
}
else
{
string error = DocutainSDK.GetLastError();
}
info

You can also load a file from a Stream or a byte[].