Search Results for

    Show / Hide Table of Contents

    Class PrintSettings

    A print settings class to use with a IronPrint.Printer functions as an optional parameters.

    Inheritance
    System.Object
    PrintSettings
    Namespace: IronPrint
    Assembly: IronPrint.dll
    Syntax
    public class PrintSettings : Object

    PrintSettings is the configuration object you hand to a print call to control how a document reaches paper. It carries the printer choice, copy count, paper size and orientation, margins, and output quality, and it is accepted as the optional argument to every Printer method. One settings object can be reused across several jobs or adjusted per call. The defaults suit most documents, so only the properties that differ from a standard print need to be set.

    Create one with new PrintSettings() for an empty configuration, or read the static PrintSettings.DefaultSettings for a populated baseline to adjust. The properties fall into three groups. Paper setup covers PaperSize, PaperOrientation, and PaperMargins, the last a Nullable<Margins> that falls back to the printer's own margins when left null. Output quality covers Dpi, Grayscale, and Flatten, where Flatten renders form fields and images before printing. Job control covers NumberOfCopies, PrinterName, and Tray.

    Several values are advisory rather than guaranteed. NumberOfCopies can be capped by the platform, so a multi-copy request may yield a single copy. PrinterName and Tray are ignored when the user selects a device in a print dialog, and Tray applies only on Windows. To target a printer reliably, read the printer names first and assign one to PrinterName before calling Printer.Print.

    using IronPrint;
    
    PrintSettings settings = new PrintSettings
    {
        PaperSize = PaperSize.A4,
        PaperOrientation = PaperOrientation.Landscape,
        NumberOfCopies = 3
    };
    Printer.Print("report.pdf", settings);

    The print settings guide walks through every option, the paper size guide and paper orientation guide cover layout, and the grayscale printing guide covers monochrome output.

    Constructors

    PrintSettings()

    Initializes a new instance of the PrintSettings class with default values.

    Declaration
    public PrintSettings()
    Remarks

    Alternative, you can use DefaultSettings to access a predefined set of default settings.

    Properties

    CompactMemoryAfterPrint

    Whether PrintAsync(String, PrintSettings) / PrintAsync(Byte[], PrintSettings) should run a full System.GC.Collect + System.Runtime.GCLargeObjectHeapCompactionMode.CompactOnce pass after each print operation.

    Declaration
    public bool CompactMemoryAfterPrint { get; set; }
    Property Value
    Type Description
    System.Boolean
    Remarks

    Default value is true. Printing a PDF allocates large managed buffers (decoded JPEG bitmaps, the source byte[] when reading from byte[]) that land on the Large Object Heap, which only compacts when explicitly requested. Forcing compaction at the print boundary keeps long-running services (e.g. print spoolers, batch processors) from accumulating LOH fragmentation across iterations.

    Set this to false if you print many small documents in a tight loop and would rather let the GC schedule itself — the per-call cost of a forced Gen2 collection can dominate when individual prints allocate only a few KB.

    DefaultSettings

    Initializes a new instance of the PrintSettings class with default values.

    Declaration
    public static PrintSettings DefaultSettings { get; }
    Property Value
    Type Description
    PrintSettings

    Dpi

    Intended print resolution in dots per inch.

    Default value is 300 which is a common value used in commercial printing.

    Declaration
    public int Dpi { get; set; }
    Property Value
    Type Description
    System.Int32
    Remarks

    The actual DPI used for printing might be limited by the capabilities of the printer.

    Flatten

    Flatten the PDF before printing, which is useful for displaying form field values and images.

    Declaration
    public bool Flatten { get; set; }
    Property Value
    Type Description
    System.Boolean
    Remarks

    The default value is false, indicating that the PDF will not be flattened before printing.

    Grayscale

    A value indicating whether to print in grayscale.

    Declaration
    public bool Grayscale { get; set; }
    Property Value
    Type Description
    System.Boolean
    Remarks

    The default value is false, indicating an attempt to print in color.

    NumberOfCopies

    The number of identical copies to be generated when printing a document.

    Default value is 1 copy

    Declaration
    public int NumberOfCopies { get; set; }
    Property Value
    Type Description
    System.Int32
    Remarks

    Note: In certain platforms, there may be limitations that prevent the accurate reproduction of multiple copies. In such cases, the specified value of NumberOfCopies might be ignored, and only one copy will be printed.

    PaperMargins

    The margins to use for printing in millimeters.

    The default value is null, indicating the use of the default margins provided by the printer.

    Declaration
    public Nullable<Margins> PaperMargins { get; set; }
    Property Value
    Type Description
    System.Nullable<Margins>

    PaperOrientation

    The paper orientation. E.g. Automatic, Portrait or Landscape.

    Default value is Automatic

    Declaration
    public PaperOrientation PaperOrientation { get; set; }
    Property Value
    Type Description
    PaperOrientation

    PaperSize

    Set an paper size used by the printer.

    Default value is PrinterDefault

    Declaration
    public PaperSize PaperSize { get; set; }
    Property Value
    Type Description
    PaperSize

    PrinterName

    The name of the printer to use for printing.

    Default value is null which means the current default printer of the operating system will be used.

    Declaration
    public string PrinterName { get; set; }
    Property Value
    Type Description
    System.String
    Remarks

    If you choose the printer in a PrintDialog, this setting will be ignored.

    To obtain the available printer names, you can use GetPrinterNames() or GetPrinterNamesAsync() to fetch the printer name list.

    Tray

    Printer tray used for the printing job. This allows users to specify a particular tray from which paper should be fed into the printer.

    If you choose the tray in a PrintDialog, this setting will be ignored.

    To obtain the available tray, you can use GetPrinterTrays(String) or GetPrinterTraysAsync(String)
    Declaration
    public string Tray { get; set; }
    Property Value
    Type Description
    System.String
    Remarks

    The default value is null, indicating the use of the default tray provided by the printer.

    ☀
    ☾
    Downloads
    • Download with NuGet
    • Start for Free
    In This Article
    Back to top
    Install with NuGet
    IronPrint_for_dotnet_log2o
    Blue key in circleGet started for FREE
    No credit card required
    Test in a live environment

    Test in production without watermarks.
    Works wherever you need it to.

    Fully-functional product

    Get 30 days of fully functional product.
    Have it up and running in minutes.

    24/5 technical support

    Full access to our support engineering team during your product trial

    Grey key in circleGet started for FREE
    The trial form was submitted successfully.
    Calendar in circleBook Free Live Demo
    No contact, no card details, no commitments Book a 30-minute, personal demo.
    Here's what to expect:

    A live demo of our product and its key features

    Get project specific feature recommendations

    All your questions are answered to make sure you have all the information you need. (No commitment whatsoever.)

    Grey key in circleBook Free Live Demo
    Your booking has been completed Check your e-mail for confirmation
    Support Team Member 6 related to The C# PDF Library Support Team Member 14 related to The C# PDF Library Support Team Member 4 related to The C# PDF Library Support Team Member 2 related to The C# PDF Library
    Online 24/5
    Need help? Our sales team would be glad to help you.
    Try the Enterprise Trial
    ironpdf_for_dotnet_log2o
    Key in blue circle
    Get your free 30-day Trial Key instantly.
    bullet_checkedNo credit card or account creation required
    Key in blue circle
    Get your free 30-day Trial Key instantly.
    Blue key in circleNo credit card or account creation required
    Green Check in orange circle
    The trial form was submitted successfully.
    badge_greencheck_in_yellowcircle
    Thank you for starting a trial

    Please check your email for the trial license key.

    If you don’t receive an email, please start a live chat or email support@ironsoftware.com

    Install with NuGet
    View Licensing
    • Logo Aetna
    • Logo NASA
    • Logo GE
    • Logo Porsche
    • Logo USDA
    • Logo Qatar
    Join Millions of Engineers who’ve tried IronPrint