feat(20-windows-client): aplikacja C# WinForms do zdalnego druku etykiet
- System tray app z NotifyIcon + ContextMenuStrip - Polling API orderPRO (GET /api/print/jobs/pending) - Pobieranie etykiet PDF i druk przez PdfiumViewer - Formularz ustawień: URL API, klucz, drukarka, interwał - Okno logów z historią (ciemny motyw, Consolas) - Self-contained .NET 8 publish (win-x64) - Milestone v0.7 Zdalne drukowanie etykiet — COMPLETE Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
32
clients/windows/OrderPROPrint/Services/PrintService.cs
Normal file
32
clients/windows/OrderPROPrint/Services/PrintService.cs
Normal file
@@ -0,0 +1,32 @@
|
||||
using System.Drawing.Printing;
|
||||
using PdfiumViewer;
|
||||
|
||||
namespace OrderPROPrint.Services;
|
||||
|
||||
public class PrintService
|
||||
{
|
||||
public bool PrintPdf(byte[] pdfBytes, string printerName)
|
||||
{
|
||||
using var stream = new MemoryStream(pdfBytes);
|
||||
using var pdfDocument = PdfDocument.Load(stream);
|
||||
|
||||
using var printDocument = pdfDocument.CreatePrintDocument();
|
||||
printDocument.PrinterSettings.PrinterName = printerName;
|
||||
printDocument.DefaultPageSettings.Margins = new Margins(0, 0, 0, 0);
|
||||
|
||||
// A6 = 105x148mm = 413x583 hundredths of inch
|
||||
printDocument.DefaultPageSettings.PaperSize = new PaperSize("A6", 413, 583);
|
||||
|
||||
printDocument.PrintController = new StandardPrintController();
|
||||
|
||||
try
|
||||
{
|
||||
printDocument.Print();
|
||||
return true;
|
||||
}
|
||||
catch
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user