In This Article

Printer View Margins

While the SyntaxEditor printer views have numerous built-in margins (document title, page number, etc.), SyntaxEditor offers an extensibility point where custom margins can be created and added to printer views in any location.

Printer view margins all implement the IPrinterViewMargin interface.

Margin Locations

Printer view margins surround the text area and can be displayed in one of four placement locations (left, top, right, bottom).

The IPrinterViewMargin.Placement property has an PrinterViewMarginPlacement enumeration value that indicates one of those four placement locations.

Since each IPrinterViewMargin has a string-based Key, and the interface also implements IOrderable, it has an Orderings property that returns an enumerable of Ordering objects. Each ordering indicates the string Key of another margin and whether this margin comes before or after that one. When multiple margins are combined into a placement location, they are ordered based on the Orderings property values, where "after" means farther away from the text area.

Built-In Margin Summary

These printer view margins are built-in to the product:

  • Document title margin
  • Line number margin
  • Word wrap glyph margin
  • Page number margin

Document Title Margin

The document title margin, implemented by the PrinterDocumentTitleMargin class, is used to display the title of the document, which is specified in the IPrintSettings.DocumentTitle property. It appears in the top placement.

Visibility

This margin is visible by default (if a document title is specified), and can be made invisible when the IPrintSettings.IsDocumentTitleMarginVisible property is false.

Line Number Margin

The line number margin, implemented by the PrinterLineNumberMargin class, is used to display snapshot line numbers. It appears in the left placement.

Word wrapped lines do not display any line numbers.

Visibility

This margin is not visible by default, and can be made visible when the IPrintSettings.IsLineNumberMarginVisible property is true.

Word Wrap Glyph Margin

The word wrap glyph margin, implemented by the PrinterWordWrapGlyphMargin class, is used to display glyphs at the end of lines that are too long to fit in the view and must be wrapped. It appears in the right placement.

Visibility

This margin is visible by default, and can be made invisible when the IPrintSettings.IsWordWrapGlyphMarginVisible property is false.

Page Number Margin

The page number margin, implemented by the PrinterPageNumberMargin class, is used to display the current page number on each page, along with the total page count. It appears in the bottom placement.

Visibility

This margin is visible by default, and can be made invisible when the IPrintSettings.IsPageNumberMarginVisible property is false.

Margin Factories

Margin factories are used to tell SyntaxEditor which margins to display in a printer view. Margin factories are implementations of the IPrinterViewMarginFactory interface.

The DefaultPrinterViewMarginFactory class is an implementation of a factory that creates all of the built-in margins. While all the built-in margins are added if this factory is used, they still change their visibility based on the related IPrintSettings margin visibility properties such as IsDocumentTitleMarginVisible.

The IPrintSettings.ViewMarginFactories property is a collection of IPrinterViewMarginFactory objects. By default, it is auto-populated with the DefaultPrinterViewMarginFactory, meaning all built-in margins are available. Add additional margin factories to the collection if you wish to add custom margins. A QuickStart is available in the samples that shows how to do this.

Custom Margins

Custom margins are pretty easy to create. These are the basic steps involved:

  1. Make a margin Control that implements IPrinterViewMargin.
  2. Make a custom IPrinterViewMarginFactory that creates an instance of your margin class.
  3. Add your custom margin factory to the IPrintSettings.ViewMarginFactories collection.

At this point your margin should now be getting added to the view.

For details on implementing a custom margin including several complete examples, please see the related QuickStarts in the samples.