PrintDialogX 3.0.0

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

PrintDialogX v3.0.0

C# Platform Target .Net Target .Net Framework Nuget Lincense

A custom WPF print dialog with lightning-fast real-time preview. Support a full scope of print settings for modern demands, with the flexibility for complete customization. Provide the ability to dynamically adjust documents according to changes in print settings. Empowers the user experience with a responsive, elegant, and configurable interface.

Preview

Preview

Features

PrintDialogX is a powerful and user-friendly print dialog tailored for modern demands. It supports all essential and advanced features expected from a next-generation print dialog, delivering real-time document previews at lightning speed. Without relying on the built-in controls for document hosting and printing, this next-level print dialog is able to truly take full control over the print pipeline, enabling more thorough customizations and better performance.

The print settings responsively adapt to the capabilities of specific printers, adhering to industry standards in addition to intelligently maintaining the user's preferences. With the ability to respond to any changes in print settings made by the user, documents remain flexible and dynamically reactive to these adjustments. Powered by Wpf.Ui, the compelling interface allows complete personalization to suit specific scenarios, while its carefully crafted structure minimizes lag and ensures a fluid, modern printing experience.

  • Comprehensive printer selection
    • Detailed printer information with graphics
    • Options to add new printers or configure existing printers
  • Personalizable print settings
    • Full range of configurations for modern print dialogs
    • Modifiable settings organization for personal needs
  • Interactive real-time preview
    • Responsive high-resolution zooming
    • Customizable document arrangement and navigation
  • Dynamically updatable documents
    • Handler for print setting changes to adjust the contents on the fly

Dependencies

  • Wpf.Ui ≥ 4.0.0

How to Use

An example project is included under the PrintDialogX.Test folder on GitHub, with custom configurations to generate the print dialog accordingly, and three template documents to showcase the capability of PrintDialogX.

Quick Start

The usage of PrintDialogX is straightforward:

// Create a new document
PrintDialogX.PrintDocument document = new PrintDialogX.PrintDocument();

// Create the pages of the document
for (int i = 0; i < 100; i++)
{
    PrintDialogX.PrintPage page = new PrintDialogX.PrintPage();
    page.Content = GenerateContent(i);
    document.Pages.Add(page);
}

// Initialize the print dialog
PrintDialogX.PrintDialog dialog = new PrintDialogX.PrintDialog();
dialog.Document = document;

// Open the print dialog
dialog.ShowDialog();

// Retrieve the result of the operation
bool isSuccess = dialog.Result.IsSuccess;
int paperCount = dialog.Result.PaperCount;

Asynchronous Document Generation

PrintDialogX supports the ability to delay the document generation until the dialog is loaded, so that a spinner is shown during the generation:

// Initialize the print dialog
PrintDialogX.PrintDialog dialog = new PrintDialogX.PrintDialog();

// Open the print dialog
dialog.ShowDialog(async () =>
{
    // Create a new document
    PrintDialogX.PrintDocument document = new PrintDialogX.PrintDocument();

    // Create the pages of the document asynchronously
    for (int i = 0; i < 100; i++)
    {
        PrintDialogX.PrintPage page = new PrintDialogX.PrintPage();
        page.Content = await GenerateContentAsync(i);
        document.Pages.Add(page);

        // Allow for other UI updates
        await Dispatcher.Yield();
    }
    dialog.Document = document;
});

Document Configuration

It is easy to customize the document information (by default, the document is dynamically sized and takes up the entirety of the available space, but one may also choose to fix the size of the document):

document.DocumentName = "Untitled Document";
document.DocumentSize = new PrintDialogX.Enums.Size(PrintDialogX.Enums.Size.DefinedSize.NorthAmericaLetter);
document.DocumentMargin = 50.0;

Dynamically Updatable Documents

PrintDialogX raises an event when the print settings are changed:

document.PrintSettingsChanged += HandlePrintSettingsChanged;
private async void HandlePrintSettingsChanged(object? sender, PrintDialogX.PrintSettingsEventArgs e)
{
    if (sender is not PrintDialogX.PrintDocument document)
    {
        return;
    }

    // Block the preview generation until the document is updated, due to the use of await
    e.IsBlocking = true;

    int index = 0;
    foreach (PrintDialogX.PrintPage page in document.Pages)
    {
        // Update the content according to the print settings
        page.Content = await UpdateContentAsync(index, e.CurrentSettings);
        index++;

        // Allow for other UI updates
        await Dispatcher.Yield();
    }

    e.IsBlocking = false;
}

The default settings can be set individually (certain settings accept null and use null by default, which represents that the default configuration of the selected printer will be used):

dialog.PrintSettings.Copies = 2;
dialog.PrintSettings.Collation = PrintDialogX.Enums.Collation.Collated;
dialog.PrintSettings.Pages = PrintDialogX.Enums.Pages.CustomPages;
dialog.PrintSettings.CustomPages = "2-5, 8";
dialog.PrintSettings.Layout = PrintDialogX.Enums.Layout.Landscape;
dialog.PrintSettings.Color = PrintDialogX.Enums.Color.Grayscale;

Interface Customizations

PrintDialogX offers the ability to both customize the window of the print dialog and the exact interface to be used within the print dialog:

// Initialize the print dialog
PrintDialogX.PrintDialog dialog = new PrintDialogX.PrintDialog(window =>
{
    // Customize the dialog window
    window.Topmost = true;
    window.ShowInTaskbar = false;
});

// Customize the interface
dialog.InterfaceSettings.Title = "Test Print";
dialog.InterfaceSettings.BasicSettings = [PrintDialogX.InterfaceSettings.Option.Printer, PrintDialogX.InterfaceSettings.Option.Void, PrintDialogX.InterfaceSettings.Option.Pages, PrintDialogX.InterfaceSettings.Option.Layout, PrintDialogX.InterfaceSettings.Option.Size];
dialog.InterfaceSettings.AdvancedSettings = [PrintDialogX.InterfaceSettings.Option.Color, PrintDialogX.InterfaceSettings.Option.Quality, PrintDialogX.InterfaceSettings.Option.Scale, PrintDialogX.InterfaceSettings.Option.Margin, PrintDialogX.InterfaceSettings.Option.DoubleSided, PrintDialogX.InterfaceSettings.Option.Type, PrintDialogX.InterfaceSettings.Option.Source];

License

This project is under the MIT License.

Product Compatible and additional computed target framework versions.
.NET net6.0-windows7.0 is compatible.  net7.0-windows was computed.  net8.0-windows was computed.  net9.0-windows was computed.  net10.0-windows was computed. 
.NET Framework net472 is compatible.  net48 was computed.  net481 was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETFramework 4.7.2

  • net6.0-windows7.0

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.