CG.Infrastructure.Printing 3.10.1

There is a newer version of this package available.
See the version list below for details.
dotnet add package CG.Infrastructure.Printing --version 3.10.1
                    
NuGet\Install-Package CG.Infrastructure.Printing -Version 3.10.1
                    
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="CG.Infrastructure.Printing" Version="3.10.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="CG.Infrastructure.Printing" Version="3.10.1" />
                    
Directory.Packages.props
<PackageReference Include="CG.Infrastructure.Printing" />
                    
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 CG.Infrastructure.Printing --version 3.10.1
                    
#r "nuget: CG.Infrastructure.Printing, 3.10.1"
                    
#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 CG.Infrastructure.Printing@3.10.1
                    
#: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=CG.Infrastructure.Printing&version=3.10.1
                    
Install as a Cake Addin
#tool nuget:?package=CG.Infrastructure.Printing&version=3.10.1
                    
Install as a Cake Tool

Infrastructure.Printing

A .NET 9.0 Windows library that provides comprehensive printing capabilities for WPF applications, including file printing, PDF generation, and DataGrid document pagination.

Overview

This library offers a robust set of printing services designed to handle various printing scenarios in Windows desktop applications. It provides both basic file printing capabilities and advanced document generation features with proper pagination support.

Features

Core Printing Services

  • File Printing: Print text files with customizable fonts and formatting
  • PDF Generation: Create and print PDF documents from text content
  • DataGrid Printing: Advanced printing of WPF DataGrid controls with pagination
  • ListView Printing: Support for ListView controls with GridView layouts

Document Pagination

  • Smart Pagination: Automatic page breaking for large datasets
  • Customizable Layouts: Configurable page sizes, margins, and orientations
  • Style Management: Consistent styling across printed documents
  • Header/Footer Support: Professional document headers and footers

Platform Support

  • Windows Only: Optimized for Windows desktop applications
  • WPF Integration: Native WPF control support
  • Modern .NET: Built on .NET 9.0 with latest C# features

Dependencies

  • CG.Infrastructure.Core (v3.10.7) - Core infrastructure components
  • CG.Infrastructure.Services (v3.10.2) - Service layer abstractions
  • Spire.PDF (v11.7.16) - PDF generation and manipulation

Key Components

IPrintingService Interface

public interface IPrintingService : IService
{
    void PrintFile(string path);
    void PrintPdf(string? path);
    void PrintDataGrid(DataGrid? dataGrid, bool bA4, string? title);
}

PrintingService Implementation

  • Handles file and PDF printing operations
  • Integrates with logging and document services
  • Provides error handling and validation
  • Supports both synchronous and asynchronous operations

DataGridDocumentPaginator

  • Advanced pagination for DataGrid controls
  • Automatic column and row measurement
  • Customizable styling and layout options
  • Support for alternating row styles and headers

Usage Examples

Basic File Printing

var printingService = serviceProvider.GetService<IPrintingService>();
printingService.PrintFile("path/to/document.txt");

PDF Generation and Printing

var printingService = serviceProvider.GetService<IPrintingService>();
printingService.PrintPdf("path/to/document.pdf");

DataGrid Printing

var printingService = serviceProvider.GetService<IPrintingService>();
printingService.PrintDataGrid(myDataGrid, true, "Sales Report");

Configuration

The library integrates with the .NET dependency injection container and can be configured through standard service registration:

services.AddScoped<IPrintingService, PrintingService>();

Requirements

  • .NET 9.0 or later
  • Windows operating system
  • WPF framework support
  • Access to printing devices and drivers

License

This project is part of the CG Infrastructure Libraries and follows the same licensing terms as the parent project.

Contributing

Please refer to the main project documentation for contribution guidelines and coding standards.

Product Compatible and additional computed target framework versions.
.NET net9.0-windows7.0 is compatible.  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
3.10.3 89 8/16/2025
3.10.2 119 8/15/2025
3.10.1 150 8/10/2025
3.10.0 530 7/22/2025
3.9.0 139 12/10/2024
1.0.0 315 5/27/2022