internal static int GetListNumber(ListInfo li)
        {
            if (numberList.ContainsKey(li))
            return (int)numberList[li];

              return -1;
        }
Beispiel #2
0
        protected override HtmlItem renderingHtmlList(HtmlItem it, ref Paragraph par, HtmlItem parent)
        {
            HtmlList uol = it as HtmlList;

            if (uol != null)
            {
                foreach (HtmlLi l in uol.ListLi)
                {
                    if (l.ListItem.Exists(isText))
                    {
                        ListInfo listinfo = new ListInfo();
                        listinfo.ContinuePreviousList = true;
                        listinfo.ListType = ListType.BulletList1; // default
                        listinfo.NumberPosition = 25 * uol.Level; // BulletList margin default
                        RenderStyle.CreateRenderStyle(uol, ref listinfo).Render(); // render styles element
                        Paragraph newpar = par.Section.AddParagraph();
                        RenderStyle.CreateRenderStyle(uol, ref newpar).Render(); // render styles paragraph
                        newpar.Format.ListInfo = listinfo;

                        renderingit(l, ref newpar, uol, null);
                    }
                    else
                        renderingit(l, ref par, uol, null);
                }
            }
            if (!(parent is HtmlLi))
                par.Section.AddParagraph().AddLineBreak();
            return uol;
        }
        /// <summary>
        /// Gets the corresponding List ID of the ListInfo Object.
        /// </summary>
        internal static int GetListID(ListInfo li)
        {
            if (idList.ContainsKey(li))
            return (int)idList[li];

            return -1;
        }
