How to print images with Xamarin bluetooth

Paolo Mossa 161 Reputation points
2024-03-25T10:31:41.3466667+00:00

Hi to All. I need to print with xam.plugin.bluetooth package a text but the printer doesn't recognize the new line character. In graphics mode I've found the command to feed a new line but for text not. If it is possible can you give me the way to control the dimensions of the characters?

below the parser that format the text:

if (bluetooth.IsAvailable)

				{

					Supporto supporto1 = new Supporto();

					var lista = await bluetooth.GetPairedDevices();

					device = lista.FirstOrDefault(f => f.Name == supporto1.Get_Blue());

					await device.Connect();

					

					string intestaz = "AstroSmart " + supporto1.Getnome1() + " " + supporto1.Getcognome1();

					string Righefile = editor1.Text;

					string hh = ""; string finale = "";

					int r = 0;int t=0 ; int finer = -999;						

					if (!device.IsWriting)

						while (true)

						{

							while (t < Convert.ToInt16(supporto1.Get_Colonne()))

							{

								if (r + t >= Righefile.Count())

									goto lp1;

								if (Righefile[t + r] == '\n')

									hh += " ";

								else

									hh += Righefile[t + r];

															

								if (" \\|!\"£$%&/()=?^'[]{}#@°-.,_:;><'".Contains(Righefile[t + r]))

									finer = t;

								if (t == Convert.ToInt16(supporto1.Get_Colonne())-1)

								{

									if (finer > 0)

									{

										for (int ff = 0; ff < finer; ff++)

											finale += Righefile[r++];

										finale += "\n";

										finer = -999;

									}

									else

									{

										finale += hh+"\n";

										r += hh.Length;

									}

									hh = "";

									t = 0;

									break;

								}

								else

									t++;

							}

					

							t = 0;	

		

						}

					lp1:

					finale += hh;

					await device.Write(intestaz + Environment.NewLine+ finale);

					await device.Disconnect();

				}

			}

		
Xamarin
Xamarin
A Microsoft open-source app platform for building Android and iOS apps with .NET and C#.
5,366 questions
C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
11,110 questions
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.