IDR.Library.PrintAgent.Shared 4.0.0

There is a newer version of this package available.
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
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="IDR.Library.PrintAgent.Shared" Version="4.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="IDR.Library.PrintAgent.Shared" Version="4.0.0" />
                    
Directory.Packages.props
<PackageReference Include="IDR.Library.PrintAgent.Shared" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add IDR.Library.PrintAgent.Shared --version 4.0.0
                    
#r "nuget: IDR.Library.PrintAgent.Shared, 4.0.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package IDR.Library.PrintAgent.Shared@4.0.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=IDR.Library.PrintAgent.Shared&version=4.0.0
                    
Install as a Cake Addin
#tool nuget:?package=IDR.Library.PrintAgent.Shared&version=4.0.0
                    
Install as a Cake Tool

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

  1. Telecharger DepensoPrintAgentSetup.exe
  2. Double-cliquer et suivre l'assistant d'installation
  3. L'application demarre automatiquement

Utilisation

  1. Une icone d'imprimante apparait dans la barre des taches (pres de l'horloge)
  2. Clic droit sur l'icone > "Ouvrir" pour voir l'adresse du service
  3. 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

  1. Génération d'images (code-barres) ┌────────────────┬──────────────────────────────────────────┐ │ Plateforme │ Alternative │ ├────────────────┼──────────────────────────────────────────┤ │ Cross-platform │ SkiaSharp + ZXing.Net.Bindings.SkiaSharp │ ├────────────────┼──────────────────────────────────────────┤ │ Cross-platform │ ImageSharp (Six Labors) │ └────────────────┴──────────────────────────────────────────┘
  2. 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 │ └────────────┴────────────────────────────────────────────────────┘
  3. 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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
5.0.0 183 5/20/2026
4.1.0 216 1/29/2026
4.0.6 148 1/28/2026
4.0.2 184 1/26/2026
4.0.1 145 1/25/2026
4.0.0 140 1/25/2026
1.0.5 145 1/25/2026