Beispiel #4
0
        /// <summary>
        /// Add MigraDoc styles.
        /// </summary>
        /// <param name="doc">The document to add the styles to.</param>
        private static void AddStylesToDoc(MigraDoc.DocumentObjectModel.Document doc)
        {
            var body = doc.Styles["Normal"];

            body.Font.Size = MigraDoc.DocumentObjectModel.Unit.FromPoint(10);

            if (doc.Styles["TableText"] == null)
            {
                var tableTextStyle = doc.AddStyle("TableText", "Normal");
                // tableTextStyle.ParagraphFormat.LineSpacing = 0;
                tableTextStyle.ParagraphFormat.SpaceAfter = 5;
            }

            body.ParagraphFormat.LineSpacingRule = MigraDoc.DocumentObjectModel.LineSpacingRule.Multiple;
            body.ParagraphFormat.LineSpacing     = 1.0;
            body.ParagraphFormat.SpaceAfter      = 10;

            var footer = doc.Styles["Footer"];

            footer.Font.Size = MigraDoc.DocumentObjectModel.Unit.FromPoint(9);

            var h1 = doc.Styles["Heading1"];

            h1.Font.Bold = true;
            h1.Font.Size = MigraDoc.DocumentObjectModel.Unit.FromPoint(15);
            h1.ParagraphFormat.SpaceBefore = 0;

            var h2 = doc.Styles["Heading2"];

            h2.Font.Bold = true;
            h2.Font.Size = MigraDoc.DocumentObjectModel.Unit.FromPoint(13);
            h2.ParagraphFormat.SpaceBefore = 0;

            var h3 = doc.Styles["Heading3"];

            h3.Font.Bold = true;
            h3.Font.Size = MigraDoc.DocumentObjectModel.Unit.FromPoint(11);
            h3.ParagraphFormat.SpaceBefore = 0;

            var h4 = doc.Styles["Heading4"];

            h4.Font.Bold = true;
            h4.Font.Size = MigraDoc.DocumentObjectModel.Unit.FromPoint(10);
            h4.ParagraphFormat.SpaceBefore = 0;

            var h5 = doc.Styles["Heading5"];

            h5.Font.Bold = true;
            h5.Font.Size = MigraDoc.DocumentObjectModel.Unit.FromPoint(9);
            h5.ParagraphFormat.SpaceBefore = 0;

            var h6 = doc.Styles["Heading6"];

            h6.Font.Bold = true;
            h6.Font.Size = MigraDoc.DocumentObjectModel.Unit.FromPoint(9);
            h6.ParagraphFormat.SpaceBefore = 0;


            var links = doc.Styles["Hyperlink"];

            links.Font.Color = MigraDoc.DocumentObjectModel.Colors.Blue;

            if (doc.Styles["ListEnd"] == null)
            {
                var unorderedlist = doc.AddStyle("ListStart", "Normal");
                unorderedlist.ParagraphFormat.SpaceAfter = 0;
            }

            if (doc.Styles["UnorderedList"] == null)
            {
                var unorderedlist = doc.AddStyle("UnorderedList", "Normal");
                var listInfo      = new MigraDoc.DocumentObjectModel.ListInfo();
                listInfo.ListType = MigraDoc.DocumentObjectModel.ListType.BulletList1;
                unorderedlist.ParagraphFormat.ListInfo        = listInfo;
                unorderedlist.ParagraphFormat.LeftIndent      = "1cm";
                unorderedlist.ParagraphFormat.FirstLineIndent = "-0.5cm";
                unorderedlist.ParagraphFormat.SpaceAfter      = 0;
            }

            if (doc.Styles["OrderedList"] == null)
            {
                var orderedlist = doc.AddStyle("OrderedList", "UnorderedList");
                orderedlist.ParagraphFormat.ListInfo.ListType = MigraDoc.DocumentObjectModel.ListType.NumberList1;
                orderedlist.ParagraphFormat.LeftIndent        = "1cm";
                orderedlist.ParagraphFormat.FirstLineIndent   = "-0.5cm";
                orderedlist.ParagraphFormat.SpaceAfter        = 0;
            }

            if (doc.Styles["ListEnd"] == null)
            {
                var unorderedlist = doc.AddStyle("ListEnd", "Normal");
                unorderedlist.ParagraphFormat.SpaceAfter = 0;
            }

            if (doc.Styles["HorizontalRule"] == null)
            {
                var hr       = doc.AddStyle("HorizontalRule", "Normal");
                var hrBorder = new MigraDoc.DocumentObjectModel.Border();
                hrBorder.Width = "1pt";
                hrBorder.Color = MigraDoc.DocumentObjectModel.Colors.DarkGray;
                hr.ParagraphFormat.Borders.Bottom = hrBorder;
                hr.ParagraphFormat.LineSpacing    = 0;
                hr.ParagraphFormat.SpaceBefore    = 15;
            }
            if (doc.Styles["TableParagraph"] == null)
            {
                var style = doc.Styles.AddStyle("TableParagraph", "Normal");
                style.Font.Size = 8;
                style.ParagraphFormat.SpaceAfter = Unit.FromCentimeter(0);
                style.Font = new MigraDoc.DocumentObjectModel.Font("Courier New");
            }
        }
