IDR.Library.PrintAgent.Shared
4.0.0
See the version list below for details.
dotnet add package IDR.Library.PrintAgent.Shared --version 4.0.0
NuGet\Install-Package IDR.Library.PrintAgent.Shared -Version 4.0.0
<PackageReference Include="IDR.Library.PrintAgent.Shared" Version="4.0.0" />
<PackageVersion Include="IDR.Library.PrintAgent.Shared" Version="4.0.0" />
<PackageReference Include="IDR.Library.PrintAgent.Shared" />
paket add IDR.Library.PrintAgent.Shared --version 4.0.0
#r "nuget: IDR.Library.PrintAgent.Shared, 4.0.0"
#:package IDR.Library.PrintAgent.Shared@4.0.0
#addin nuget:?package=IDR.Library.PrintAgent.Shared&version=4.0.0
#tool nuget:?package=IDR.Library.PrintAgent.Shared&version=4.0.0
Depenso Print Agent
Agent d'impression local permettant a une application web (WebAssembly) de communiquer avec les imprimantes locales.
Structure du projet
IDR.Library.PrintAgent/
├── IDR.Library.PrintAgent.Shared/ # Bibliotheque partagee (services, modeles)
├── IDR.Library.PrintAgent.App/ # API standalone (pour dev/debug)
├── IDR.Library.PrintAgent.Tray/ # Application System Tray (pour utilisateurs)
└── Installer/ # Scripts d'installation
├── installer.iss # Script Inno Setup
└── build.ps1 # Script de build automatise
Pour les developpeurs
Pre-requis
- .NET 10 SDK
- Visual Studio 2022 ou VS Code
- Inno Setup 6 (pour creer l'installateur)
Build et test rapide
# Build du projet Tray
cd IDR.Library.PrintAgent.Tray
dotnet build
# Executer en mode dev
dotnet run
Creer l'installateur
# Methode 1: Script automatise
cd Installer
.\build.ps1
# Methode 2: Manuel
cd IDR.Library.PrintAgent.Tray
dotnet publish -c Release -r win-x64 --self-contained true -p:PublishSingleFile=true -o "bin\Release\net10.0-windows\publish"
# Puis ouvrir Installer\installer.iss avec Inno Setup et compiler
Pour les utilisateurs
Installation
- Telecharger
DepensoPrintAgentSetup.exe - Double-cliquer et suivre l'assistant d'installation
- L'application demarre automatiquement
Utilisation
- Une icone d'imprimante apparait dans la barre des taches (pres de l'horloge)
- Clic droit sur l'icone > "Ouvrir" pour voir l'adresse du service
- Copier l'adresse (
http://localhost:5555) dans votre application Depenso
Options
- Demarrer avec Windows: L'agent demarre automatiquement au demarrage de Windows
- Copier l'adresse: Copie l'URL du service dans le presse-papier
API REST
L'agent expose une API REST sur http://localhost:5555.
Endpoints principaux
| Methode | Endpoint | Description |
|---|---|---|
| GET | /health |
Verification de l'etat du service |
| GET | /api/printers/discover |
Liste toutes les imprimantes |
| POST | /api/print |
Impression d'un job |
| POST | /api/print/text |
Impression de texte simple |
| POST | /api/print/open-drawer |
Ouverture du tiroir-caisse |
| POST | /api/label/barcode |
Impression d'etiquette code-barres |
| POST | /api/label/product |
Impression d'etiquette produit |
Documentation Swagger
Disponible sur http://localhost:5555/swagger quand l'agent est en cours d'execution.
Exemple d'integration (Blazor WebAssembly)
@inject HttpClient Http
// Verifier que l'agent est disponible
var health = await Http.GetFromJsonAsync<HealthResponse>("http://localhost:5555/health");
// Lister les imprimantes
var printers = await Http.GetFromJsonAsync<List<PrinterInfo>>("http://localhost:5555/api/printers/discover");
// Imprimer du texte
await Http.PostAsJsonAsync("http://localhost:5555/api/print/text", new
{
ConnectionType = "System",
Address = "Mon Imprimante",
Text = "Bonjour le monde!",
CutAfterPrint = true
});
Troubleshooting
L'agent ne demarre pas
- Verifier que le port 5555 n'est pas utilise par une autre application
- Verifier les logs Windows dans l'Observateur d'evenements
L'application web ne peut pas se connecter
- Verifier que l'agent est en cours d'execution (icone dans la barre des taches)
- Verifier que l'adresse utilisee est bien
http://localhost:5555 - Les navigateurs modernes bloquent les requetes HTTP vers localhost depuis HTTPS. Utiliser HTTP pour l'application web en dev, ou configurer une exception.
Cross platforme
Rendre le PrintAgent cross-platform
Défis actuels (Windows-only)
Votre PrintAgent utilise des composants spécifiques à Windows : ┌──────────────────────────────────────────┬──────────────────────────────────┐ │ Composant │ Problème │ ├──────────────────────────────────────────┼──────────────────────────────────┤ │ System.Drawing.Common │ Windows uniquement depuis .NET 6 │ ├──────────────────────────────────────────┼──────────────────────────────────┤ │ ZXing.Net.Bindings.Windows.Compatibility │ Windows uniquement │ ├──────────────────────────────────────────┼──────────────────────────────────┤ │ RawPrinterHelper (Windows Spooler) │ API Windows │ ├──────────────────────────────────────────┼──────────────────────────────────┤ │ WMI pour découverte imprimantes │ Windows uniquement │ └──────────────────────────────────────────┴──────────────────────────────────┘ Solutions par plateforme
- Génération d'images (code-barres) ┌────────────────┬──────────────────────────────────────────┐ │ Plateforme │ Alternative │ ├────────────────┼──────────────────────────────────────────┤ │ Cross-platform │ SkiaSharp + ZXing.Net.Bindings.SkiaSharp │ ├────────────────┼──────────────────────────────────────────┤ │ Cross-platform │ ImageSharp (Six Labors) │ └────────────────┴──────────────────────────────────────────┘
- Impression ┌────────────┬────────────────────────────────────────────────────┐ │ Plateforme │ Méthode │ ├────────────┼────────────────────────────────────────────────────┤ │ Windows │ Windows Spooler (actuel) │ ├────────────┼────────────────────────────────────────────────────┤ │ macOS │ CUPS via lp command │ ├────────────┼────────────────────────────────────────────────────┤ │ Linux │ CUPS via lp command │ ├────────────┼────────────────────────────────────────────────────┤ │ Réseau │ Socket TCP direct (port 9100) - fonctionne partout │ └────────────┴────────────────────────────────────────────────────┘
- Découverte d'imprimantes ┌─────────────┬─────────────────────────────────────┐ │ Plateforme │ Méthode │ ├─────────────┼─────────────────────────────────────┤ │ Windows │ WMI / PrinterSettings │ ├─────────────┼─────────────────────────────────────┤ │ macOS/Linux │ lpstat -p (CUPS) │ ├─────────────┼─────────────────────────────────────┤ │ Réseau │ Scan UDP broadcast / mDNS (Bonjour) │ └─────────────┴─────────────────────────────────────┘ Architecture recommandée
IDR.Library.PrintAgent.Shared/ ├── Abstractions/ │ ├── IPrinterDiscovery.cs # Interface commune │ └── IPrintService.cs # Interface commune ├── Platforms/ │ ├── Windows/ # Implémentation Windows │ ├── MacOS/ # Implémentation macOS │ └── Linux/ # Implémentation Linux └── Common/ └── NetworkPrinting.cs # TCP port 9100 (cross-platform)
Options de packaging ┌────────────┬─────────────────────────┬────────────────────────────────┐ │ Plateforme │ Format │ Outil │ ├────────────┼─────────────────────────┼────────────────────────────────┤ │ Windows │ .exe / .msi │ Inno Setup (actuel) │ ├────────────┼─────────────────────────┼────────────────────────────────┤ │ macOS │ .dmg / .pkg │ dotnet-packaging ou create-dmg │ ├────────────┼─────────────────────────┼────────────────────────────────┤ │ Linux │ .deb / .rpm / .AppImage │ dotnet-packaging │ └────────────┴─────────────────────────┴────────────────────────────────┘ Approche pragmatique
Phase 1 : Prioriser l'impression réseau (TCP 9100)
- Fonctionne sur toutes les plateformes
- Pas besoin de drivers
- Votre PM220 supporte probablement déjà le réseau
Phase 2 : Ajouter CUPS pour macOS/Linux
- Couvre les imprimantes USB/Bluetooth locales
Phase 3 : Packaging natif par plateforme
Alternative : Electron ou MAUI
Si vous voulez une UI cross-platform pour le PrintAgent :
- MAUI : Vous l'utilisez déjà pour Depensio
- Electron : Plus lourd mais très cross-platform
- Avalonia : Alternative .NET légère à MAUI
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.2)
- System.Drawing.Common (>= 10.0.2)
- System.IO.Ports (>= 10.0.2)
- ZXing.Net (>= 0.16.11)
- ZXing.Net.Bindings.Windows.Compatibility (>= 0.16.12)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.