IDR.Library.PrintAgent.Shared
4.1.0
There is a newer version of this package available.
See the version list below for details.
See the version list below for details.
dotnet add package IDR.Library.PrintAgent.Shared --version 4.1.0
NuGet\Install-Package IDR.Library.PrintAgent.Shared -Version 4.1.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.1.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.1.0" />
<PackageReference Include="IDR.Library.PrintAgent.Shared" />
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.1.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: IDR.Library.PrintAgent.Shared, 4.1.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.1.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.1.0
#tool nuget:?package=IDR.Library.PrintAgent.Shared&version=4.1.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Depenso Print Agent
Agent d'impression local cross-platform permettant a une application web (WebAssembly) de communiquer avec les imprimantes locales.
Version 2.0.0 - Cross-Platform
L'agent est maintenant disponible pour Windows, macOS et Linux.
Structure du projet
IDR.Library.PrintAgent/
├── IDR.Library.PrintAgent.Shared/ # Bibliotheque partagee cross-platform
│ ├── Abstractions/ # Interfaces pour les services plateforme
│ ├── Platforms/
│ │ ├── Windows/ # Implementation Windows Spooler
│ │ └── Unix/ # Implementation CUPS (macOS/Linux)
│ ├── Protocols/ # ESC/POS, TSPL, Barcode generation
│ ├── Services/ # Services principaux
│ └── Models/ # Modeles de donnees
├── IDR.Library.PrintAgent.Tray/ # Application WPF (Windows uniquement)
├── IDR.Library.PrintAgent.Tray.CrossPlatform/ # Application console cross-platform
└── Installer/ # Scripts d'installation Windows
Support des plateformes
| Fonctionnalite | Windows | macOS | Linux |
|---|---|---|---|
| Imprimantes systeme | ✅ Windows Spooler | ✅ CUPS | ✅ CUPS |
| Imprimantes USB | ✅ | ✅ | ✅ |
| Imprimantes reseau | ✅ | ✅ | ✅ |
| Imprimantes serie | ✅ | ✅ | ✅ |
| Imprimantes Bluetooth | ✅ | Via CUPS | Via CUPS |
| ESC/POS | ✅ | ✅ | ✅ |
| TSPL (etiquettes) | ✅ | ✅ | ✅ |
| Interface graphique | ✅ (WPF) | Console | Console |
Installation
NuGet (Bibliotheque partagee)
dotnet add package IDR.Library.PrintAgent.Shared
Build depuis les sources
# Compiler le projet Shared
cd IDR.Library.PrintAgent.Shared
dotnet build
# Compiler le Tray cross-platform
cd ../IDR.Library.PrintAgent.Tray.CrossPlatform
dotnet build
Publication pour toutes les plateformes
cd IDR.Library.PrintAgent.Tray.CrossPlatform
# Windows x64
dotnet publish -c Release -r win-x64 -o ./publish/win-x64 --self-contained
# Linux x64
dotnet publish -c Release -r linux-x64 -o ./publish/linux-x64 --self-contained
# macOS Intel
dotnet publish -c Release -r osx-x64 -o ./publish/osx-x64 --self-contained
# macOS Apple Silicon
dotnet publish -c Release -r osx-arm64 -o ./publish/osx-arm64 --self-contained
Utilisation
Demarrer l'agent
# Lancer l'agent (port 5555 par defaut)
./DepensoPrintAgent
# Ou avec un port personnalise
./DepensoPrintAgent --PrintAgent:Port=5556
Sortie console
===========================================
Depenso Print Agent v2.0.0
Cross-Platform Edition
===========================================
Plateforme: Windows
Backend: Windows Spooler
Demarrage du serveur sur http://localhost:5555...
Endpoints disponibles:
- Health: http://localhost:5555/health
- Swagger: http://localhost:5555/swagger
- API: http://localhost:5555/api/...
Appuyez sur Ctrl+C pour arreter le serveur.
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 |
| GET | /api/printers/discover/{type} |
Decouvrir par type |
| POST | /api/printers/test |
Tester une connexion |
| POST | /api/print |
Impression d'un job |
| POST | /api/print/text |
Impression de texte simple |
| POST | /api/print/raw |
Impression de donnees brutes |
| POST | /api/print/open-drawer |
Ouverture du tiroir-caisse |
| POST | /api/print/test |
Page de test |
| POST | /api/label/barcode |
Impression d'etiquette code-barres |
| POST | /api/label/product |
Impression d'etiquette produit |
| POST | /api/label/custom |
Impression d'etiquette personnalisee |
Documentation Swagger
Disponible sur http://localhost:5555/swagger quand l'agent est en cours d'execution.
Types de connexion
public enum PrinterConnectionType
{
USB = 1,
Network = 2,
Bluetooth = 3,
Serial = 4,
System = 5
}
Exemple d'integration (JavaScript)
// Decouvrir les imprimantes
const response = await fetch('http://localhost:5555/api/printers/discover');
const result = await response.json();
console.log(result.printers);
// Imprimer du texte
await fetch('http://localhost:5555/api/print/text', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
connectionType: 5, // System
address: "Nom de l'imprimante",
text: "Hello World!",
cutAfterPrint: true
})
});
// Imprimer une etiquette
await fetch('http://localhost:5555/api/label/product', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
connectionType: 5,
address: "NELKO PM220",
productName: "Mon Produit",
barcode: "1234567890123",
price: "9.99 EUR",
quantity: 2
})
});
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 result = await Http.GetFromJsonAsync<DiscoveryResult>("http://localhost:5555/api/printers/discover");
var printers = result.Printers;
// Imprimer du texte
await Http.PostAsJsonAsync("http://localhost:5555/api/print/text", new
{
ConnectionType = 5, // System
Address = "Mon Imprimante",
Text = "Bonjour le monde!",
CutAfterPrint = true
});
Configuration CUPS (macOS/Linux)
Sur macOS et Linux, les imprimantes doivent etre configurees dans CUPS:
# Lister les imprimantes installees
lpstat -p -d
# Ajouter une imprimante USB (mode raw)
sudo lpadmin -p MyPrinter -E -v usb://... -m raw
# Definir comme imprimante par defaut
sudo lpadmin -d MyPrinter
# Tester l'impression
echo "Test" | lp -d MyPrinter
# Verifier les jobs en cours
lpq
Troubleshooting
L'agent ne demarre pas
- Verifier que le port 5555 n'est pas utilise par une autre application
- Sur macOS/Linux, verifier que CUPS est installe (
which lp)
L'application web ne peut pas se connecter
- Verifier que l'agent est en cours d'execution
- Verifier que l'adresse utilisee est bien
http://localhost:5555 - Les navigateurs bloquent les requetes HTTP vers localhost depuis HTTPS
Imprimante non detectee sur macOS/Linux
- Verifier que l'imprimante est configuree dans CUPS
- Utiliser
lpstat -ppour lister les imprimantes disponibles
Architecture
IDR.Library.PrintAgent.Shared
Shared/
├── Abstractions/
│ ├── IPlatformPrintService.cs # Interface pour impression plateforme
│ └── IPlatformDiscoveryService.cs # Interface pour decouverte plateforme
├── Platforms/
│ ├── Windows/
│ │ ├── WindowsPrintService.cs # Windows Spooler (winspool.drv)
│ │ └── WindowsDiscoveryService.cs # PrinterSettings
│ └── Unix/
│ ├── CupsPrintService.cs # CUPS (lp command)
│ └── CupsDiscoveryService.cs # lpstat/lpinfo
├── Services/
│ ├── IPrintService.cs # Interface principale impression
│ ├── PrintService.cs # Implementation
│ ├── IPrinterDiscoveryService.cs # Interface principale decouverte
│ └── PrinterDiscoveryService.cs # Implementation
├── Protocols/
│ ├── EscPosEncoder.cs # Encodeur ESC/POS
│ ├── TsplEncoder.cs # Encodeur TSPL (etiquettes)
│ └── BarcodeImageGenerator.cs # Generation code-barres (SkiaSharp)
└── Models/
├── PrinterInfo.cs # Info imprimante
├── PrintJob.cs # Job d'impression
└── PrintResult.cs # Resultat
Dependances principales
- SkiaSharp: Generation d'images cross-platform (remplace System.Drawing)
- ZXing.Net.Bindings.SkiaSharp: Generation de codes-barres cross-platform
- System.IO.Ports: Communication serie cross-platform
- System.Drawing.Common: Windows uniquement (pour PrinterSettings)
Licence
MIT
| 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. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net10.0
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.2)
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.2)
- SkiaSharp (>= 3.119.1)
- System.IO.Ports (>= 10.0.2)
- ZXing.Net (>= 0.16.11)
- ZXing.Net.Bindings.SkiaSharp (>= 0.16.22)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.