Printing Implementation
As with other additional interfaces, the EAManagement will indicate whether the plugin includes the printer interface before it can be accessed.
Step 1
Check if service is a part of the EAManagement object:
Copy
public void LoadPrintService()
{
if(this.printerService == null && this.eaManagement is IPrinter)
{
this.printerService = ((IPrinter)this.eaManagement).GetPrinterService();
this.printerService.PrintingEvent += OnPrintEvent;
}
}
Step 2
Check if the service needs to upload a font for the printing process.
Note: For Android specific code:
upload the font to memory and send the full path to the print service.
Copy
private void InitializeFontSelection()
{
string fontFamily = this.printerService.GetFontFamily();
if (fontFamily.Length > 0)
{
fontFamily = "Font/" + fontFamily;
string absoluteFontPath = ExtractFont(fontFamily);
this.printerService.SetAbsolutePath(absoluteFontPath);
}
}
Step 3
A receipt can now be sent to the printer and will receive event updates.
In the end a line feed command is sent to the printer.
Copy
if (this.printerService != null)
{
var connected = await this.printerService.OpenPrinterConnection();
if (connected)
{
return await this.printerService.LineFeed();
}
}
See also