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
    %s requires a valid license key for further deployment. Get Trial Below.
    ironsuite
    Blue key in circleGet Started for Free
    30 days full access • 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.
    Grey check in circleTrial key delivered
    Your key has been issued and sent to your email.
    Calendar in circleBook Free Live Demo
    No cards • no pitches • no commitments Pick a time for a quick, personalized demo
    Get the most out of your 30-day trial with:

    Live product and key features walk-through

    Project-specific recommendations

    All your questions answered

    Grey key in circleBook Free Live Demo
    Your booking has been completed Check your e-mail for confirmation

    Want to deploy Iron Suite
    to a live project for FREE?

    What’s included?

    • Test in production without watermarks
    • 30 days fully functional product
    • 24/5 technical support during trial
    ironpdf Logo
    ironword Logo
    ironxl Logo
    ironppt Logo
    ironocr Logo
    ironbarcode Logo
    ironqr Logo
    ironprint Logo
    ironzip Logo
    ironwebscraper Logo
    Iron Software sales team
    Online 24/5
    Have Enterprise licensing requirements?
    Request Iron Suite Enterprise trial
    Key in blue circle

    Get your free 30-day Trial Key instantly

    Your trial license will be sent to your email address

    No limitations. 100% unlocked. No credit card.

    bullet_checkedNo credit card or account creation requiredNo limitations. 100% unlocked. No credit card.
    Or
    Key in blue circle

    Complete Your Trial Key Signup

    Tell us a little more about yourself.

    Key in blue circleNo credit card or account creation requiredNo limitations. 100% unlocked. No credit card.
    Key in blue circle

    Your license key has been delivered to your inbox

    Can't find it? Check your spam folder.

    What’s next?
    Install with NuGet
    Add IronPrint to your project
    Quickstart Guide
    Helpful resources to get started

    Need help getting started?

    Book a Free Live Demo

    See IronPrint in action and get your licensing questions answered, or

    Key in blue circle

    Your demo request is in.

    You'll receive an invite via email shortly.

    What’s next?
    Explore Documentation
    Review Licensing Options
    badge_greencheck_in_yellowcircle
    Thank you
    Your trial key should be in the email.
    If it is not, please contact support@ironsoftware.com
    • Logo Aetna
    • Logo NASA
    • Logo GE
    • Logo Porsche
    • Logo USDA
    • Logo Qatar
    Join Millions of Engineers who’ve tried IronPrint
    Your trial key should be in the email.
    If it is not, please contact support@ironsoftware.com