Xamarin.ESCUtils
1.0.1
dotnet add package Xamarin.ESCUtils --version 1.0.1
NuGet\Install-Package Xamarin.ESCUtils -Version 1.0.1
<PackageReference Include="Xamarin.ESCUtils" Version="1.0.1" />
paket add Xamarin.ESCUtils --version 1.0.1
#r "nuget: Xamarin.ESCUtils, 1.0.1"
// Install Xamarin.ESCUtils as a Cake Addin #addin nuget:?package=Xamarin.ESCUtils&version=1.0.1 // Install Xamarin.ESCUtils as a Cake Tool #tool nuget:?package=Xamarin.ESCUtils&version=1.0.1
Xamarin.Forms Android ESC/POS Bluetooth Printer
Add Nuget Package
dotnet add package Xamarin.ESCUtils --version 1.0.1
Features
- 58, 80mm bluetooth esc/pos printer support
- Bold font support
- Justify text right, left, center
- Print QR Code
- Print Barcode
- Turkish Character Supported
The project is completely open source and open to support. Download the Sample Application for details.
The application has been developed for the current Xamarin.Forms android platform.
Android Manifest Permission
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
Note:
** Make sure to allow all permissions from application settings before running the project.
Android Mainactivity.cs
[assembly: Xamarin.Forms.Dependency(typeof(BluetoothService))]
[assembly: Xamarin.Forms.Dependency(typeof(EscUtil))]
namespace SampleApp.Droid
...
Xamarin Forms
Init Implementation
using SampleApp.ViewModels;
using Xamarin.Forms;
using XamarinESCUtils.Platforms.Common;
namespace SampleApp
{
public partial class MainPage : ContentPage
{
private IBlueToothService _blueToothService;
private IEscUtil _escUtil;
public MainPage()
{
InitializeComponent();
_blueToothService = DependencyService.Get<IBlueToothService>();
_escUtil = DependencyService.Get<IEscUtil>();
}
}
}
Get Bluetooth Device List
private List <BluetoothInfo> PrinterList = new List<BluetoothInfo>();
....
...
var list = _blueToothService.GetDeviceList();
foreach (var item in list)
{
PrinterList.Add(item);
}
Selected Bluetooth Printer
return new Command<object>(async (parameter) =>
{
try
{
if (parameter is BluetoothInfo selectedItem)
{
_BluetoothInfo = selectedItem;
}
}
catch (Exception e)
{
await App.Current.MainPage.DisplayToastAsync(e.Message);
throw;
}
});
Send Printer Data
if (_BluetoothInfo != null)
{
_blueToothService.ConnectBlueTooth(_BluetoothInfo.Adress);
_blueToothService.SendData(_escUtil.SetCodeSystem(_escUtil.CodeParse(20))); // utf-8
_blueToothService.SendData(_escUtil.UnderlineOff());
_blueToothService.SendData(_escUtil.BoldOn());
_blueToothService.SendData(_escUtil.AlignCenter());
_blueToothService.SendData(_escUtil.GetTextBytes("Welcome to XamarinForms.ESCUtils"));
_blueToothService.SendData(_escUtil.NextLine(1));
_blueToothService.SendData(_escUtil.BoldOff());
_blueToothService.SendData(_escUtil.AlignLeft());
_blueToothService.SendData(_escUtil.GetTextBytes("This is a test output."));
_blueToothService.SendData(_escUtil.NextLine(1));
_blueToothService.SendData(_escUtil.AlignRight());
_blueToothService.SendData(_escUtil.GetTextBytes("Have a nice day :)"));
_blueToothService.SendData(_escUtil.NextLine(4));
_blueToothService.SendData(_escUtil.AlignCenter());
_blueToothService.SendData(_escUtil.GetPrintQrCode($"https://github.com/bestekarx", 3, 1));
_blueToothService.SendData(_escUtil.NextLine(1));
}
<img src="https://user-images.githubusercontent.com/17545048/227748088-1db14ec9-65f3-40a5-afce-3bb246d0a3c4.jpg" width="400" height="400"> <img src="https://user-images.githubusercontent.com/17545048/227748089-b93d9d18-293d-4dc7-bdbe-1ccfddfe3b4b.jpg" width="400" height="800">
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. monoandroid81 is compatible. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- No dependencies.
-
MonoAndroid 8.1
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Xamarin Forms Bluetooth Printers.