Beispiel #5
0
        /// <summary>
        /// Converts ParagraphFormat into DDL.
        /// </summary>
        internal void Serialize(Serializer serializer, string name, ParagraphFormat refFormat)
        {
            int pos = serializer.BeginContent(name);

            if (!IsNull("Font") && Parent.GetType() != typeof(Style))
            {
                Font.Serialize(serializer);
            }

            // If a refFormat is specified, it is important to compare the fields and not the properties.
            // Only the fields holds the internal information whether a value is NULL. In contrast to the
            // Efw.Application framework the nullable values and all the meta stuff is kept internal to
            // give the user the illusion of simplicity.

            if (!_alignment.IsNull && (refFormat == null || (_alignment != refFormat._alignment)))
            {
                serializer.WriteSimpleAttribute("Alignment", Alignment);
            }

            if (!_leftIndent.IsNull && (refFormat == null || (_leftIndent != refFormat._leftIndent)))
            {
                serializer.WriteSimpleAttribute("LeftIndent", LeftIndent);
            }

            if (!_firstLineIndent.IsNull && (refFormat == null || _firstLineIndent != refFormat._firstLineIndent))
            {
                serializer.WriteSimpleAttribute("FirstLineIndent", FirstLineIndent);
            }

            if (!_rightIndent.IsNull && (refFormat == null || _rightIndent != refFormat._rightIndent))
            {
                serializer.WriteSimpleAttribute("RightIndent", RightIndent);
            }

            if (!_spaceBefore.IsNull && (refFormat == null || _spaceBefore != refFormat._spaceBefore))
            {
                serializer.WriteSimpleAttribute("SpaceBefore", SpaceBefore);
            }

            if (!_spaceAfter.IsNull && (refFormat == null || _spaceAfter != refFormat._spaceAfter))
            {
                serializer.WriteSimpleAttribute("SpaceAfter", SpaceAfter);
            }

            if (!_lineSpacingRule.IsNull && (refFormat == null || _lineSpacingRule != refFormat._lineSpacingRule))
            {
                serializer.WriteSimpleAttribute("LineSpacingRule", LineSpacingRule);
            }

            if (!_lineSpacing.IsNull && (refFormat == null || _lineSpacing != refFormat._lineSpacing))
            {
                serializer.WriteSimpleAttribute("LineSpacing", LineSpacing);
            }

            if (!_keepTogether.IsNull && (refFormat == null || _keepTogether != refFormat._keepTogether))
            {
                serializer.WriteSimpleAttribute("KeepTogether", KeepTogether);
            }

            if (!_keepWithNext.IsNull && (refFormat == null || _keepWithNext != refFormat._keepWithNext))
            {
                serializer.WriteSimpleAttribute("KeepWithNext", KeepWithNext);
            }

            if (!_widowControl.IsNull && (refFormat == null || _widowControl != refFormat._widowControl))
            {
                serializer.WriteSimpleAttribute("WidowControl", WidowControl);
            }

            if (!_pageBreakBefore.IsNull && (refFormat == null || _pageBreakBefore != refFormat._pageBreakBefore))
            {
                serializer.WriteSimpleAttribute("PageBreakBefore", PageBreakBefore);
            }

            if (!_outlineLevel.IsNull && (refFormat == null || _outlineLevel != refFormat._outlineLevel))
            {
                serializer.WriteSimpleAttribute("OutlineLevel", OutlineLevel);
            }

            if (!IsNull("ListInfo"))
            {
                ListInfo.Serialize(serializer);
            }

            if (!IsNull("TabStops"))
            {
                _tabStops.Serialize(serializer);
            }

            if (!IsNull("Borders"))
            {
                if (refFormat != null)
                {
                    _borders.Serialize(serializer, refFormat.Borders);
                }
                else
                {
                    _borders.Serialize(serializer, null);
                }
            }

            if (!IsNull("Shading"))
            {
                _shading.Serialize(serializer);
            }

            serializer.EndContent(pos);
        }
        internal int NextListNumber(ListInfo listInfo)
        {
            ListType listType = listInfo.ListType;
              bool isNumberList = listType == ListType.NumberList1 ||
            listType == ListType.NumberList2 ||
            listType == ListType.NumberList3;

              int listNumber = int.MinValue;
              if (listInfo == this.previousListInfo)
              {
            if (isNumberList)
              return (int)this.previousListNumbers[listType];
            return listNumber;
              }

              //bool listTypeChanged = this.previousListInfo == null || this.previousListInfo.ListType != listType;

              if (isNumberList)
              {
            listNumber = 1;
            if (/*!listTypeChanged &&*/ (listInfo.IsNull("ContinuePreviousList") || listInfo.ContinuePreviousList))
              listNumber = (int)this.previousListNumbers[listType] + 1;

            this.previousListNumbers[listType] = listNumber;
              }
              //      else
              //        listNumber = int.MinValue;

              this.previousListInfo = listInfo;
              return listNumber;
        }
        /// <summary>
        /// Prepares this instance for rendering.
        /// </summary>
        public void PrepareDocument()
        {
            PdfFlattenVisitor visitor = new PdfFlattenVisitor();
              visitor.Visit(this.document);
              this.previousListNumbers = new Hashtable(3);
              this.previousListNumbers[ListType.NumberList1] = 0;
              this.previousListNumbers[ListType.NumberList2] = 0;
              this.previousListNumbers[ListType.NumberList3] = 0;
              this.formattedDocument = new FormattedDocument(this.document, this);
              //REM: Size should not be necessary in this case.
            #if true
              XGraphics gfx = XGraphics.CreateMeasureContext(new XSize(2000, 2000), XGraphicsUnit.Point, XPageDirection.Downwards);
            #else
            #if GDI
              XGraphics gfx = XGraphics.FromGraphics(Graphics.FromHwnd(IntPtr.Zero), new XSize(2000, 2000));
            #endif
            #if WPF
              XGraphics gfx = XGraphics.FromDrawingContext(null, new XSize(2000, 2000), XGraphicsUnit.Point);
            #endif
            #endif
            //      this.previousListNumber = int.MinValue;
              //gfx.MUH = this.unicode;
              //gfx.MFEH = this.fontEmbedding;

              this.previousListInfo = null;
              this.formattedDocument.Format(gfx);
        }
 public ListInfoOverrideRenderer(DocumentObject domObj, RtfDocumentRenderer docRenderer)
     : base(domObj, docRenderer)
 {
     this.listInfo = domObj as ListInfo;
 }
        private void StyleDoc(Document doc)
        {
            Color green = new Color(108, 179, 63),
                  brown = new Color(88, 71, 76),
                  lightbrown = new Color(150, 132, 126);

            var body = doc.Styles["Normal"];

            body.Font.Size = Unit.FromInch(0.14);
            body.Font.Color = new Color(51, 51, 51);

            body.ParagraphFormat.LineSpacingRule = LineSpacingRule.Multiple;
            body.ParagraphFormat.LineSpacing = 1.25;
            body.ParagraphFormat.SpaceAfter = 10;

            var footer = doc.Styles["Footer"];
            footer.Font.Size = Unit.FromInch(0.125);
            footer.Font.Color = green;

            var h1 = doc.Styles["Heading1"];
            h1.Font.Color = green;
            h1.Font.Bold = true;
            h1.Font.Size = Unit.FromPoint(15);

            var h2 = doc.Styles["Heading2"];
            h2.Font.Color = green;
            h2.Font.Bold = true;
            h2.Font.Size = Unit.FromPoint(13);

            var h3 = doc.Styles["Heading3"];
            h3.Font.Bold = true;
            h3.Font.Color = Colors.Black;
            h3.Font.Size = Unit.FromPoint(11);

            var links = doc.Styles["Hyperlink"];
            links.Font.Color = green;

            var unorderedlist = doc.AddStyle("UnorderedList", "Normal");
            var listInfo = new ListInfo();
            listInfo.ListType = ListType.BulletList1;
            unorderedlist.ParagraphFormat.ListInfo = listInfo;
            unorderedlist.ParagraphFormat.LeftIndent = "1cm";
            unorderedlist.ParagraphFormat.FirstLineIndent = "-0.5cm";
            unorderedlist.ParagraphFormat.SpaceAfter = 0;

            var orderedlist = doc.AddStyle("OrderedList", "UnorderedList");
            orderedlist.ParagraphFormat.ListInfo.ListType = ListType.NumberList1;

            // for list spacing (since MigraDoc doesn't provide a list object that we can target)
            var listStart = doc.AddStyle("ListStart", "Normal");
            listStart.ParagraphFormat.SpaceAfter = 0;
            listStart.ParagraphFormat.LineSpacing = 0.5;
            var listEnd = doc.AddStyle("ListEnd", "ListStart");
            listEnd.ParagraphFormat.LineSpacing = 1;

            var hr = doc.AddStyle("HorizontalRule", "Normal");
            var hrBorder = new Border();
            hrBorder.Width = "1pt";
            hrBorder.Color = Colors.DarkGray;
            hr.ParagraphFormat.Borders.Bottom = hrBorder;
            hr.ParagraphFormat.LineSpacing = 0;
            hr.ParagraphFormat.SpaceBefore = 15;
        }
