- 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>
33 lines
882 B
C#
33 lines
882 B
C#
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;
|
|
}
|
|
}
|
|
}
|