image printing fix

This commit is contained in:
EugeneTes
2026-01-16 16:07:45 +01:00
parent 5229cac987
commit 4720ca2d57
3 changed files with 14 additions and 4 deletions

View File

@@ -566,6 +566,8 @@ public class HtmlPrinter : IEpsonPrinter
// Get relative path for HTML // Get relative path for HTML
var htmlDir = Path.GetDirectoryName(_outputPath) ?? "."; var htmlDir = Path.GetDirectoryName(_outputPath) ?? ".";
if(htmlDir=="")
htmlDir=".";
var relativeImagePath = Path.GetRelativePath(htmlDir, imagePath).Replace('\\', '/'); var relativeImagePath = Path.GetRelativePath(htmlDir, imagePath).Replace('\\', '/');
// Add to HTML content // Add to HTML content

View File

@@ -56,6 +56,9 @@ public class EpsonPrintService: IPrintService
{ {
// Download logo image // Download logo image
var logoFileName = Path.GetFileName(new Uri(job.Document.LogoUrl).LocalPath); 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"); var logoCachePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "logos");
// Ensure logos cache directory exists // Ensure logos cache directory exists

View File

@@ -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.Printers.Utils.FinalRecipe;
using Inspectron.Epson.PrintServer.PrintServices; using Inspectron.Epson.PrintServer.PrintServices;
using System.Reflection;
using System.Text.Json;
using FinalReceipt = Inspectron.Epson.PrintServer.Printers.Utils.FinalRecipe.FinalReceipt; using FinalReceipt = Inspectron.Epson.PrintServer.Printers.Utils.FinalRecipe.FinalReceipt;
namespace Inspectron.Epson.PrintServer.Printers; namespace Inspectron.Epson.PrintServer.Printers;
@@ -22,9 +23,14 @@ public class TM_T30IIITranslated:IPrinter
public async Task PrintImageAsync(string path) public async Task PrintImageAsync(string path)
{ {
await _printer.FeedLinesAsync(1);
await _printer.SetAbsolutePrintPosition(100); await _printer.SetAbsolutePrintPosition(100);
await _printer.LoadImageAsync(Path.Combine("logos", path), 384); await _printer.LoadImageAsync(path, 384);
await Task.Delay(100); await Task.Delay(100);
if (_printer is HtmlPrinter)
{
await _printer.PrintLoadedImage();
}
await _printer.FeedLinesAsync(1); await _printer.FeedLinesAsync(1);
await _printer.SetAbsolutePrintPosition(0); await _printer.SetAbsolutePrintPosition(0);
} }
@@ -49,7 +55,6 @@ public class TM_T30IIITranslated:IPrinter
} }
var converter = new ReceiptConverter(lineWidth: 48, bigFontLineWidth: 24); var converter = new ReceiptConverter(lineWidth: 48, bigFontLineWidth: 24);
var printCommands = converter.ConvertToPrintCommands(receipt); var printCommands = converter.ConvertToPrintCommands(receipt);
await _printer.FeedLinesAsync(1);
await _printer.SetCustomLineSpacing(22); await _printer.SetCustomLineSpacing(22);
foreach (var command in printCommands) foreach (var command in printCommands)