GemBox.Document
  • Overview
  • Examples
  • Free version
  • Support
  • Pricelist

    Show / Hide Table of Contents

    ImportMapping Class

    Namespace:
    GemBox.Document
    Assembly:
    GemBox.Document.dll

    Represents a mapping of styles (and other referenced objects) from source document to destination document when importing elements between two different DocumentModel instances.

    • C#
    • VB.NET
    public sealed class ImportMapping
    Public NotInheritable Class ImportMapping
    Inheritance:
    System.Object
    ImportMapping
    Remarks

    Same ImportMapping instance can be used for multiple imports. This improves performances because matching styles (mapping from source document style to destination document style) do not have to be identified in subsequent imports if they where matched in previous imports. It also reduces memory usage and provides more consistent behavior in some particular scenarios which involve importing list paragraphs, list styles and paragraph styles which contain list formatting.

    Constructors

    ImportMapping(DocumentModel, DocumentModel, Boolean)

    Initializes a new instance of the ImportMapping class.

    • C#
    • VB.NET
    public ImportMapping(DocumentModel sourceDocument, DocumentModel destinationDocument, bool useDestinationStyles)
    Public Sub New(sourceDocument As DocumentModel, destinationDocument As DocumentModel, useDestinationStyles As Boolean)
    Parameters
    sourceDocument
    DocumentModel

    The source document.

    destinationDocument
    DocumentModel

    The destination document.

    useDestinationStyles
    System.Boolean

    true to use destination document styles if it has the same name as source style (but doesn't have the same formatting); otherwise false to use source document styles.

    Exceptions
    System.ArgumentNullException

    sourceDocument or destinationDocument is null.

    ImportMapping(DocumentModel, DocumentModel, Boolean, Boolean)

    Initializes a new instance of the ImportMapping class.

    • C#
    • VB.NET
    public ImportMapping(DocumentModel sourceDocument, DocumentModel destinationDocument, bool useDestinationStyles, bool resolveFormatting)
    Public Sub New(sourceDocument As DocumentModel, destinationDocument As DocumentModel, useDestinationStyles As Boolean, resolveFormatting As Boolean)
    Parameters
    sourceDocument
    DocumentModel

    The source document.

    destinationDocument
    DocumentModel

    The destination document.

    useDestinationStyles
    System.Boolean

    true to use destination document styles if it has the same name as source style (but doesn't have the same formatting); otherwise false to use source document styles.

    resolveFormatting
    System.Boolean

    true to fully resolve formatting on elements from styles and document default formats; otherwise false.

    Exceptions
    System.ArgumentNullException

    sourceDocument or destinationDocument is null.

    Properties

    DestinationDocument

    Gets the destination document.

    • C#
    • VB.NET
    public DocumentModel DestinationDocument { get; }
    Public ReadOnly Property DestinationDocument As DocumentModel
    Property Value
    DocumentModel

    The destination document.

    ResolveFormatting

    Gets a value indicating whether to fully resolve formatting on elements.

    • C#
    • VB.NET
    public bool ResolveFormatting { get; }
    Public ReadOnly Property ResolveFormatting As Boolean
    Property Value
    System.Boolean

    true to fully resolve formatting; otherwise, false.

    Remarks

    If this property is set to true, even if a formatting property wasn't explicitly set in the source document, it will be resolved from the style or the document's default formats. This is useful when merging multiple documents with different default formats. Default value is false.

    SourceDocument

    Gets the source document.

    • C#
    • VB.NET
    public DocumentModel SourceDocument { get; }
    Public ReadOnly Property SourceDocument As DocumentModel
    Property Value
    DocumentModel

    The source document.

    UseDestinationStyles

    Gets a value indicating whether to use destination document styles if they have the same name as source document styles, even though they do not have the same formatting.

    • C#
    • VB.NET
    public bool UseDestinationStyles { get; }
    Public ReadOnly Property UseDestinationStyles As Boolean
    Property Value
    System.Boolean

    true to use destination document styles; otherwise, false.

    Remarks

    Destination document ListStyle and ParagraphStyle with ListFormat.IsList equal to true are never used, because that would continue numbering of imported paragraphs in destination document and thus imported paragraphs would influence on the numbering of the rest of the paragraphs in destination document. If imported paragraphs with specific ListStyle should continue numbering in destination document, then set explicit mapping from source ListStyle (of these imported paragraphs) to destination ListStyle onto which numbering should continue.

    Methods

    GetDestinationStyle(Style)

    Gets the destination Style that matches the specified source style.

    • C#
    • VB.NET
    public Style GetDestinationStyle(Style sourceStyle)
    Public Function GetDestinationStyle(sourceStyle As Style) As Style
    Parameters
    sourceStyle
    Style

    The source style.

    Returns
    Style

    The destination Style that matches the specified source style or null if source style was not yet matched to any destination style.

    GetOrAddDestinationStyle(Style)

    Gets existing or new destination Style that matches the specified source style.

    • C#
    • VB.NET
    public Style GetOrAddDestinationStyle(Style sourceStyle)
    Public Function GetOrAddDestinationStyle(sourceStyle As Style) As Style
    Parameters
    sourceStyle
    Style

    The source style.

    Returns
    Style

    The destination Style that matches the specified source style.

    SetDestinationStyle(Style, Style)

    Sets the destination Style that matches the specified source style.

    • C#
    • VB.NET
    public void SetDestinationStyle(Style sourceStyle, Style destinationStyle)
    Public Sub SetDestinationStyle(sourceStyle As Style, destinationStyle As Style)
    Parameters
    sourceStyle
    Style

    The source style.

    destinationStyle
    Style

    The destination Style that matches the specified source style.

    Exceptions
    System.ArgumentNullException

    sourceStyle is null.

    System.ArgumentException

    Source and destination style are not of the same type.

    Back to top

    Facebook • Twitter • LinkedIn

    © GemBox Ltd. — All rights reserved.