Table of Contents

Class PdfPrintService

Namespace
combit.Reporting.Printing.Pdf
Assembly
combit.ListLabel31.CrossPlatform.Printing.Pdf.dll

Default implementation of IPdfPrintService that orchestrates the full print pipeline: input validation, printer capability probing, PDF passthrough, and rasterized fallback printing. Print a PDF file from disk:

using combit.Reporting.Printing.Pdf;

var printerName = "My Printer";
var pdfPath = "document.pdf";

using var printService = new PdfPrintService();
PrintResult result = await printService.PrintAsync(
    pdfPath,
    printerName,
    options: new PrintJobOptions { PreferPdfPassthrough = true },
    cancellationToken: CancellationToken.None);

if (!result.Success)
{
    Console.WriteLine(result.ErrorMessage);
    Console.WriteLine(result.Diagnostics);
}
Print a PDF from a Stream:
using combit.Reporting.Printing.Pdf;

var printerName = "My Printer"; await using FileStream pdfStream = File.OpenRead("document.pdf");

using var printService = new PdfPrintService(); PrintResult result = await printService.PrintAsync( pdfStream, printerName, options: new PrintJobOptions { RasterDpi = 300 }, cancellationToken: CancellationToken.None);

public sealed class PdfPrintService : IPdfPrintService, IDisposable
Inheritance
PdfPrintService
Implements
Inherited Members

Constructors

PdfPrintService()

Initializes a new instance of the PdfPrintService class using the platform-default backend and rasterizer with logging disabled.

public PdfPrintService()

PdfPrintService(ILogger?)

Initializes a new instance of the PdfPrintService class using the platform-default backend and rasterizer.

public PdfPrintService(ILogger? logger)

Parameters

logger ILogger

Optional logger for structured diagnostics. When null, logging is disabled.

Methods

Dispose()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

public void Dispose()

PrintAsync(Stream, string, PrintJobOptions?, CancellationToken)

Prints a PDF document from a stream to the specified printer. The stream contents are read into memory and passed directly to the print backend; no temporary file is created on disk.

public Task<PrintResult> PrintAsync(Stream pdfStream, string printerName, PrintJobOptions? options = null, CancellationToken cancellationToken = default)

Parameters

pdfStream Stream

A readable stream containing the PDF document.

printerName string

The system name of the target printer.

options PrintJobOptions

Optional print job settings. When null, default options are used.

cancellationToken CancellationToken

Token used to observe cancellation requests.

Returns

Task<PrintResult>

A PrintResult describing whether the print operation succeeded, the method used, and any error or diagnostic information.

Exceptions

ArgumentNullException

Thrown when pdfStream or printerName is null.

ArgumentException

Thrown when printerName is empty or whitespace, or when pdfStream is not readable.

PrintAsync(string, string, PrintJobOptions?, CancellationToken)

Prints a PDF document from a file path to the specified printer.

public Task<PrintResult> PrintAsync(string pdfFilePath, string printerName, PrintJobOptions? options = null, CancellationToken cancellationToken = default)

Parameters

pdfFilePath string

The absolute path to the PDF file to print.

printerName string

The system name of the target printer.

options PrintJobOptions

Optional print job settings. When null, default options are used.

cancellationToken CancellationToken

Token used to observe cancellation requests.

Returns

Task<PrintResult>

A PrintResult describing whether the print operation succeeded, the method used, and any error or diagnostic information.

Exceptions

ArgumentNullException

Thrown when pdfFilePath or printerName is null.

ArgumentException

Thrown when pdfFilePath or printerName is empty or whitespace.

FileNotFoundException

Thrown when the file specified by pdfFilePath does not exist.