From 4720ca2d5771326d5eb74ce0c673e9e2bb1f7b58 Mon Sep 17 00:00:00 2001 From: EugeneTes Date: Fri, 16 Jan 2026 16:07:45 +0100 Subject: [PATCH] image printing fix --- Inspectron.Epson/HtmlPrinter.cs | 2 ++ .../PrintServer/PrintServices/EpsonPrintService.cs | 3 +++ .../PrintServer/Printers/TM-T30IIITranslated.cs | 13 +++++++++---- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/Inspectron.Epson/HtmlPrinter.cs b/Inspectron.Epson/HtmlPrinter.cs index 7b28de8..9662888 100644 --- a/Inspectron.Epson/HtmlPrinter.cs +++ b/Inspectron.Epson/HtmlPrinter.cs @@ -566,6 +566,8 @@ public class HtmlPrinter : IEpsonPrinter // Get relative path for HTML var htmlDir = Path.GetDirectoryName(_outputPath) ?? "."; + if(htmlDir=="") + htmlDir="."; var relativeImagePath = Path.GetRelativePath(htmlDir, imagePath).Replace('\\', '/'); // Add to HTML content diff --git a/Inspectron.Epson/PrintServer/PrintServices/EpsonPrintService.cs b/Inspectron.Epson/PrintServer/PrintServices/EpsonPrintService.cs index b99c65a..dc9f83d 100644 --- a/Inspectron.Epson/PrintServer/PrintServices/EpsonPrintService.cs +++ b/Inspectron.Epson/PrintServer/PrintServices/EpsonPrintService.cs @@ -56,6 +56,9 @@ public class EpsonPrintService: IPrintService { // Download logo image var logoFileName = Path.GetFileName(new Uri(job.Document.LogoUrl).LocalPath); + var ext = Path.GetExtension(logoFileName).ToLowerInvariant(); + var encodedName = Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes(logoFileName)); + logoFileName = $"{encodedName}{ext}"; var logoCachePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "logos"); // Ensure logos cache directory exists diff --git a/Inspectron.Epson/PrintServer/Printers/TM-T30IIITranslated.cs b/Inspectron.Epson/PrintServer/Printers/TM-T30IIITranslated.cs index aa3bd73..63e3e7f 100644 --- a/Inspectron.Epson/PrintServer/Printers/TM-T30IIITranslated.cs +++ b/Inspectron.Epson/PrintServer/Printers/TM-T30IIITranslated.cs @@ -1,7 +1,8 @@ -using System.Text.Json; -using Inspectron.Epson.PrintServer.Printers.Utils; +using Inspectron.Epson.PrintServer.Printers.Utils; using Inspectron.Epson.PrintServer.Printers.Utils.FinalRecipe; using Inspectron.Epson.PrintServer.PrintServices; +using System.Reflection; +using System.Text.Json; using FinalReceipt = Inspectron.Epson.PrintServer.Printers.Utils.FinalRecipe.FinalReceipt; namespace Inspectron.Epson.PrintServer.Printers; @@ -22,9 +23,14 @@ public class TM_T30IIITranslated:IPrinter public async Task PrintImageAsync(string path) { + await _printer.FeedLinesAsync(1); await _printer.SetAbsolutePrintPosition(100); - await _printer.LoadImageAsync(Path.Combine("logos", path), 384); + await _printer.LoadImageAsync(path, 384); await Task.Delay(100); + if (_printer is HtmlPrinter) + { + await _printer.PrintLoadedImage(); + } await _printer.FeedLinesAsync(1); await _printer.SetAbsolutePrintPosition(0); } @@ -49,7 +55,6 @@ public class TM_T30IIITranslated:IPrinter } var converter = new ReceiptConverter(lineWidth: 48, bigFontLineWidth: 24); var printCommands = converter.ConvertToPrintCommands(receipt); - await _printer.FeedLinesAsync(1); await _printer.SetCustomLineSpacing(22); foreach (var command in printCommands)