Beispiel #10
0
        /// <summary>
        /// Creates a <see cref="Document"/>.
        /// </summary>
        /// <param name="title">The document title.</param>
        /// <returns>A <see cref="Document"/>.</returns>
        protected Document CreateDocument(string title = "")
        {
            Document document = new Document();
            document.AddSection();
            document.Info.Title = this.Settings.MetaTitle;
            document.Info.Author = this.Settings.MetaAuthor;

            this.DefaultStyle = document.Styles[StyleNames.Normal];
            this.DefaultStyle.Font.Name = this.Settings.FontFace;
            this.DefaultStyle.Font.Size = this.Settings.FontSize;
            this.DefaultStyle.Font.Color = this.CreateColorFromHex(this.Settings.FontColourHex);

            Style hyperlinkStyle = document.Styles[StyleNames.Hyperlink];
            hyperlinkStyle.BaseStyle = StyleNames.Normal;
            hyperlinkStyle.Font.Underline = Underline.Single;
            hyperlinkStyle.Font.Color = Colors.Blue;

            Style tableStyle = document.Styles.AddStyle(PdfResources.StyleNameTable, StyleNames.Normal);
            tableStyle.ParagraphFormat.LeftIndent = 4;
            tableStyle.ParagraphFormat.RightIndent = 4;

            Style tableHeaderStyle = document.Styles.AddStyle(PdfResources.StyleNameHeaderRow, PdfResources.StyleNameTable);
            tableHeaderStyle.Font.Bold = true;
            tableHeaderStyle.Font.Color = this.CreateColorFromHex(this.Settings.HeaderRowFontColourHex);

            this.WriteHeader(document, title, this.Settings.HeaderLogoUri);

            Color headerRowColour = this.CreateColorFromHex(this.Settings.HeaderRowBackgroundHex);
            var headerStyle = document.Styles[StyleNames.Header];
            headerStyle.Font.Name = this.Settings.FontFace;
            headerStyle.Font.Size = "20pt";

            var headingOneStyle = document.Styles[StyleNames.Heading1];
            headingOneStyle.Font.Name = this.Settings.FontFace;
            headingOneStyle.Font.Size = this.DefaultStyle.Font.Size * 2.0;

            var headingTwoStyle = document.Styles[StyleNames.Heading2];
            headingTwoStyle.BaseStyle = StyleNames.Heading1;
            headingTwoStyle.ParagraphFormat.Font.Color = headerRowColour;
            headingTwoStyle.ParagraphFormat.Borders.Top = new Border { Color = headerRowColour, Style = BorderStyle.Single };
            headingTwoStyle.ParagraphFormat.SpaceBefore = new Unit(6, UnitType.Millimeter);
            headingTwoStyle.ParagraphFormat.SpaceAfter = new Unit(2, UnitType.Millimeter);
            headingTwoStyle.Font.Size = this.DefaultStyle.Font.Size * 1.5;

            var headingThreeStyle = document.Styles[StyleNames.Heading3];
            headingThreeStyle.BaseStyle = StyleNames.Heading2;
            headingThreeStyle.ParagraphFormat.Borders.Top = new Border { Style = BorderStyle.None, Visible = false, Width = 0 };
            headingThreeStyle.Font.Size = this.DefaultStyle.Font.Size * 1.25;

            var controlLabelStyle = document.AddStyle(PdfResources.StyleNameControlLabel, StyleNames.Normal);
            controlLabelStyle.ParagraphFormat.SpaceBefore = new Unit(3, UnitType.Millimeter);
            controlLabelStyle.ParagraphFormat.SpaceAfter = new Unit(2, UnitType.Millimeter);

            var unorderedlist = document.AddStyle(PdfResources.StyleNameUnorderedList, StyleNames.Normal);
            var listInfo = new ListInfo
                           {
                               ListType = ListType.BulletList1
                           };
            unorderedlist.ParagraphFormat.ListInfo = listInfo;
            unorderedlist.ParagraphFormat.LeftIndent = 2;
            unorderedlist.ParagraphFormat.FirstLineIndent = -0.5;
            unorderedlist.ParagraphFormat.SpaceAfter = 0;

            var orderedlist = document.AddStyle(PdfResources.StyleNameOrderedList, PdfResources.StyleNameUnorderedList);
            orderedlist.ParagraphFormat.ListInfo.ListType = ListType.NumberList1;

            // for list spacing (since MigraDoc doesn't provide a list object that we can target)
            var listStart = document.AddStyle(PdfResources.StyleNameListStart, StyleNames.Normal);
            listStart.ParagraphFormat.SpaceBefore = 0;
            listStart.ParagraphFormat.SpaceAfter = 0;
            listStart.ParagraphFormat.LineSpacing = 0.5;
            var listEnd = document.AddStyle(PdfResources.StyleNameListEnd, PdfResources.StyleNameListStart);
            listEnd.ParagraphFormat.SpaceBefore = 0;
            listEnd.ParagraphFormat.SpaceAfter = 0;
            listEnd.ParagraphFormat.LineSpacing = 1;

            return document;
        }
