Search Results for

    Show / Hide Table of Contents

    Document settings

    Version 6.1.0

    In this article

    • Document information
    • Culture
    • Color mode
    • Further options

    This article describes how the settings of a MigraDoc document are configured and how information about it is added.

    Document information

    You can add some information like the title or the author to your MigraDoc document. This information is held in the DocumentInformation instance of your document. You can reach it via the Info property of your Document instance.

    The following code sets the available document information properties:

    // Set document info.
    document.Info.Title = "DocumentInfo sample";
    document.Info.Subject = "Introducing DocumentInfo and how to use it";
    document.Info.Author = "PDFsharp team";
    document.Info.Keywords = "DocumentInfo, Title, Subject, Author, Keywords";
    

    See full DocumentInfo sample in PDFsharp.Sample repository. Show resulting PDF

    This information can be read by applications like PDF readers. You can also insert the text saved in these properties in your document using InfoFields (see Contents / Fields for more information).

    Culture

    Especially when your code may be executed on machines with different culture settings it can be useful to set the culture of the document. The culture of the document will be used to render DateFields (see Contents / Fields for more information). Also, when you work with decimal aligned tab stops it is important that MigraDoc uses the same decimal separator for alignment like you do inside the numbers you wish to be aligned. If the wrong culture is used, the alignment will fail and cause ugly results.

    You can set the culture of the document by assigning a CultureInfo to the Culture property of your Document instance:

    // Set the culture to French (France).
    document.Culture = CultureInfo.GetCultureInfo("fr-fr");
    

    See full Culture sample in PDFsharp.Sample repository. Show resulting PDF

    Color mode

    All colors of the document are rendered in the same color model, regardless of if you initialized them from RGB or CMYK values. If the UseCmykColor property of a Document instance is set to true, the colors will be rendered in CMYK, otherwise RGB values are used.

    Note that this setting only applies to colors (see Formats / Colors for more information). Images are rendered using the color mode they were loaded with. So, if you want all images to be of the same color mode, you have to ensure this for all source files before importing them.

    You can set the color mode like this:

    // Render all colors in CMYK.
    document.UseCmykColor = true;
    

    See full ColorMode sample in PDFsharp.Sample repository. Show resulting PDF

    Further options

    There are some more document settings that are not described here. These are:

    • DefaultPageSetup (see Formats / Page setup)
    • DefaultTabStop (see Formats / Tab stops)
    • ImagePath (see Contents / Images)
    • Styles (see Formatting)

    You will also find some more specific document settings at the instance of the PdfDocumentRenderer or RtfDocumentRenderer that is used for the rendering of the document (see Rendering for more information).

    • Edit this page
    In this article
    Generated by DocFX  |   Privacy policy  |   Legal notice
    Back to top