PDF Creation
The Docutain SDK for Xamarin 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 the Docutain Xamarin SDK as described here.
Create a PDF
- Xamarin.Forms
- Xamarin.Android
- Xamarin.iOS
using Docutain.SDK.Xamarin.Forms;
// ...
// scan or import 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;
}
tip
You can specify the PDF page format by providing the appropriate value
var pdfFile = Document.WritePDF(destinationPath, true, PDFPageFormat.A4);
using Docutain.SDK.Xamarin.Android;
// ...
// scan or import file
// ...
var destinationPath = FileSystem.CacheDirectory + "/TestPDF.pdf";
var pdfFile = Document.WritePDF(new Java.IO.File(destinationPath));
if(pdfFile != null)
{
//do something with the generated pdf file
}
else
{
//error occured
var error = DocutainSDK.LastError;
}
tip
You can specify the PDF page format by providing the appropriate value
var pdfFile = Document.WritePDF(new Java.IO.File(destinationPath), true, PDFPageFormat.A4);
using Docutain.SDK.Xamarin.iOS;
// ...
// scan or import file
// ...
var paths = NSFileManager.DefaultManager.GetUrls(NSSearchPathDirectory.DocumentDirectory, NSSearchPathDomain.User);
var destinationPath = paths[0];
var pdfFile = Document.WritePDF(destinationPath, "TestPDF");
if(pdfFile != null)
{
//do something with the generated pdf file
}
else
{
//error occured
var error = DocutainSDK.LastError;
}
tip
You can specify the PDF page format by providing the appropriate value
var pdfFile = Document.WritePDF(destinationPath, "TestPDF", true, PDFPageFormat.A4);