Beispiel #11
0
        internal int NextListNumber(ListInfo listInfo)
        {
            ListType listType = listInfo.ListType;
            bool isNumberList = listType == ListType.NumberList1 ||
              listType == ListType.NumberList2 ||
              listType == ListType.NumberList3;

            int listNumber = int.MinValue;
            if (listInfo == _previousListInfo)
            {
                if (isNumberList)
                    return _previousListNumbers[listType];
                return listNumber;
            }

            //bool listTypeChanged = _previousListInfo == null || _previousListInfo.ListType != listType;

            if (isNumberList)
            {
                listNumber = 1;
                if (/*!listTypeChanged &&*/ (listInfo._continuePreviousList.IsNull || listInfo.ContinuePreviousList))
                    listNumber = _previousListNumbers[listType] + 1;

                _previousListNumbers[listType] = listNumber;
            }

            _previousListInfo = listInfo;
            return listNumber;
        }
Beispiel #12
0
        /// <summary>
        /// Add MigraDoc styles.
        /// </summary>
        /// <param name="doc">The document to add the styles to.</param>
        private static void AddStylesToDoc(MigraDoc.DocumentObjectModel.Document doc)
        {
            var body = doc.Styles["Normal"];
            body.Font.Size = MigraDoc.DocumentObjectModel.Unit.FromPoint(10);

            if (doc.Styles["TableText"] == null)
            {
                var tableTextStyle = doc.AddStyle("TableText", "Normal");
                //tableTextStyle.ParagraphFormat.LineSpacing = 0;
                tableTextStyle.ParagraphFormat.SpaceAfter = 5;
            }

            body.ParagraphFormat.LineSpacingRule = MigraDoc.DocumentObjectModel.LineSpacingRule.Multiple;
            body.ParagraphFormat.LineSpacing = 1.0;
            body.ParagraphFormat.SpaceAfter = 10;

            var footer = doc.Styles["Footer"];
            footer.Font.Size = MigraDoc.DocumentObjectModel.Unit.FromPoint(9);

            var h1 = doc.Styles["Heading1"];
            h1.Font.Bold = true;
            h1.Font.Size = MigraDoc.DocumentObjectModel.Unit.FromPoint(15);
            h1.ParagraphFormat.SpaceBefore = 0;

            var h2 = doc.Styles["Heading2"];
            h2.Font.Bold = true;
            h2.Font.Size = MigraDoc.DocumentObjectModel.Unit.FromPoint(13);
            h2.ParagraphFormat.SpaceBefore = 0;

            var h3 = doc.Styles["Heading3"];
            h3.Font.Bold = true;
            h3.Font.Size = MigraDoc.DocumentObjectModel.Unit.FromPoint(11);
            h3.ParagraphFormat.SpaceBefore = 0;

            var h4 = doc.Styles["Heading4"];
            h4.Font.Bold = true;
            h4.Font.Size = MigraDoc.DocumentObjectModel.Unit.FromPoint(10);
            h4.ParagraphFormat.SpaceBefore = 0;

            var h5 = doc.Styles["Heading5"];
            h5.Font.Bold = true;
            h5.Font.Size = MigraDoc.DocumentObjectModel.Unit.FromPoint(9);
            h5.ParagraphFormat.SpaceBefore = 0;

            var h6 = doc.Styles["Heading6"];
            h6.Font.Bold = true;
            h6.Font.Size = MigraDoc.DocumentObjectModel.Unit.FromPoint(9);
            h6.ParagraphFormat.SpaceBefore = 0;

            var links = doc.Styles["Hyperlink"];
            links.Font.Color = MigraDoc.DocumentObjectModel.Colors.Blue;

            if (doc.Styles["ListEnd"] == null)
            {
                var unorderedlist = doc.AddStyle("ListStart", "Normal");
                unorderedlist.ParagraphFormat.SpaceAfter = 0;
            }

            if (doc.Styles["UnorderedList"] == null)
            {
                var unorderedlist = doc.AddStyle("UnorderedList", "Normal");
                var listInfo = new MigraDoc.DocumentObjectModel.ListInfo();
                listInfo.ListType = MigraDoc.DocumentObjectModel.ListType.BulletList1;
                unorderedlist.ParagraphFormat.ListInfo = listInfo;
                unorderedlist.ParagraphFormat.LeftIndent = "1cm";
                unorderedlist.ParagraphFormat.FirstLineIndent = "-0.5cm";
                unorderedlist.ParagraphFormat.SpaceAfter = 0;
            }

            if (doc.Styles["OrderedList"] == null)
            {
                var orderedlist = doc.AddStyle("OrderedList", "UnorderedList");
                orderedlist.ParagraphFormat.ListInfo.ListType = MigraDoc.DocumentObjectModel.ListType.NumberList1;
                orderedlist.ParagraphFormat.LeftIndent = "1cm";
                orderedlist.ParagraphFormat.FirstLineIndent = "-0.5cm";
                orderedlist.ParagraphFormat.SpaceAfter = 0;
            }

            if (doc.Styles["ListEnd"] == null)
            {
                var unorderedlist = doc.AddStyle("ListEnd", "Normal");
                unorderedlist.ParagraphFormat.SpaceAfter = 0;
            }

            if (doc.Styles["HorizontalRule"] == null)
            {
                var hr = doc.AddStyle("HorizontalRule", "Normal");
                var hrBorder = new MigraDoc.DocumentObjectModel.Border();
                hrBorder.Width = "1pt";
                hrBorder.Color = MigraDoc.DocumentObjectModel.Colors.DarkGray;
                hr.ParagraphFormat.Borders.Bottom = hrBorder;
                hr.ParagraphFormat.LineSpacing = 0;
                hr.ParagraphFormat.SpaceBefore = 15;
            }
            if (doc.Styles["TableParagraph"] == null)
            {
                var style = doc.Styles.AddStyle("TableParagraph", "Normal");
                style.Font.Size = 8;
                style.ParagraphFormat.SpaceAfter = Unit.FromCentimeter(0);
                style.Font = new MigraDoc.DocumentObjectModel.Font("Courier New");
            }
        }