APM provides comprehensive printer management for thermal and dot-matrix printers. The system supports multiple connection types, automatic configuration, and print job distribution to multiple printers.
The ProcessPrintJobAsync method orchestrates the entire print workflow: template rendering, ESC/POS command generation, and transmission to the printer(s).
APM supports automatic job distribution to multiple printers using the CopyToPrinterIds property:
Infraestructure/Services/PrintService.cs:176-198
if (printerSettings.CopyToPrinterIds != null && printerSettings.CopyToPrinterIds.Any()){ foreach (var copyPrinterId in printerSettings.CopyToPrinterIds) { var copyPrinterSettings = await _settingsRepository.GetPrinterSettingsAsync(copyPrinterId); if (copyPrinterSettings == null) { _logger.LogWarning($"Impresora de copia con ID '{copyPrinterId}' no encontrada."); continue; } _logger.LogInfo($"Enviando copia a impresora '{copyPrinterId}'."); var copyEscPosCommands = await _escPosGenerator.GenerateEscPosCommandsAsync( ticketContent, copyPrinterSettings ); bool copyPrintSuccess = await _tcpIpPrinterClient.PrintAsync( copyPrinterSettings.IpAddress ?? string.Empty, copyPrinterSettings.Port, copyEscPosCommands ); if (!copyPrintSuccess) { _logger.LogError($"Fallo al imprimir en impresora de copia '{copyPrinterId}'."); // Process continues even if copy fails } }}
Copy printer failures do not halt the main print job. The service logs errors but continues processing.
The service provides comprehensive error reporting through PrintJobResult:
public class PrintJobResult{ public string JobId { get; set; } public string Status { get; set; } // "DONE" or "ERROR" public string? ErrorMessage { get; set; } // Detailed error description}