MigraDoc DDL (MDDDL)

Modified on 2010/01/19 11:16 by Thomas Hövel — Categorized as: Articles, MigraDoc Articles

MigraDoc DDL, the MigraDoc Document Description Language (MDDDL), is a text based serialization of a MigraDoc document.

It is used to pass a document to the DocumentPreview class.

It can also be used to persist a document in a file (using the DdlWriter and DdlReader classes).

Such a DDL file can also be helpful if a document doesn't quite look as expected.

Here's a code snippet that shows how to save a MDDDL file in Debug build only:
#if DEBUG
  MigraDoc.DocumentObjectModel.IO.DdlWriter dw = new MigraDoc.DocumentObjectModel.IO.DdlWriter("HelloWorld.mdddl");
  dw.WriteDocument(document);
  dw.Close();
#endif
And here's a MigraDoc DDL snippet from the Hello World sample:
\section
[
  PageSetup
  {
    PageHeight = "29.7cm"
    PageWidth = "21cm"
    Orientation = Portrait
    LeftMargin = "2.5cm"
    RightMargin = "2.5cm"
    TopMargin = "2.5cm"
    BottomMargin = "2cm"
    FooterDistance = "1.25cm"
    HeaderDistance = "1.25cm"
    OddAndEvenPagesHeaderFooter = false
    DifferentFirstPageHeaderFooter = false
    SectionStart = BreakNextPage
    PageFormat = A4
    MirrorMargins = false
    HorizontalPageBreak = false
  }
]
{
  \paragraph
  [
    Style = "Normal"
    Format
    {
      Font
      {
        Name = "Verdana"
        Size = 10
        Bold = false
        Italic = false
        Underline = None
        Superscript = false
        Color = CMYK(100,30,20,50)
      }
      Alignment = Left
      LeftIndent = 0
      FirstLineIndent = 0
      RightIndent = 0
      SpaceBefore = 0
      SpaceAfter = 0
      LineSpacingRule = Single
      LineSpacing = 10
      KeepTogether = false
      KeepWithNext = false
      WidowControl = true
      PageBreakBefore = false
      OutlineLevel = BodyText
    }
  ]
  {
    \font
    [Name = "Verdana"
    Size = 10
    Bold = true
    Italic = false
    Underline = None
    Superscript = false
    Color = CMYK(100,30,20,50)
    ]
    {Hello, World!}
  }
}

Personal comment by Stefan Lange: We at empira Software invented MDDDL in 2000/2001, approximately at the same time when Microsoft invented XAML (original acronym for eXtensible Avalon Markup Language). Today I have used XAML with WPF and Silverlight for more than 3 years. But when I take a look at MDDDL, I still find it significantly more readable.