/// <summary>
        /// Render a foreach page element
        /// </summary>
        /// <param name="forEach"></param>
        /// <param name="document"></param>
        /// <param name="wdDoc"></param>
        /// <param name="context"></param>
        /// <param name="mainDocumentPart"></param>
        /// <param name="formatProvider"></param>
        public static void Render(this ForEachPage forEach,
                                  Document document,
                                  OpenXmlElement wdDoc,
                                  ContextModel context,
                                  MainDocumentPart mainDocumentPart,
                                  IFormatProvider formatProvider)
        {
            context.ReplaceItem(forEach, formatProvider);

            if (string.IsNullOrEmpty(forEach.DataSourceKey) ||
                !context.ExistItem <DataSourceModel>(forEach.DataSourceKey))
            {
                return;
            }

            var datasource = context.GetItem <DataSourceModel>(forEach.DataSourceKey);

            if (datasource == null || datasource.Items == null)
            {
                return;
            }

            int i = 0;

            foreach (var item in datasource.Items)
            {
                var newPage = forEach.Clone();
                // doc inherit margin from page
                if (document.Margin == null && newPage.Margin != null)
                {
                    document.Margin = newPage.Margin;
                }
                // newPage inherit margin from doc
                else if (document.Margin != null && newPage.Margin == null)
                {
                    newPage.Margin = document.Margin;
                }

                if (!string.IsNullOrWhiteSpace(forEach.AutoContextAddItemsPrefix))
                {
                    // We add automatic keys :
                    // Is first item
                    item.AddItem("#" + forEach.AutoContextAddItemsPrefix + "_ForEachPage_IsFirstItem#", new BooleanModel(i == 0));
                    item.AddItem("#" + forEach.AutoContextAddItemsPrefix + "_ForEachPage_IsNotFirstItem#", new BooleanModel(i > 0));
                    // Is last item
                    item.AddItem("#" + forEach.AutoContextAddItemsPrefix + "_ForEachPage_IsLastItem#", new BooleanModel(i == datasource.Items.Count - 1));
                    // Index of the element (Based on 0, and based on 1)
                    item.AddItem("#" + forEach.AutoContextAddItemsPrefix + "_ForEachPage_IndexBaseZero#", new StringModel(i.ToString()));
                    item.AddItem("#" + forEach.AutoContextAddItemsPrefix + "_ForEachPage_IndexBaseOne#", new StringModel((i + 1).ToString()));
                    item.AddItem("#" + forEach.AutoContextAddItemsPrefix + "_ForEachPage_IsOdd#", new BooleanModel(i % 2 == 1));
                    item.AddItem("#" + forEach.AutoContextAddItemsPrefix + "_ForEachPage_IsEven#", new BooleanModel(i % 2 == 0));
                }

                newPage.Clone().Render(document, wdDoc, item, mainDocumentPart, formatProvider);

                i++;
            }
        }
        /// <summary>
        /// Generate the template
        /// </summary>
        /// <returns></returns>
        private static Document GetTemplateDocument()
        {
            var doc = new Document();

            doc.Styles.Add(new Style()
            {
                StyleId = "Red", FontColor = "FF0050", FontSize = "42"
            });
            doc.Styles.Add(new Style()
            {
                StyleId = "Yellow", FontColor = "FFFF00", FontSize = "40"
            });

            var page1 = new Page();

            page1.Margin = new SpacingModel()
            {
                Top = 845, Bottom = 1418, Left = 567, Right = 567, Header = 709, Footer = 709
            };
            var page2 = new Page();

            page2.Margin = new SpacingModel()
            {
                Top = 1418, Left = 845, Header = 709, Footer = 709
            };
            doc.Pages.Add(page1);
            doc.Pages.Add(page2);

            // Template 1 :

            var paragraph = new Paragraph();

            paragraph.ChildElements.Add(new Label()
            {
                Text = "Label wihtou special character (éèàù).", FontSize = "30", FontName = "Arial"
            });
            paragraph.ChildElements.Add(new Hyperlink()
            {
                Text = new Label()
                {
                    Text     = "Go to github.",
                    FontSize = "20",
                    FontName = "Arial"
                },
                WebSiteUri = "https://www.github.com/"
            });
            paragraph.Indentation = new ParagraphIndentationModel()
            {
                Left  = "300",
                Right = "6000"
            };
            paragraph.ChildElements.Add(new Label()
            {
                Text = "Ceci est un texte avec accents (éèàù)", FontSize = "30", FontName = "Arial"
            });
            paragraph.ChildElements.Add(new Label()
            {
                Text                = "#KeyTest1#",
                FontSize            = "40",
                TransformOperations = new List <LabelTransformOperation>()
                {
                    new LabelTransformOperation()
                    {
                        TransformOperationType = LabelTransformOperationType.ToUpper
                    }
                },
                FontColor = "#FontColorTestRed#",
                Shading   = "9999FF",
                BoldKey   = "#BoldKey#",
                Bold      = false
            });
            paragraph.ChildElements.Add(new Label()
            {
                Text = "#KeyTest2#",
                Show = false
            });
            paragraph.Borders = new BorderModel()
            {
                BorderPositions           = BorderPositions.BOTTOM | BorderPositions.TOP | BorderPositions.LEFT,
                BorderWidthBottom         = 3,
                BorderWidthLeft           = 10,
                BorderWidthTop            = 20,
                BorderWidthInsideVertical = 1,
                UseVariableBorders        = true,
                BorderColor       = "FF0000",
                BorderLeftColor   = "CCCCCC",
                BorderTopColor    = "123456",
                BorderRightColor  = "FFEEDD",
                BorderBottomColor = "FF1234"
            };

            var templateDefinition = new TemplateDefinition()
            {
                TemplateId    = "Template 1",
                Note          = "Sample paragraph",
                ChildElements = new List <BaseElement>()
                {
                    paragraph
                }
            };

            doc.TemplateDefinitions.Add(templateDefinition);

            page1.ChildElements.Add(new TemplateModel()
            {
                TemplateId = "Template 1"
            });
            page1.ChildElements.Add(paragraph);
            page1.ChildElements.Add(new TemplateModel()
            {
                TemplateId = "Template 1"
            });
            page1.ChildElements.Add(new TemplateModel()
            {
                TemplateId = "Template 1"
            });

            var p2 = new Paragraph();

            p2.Shading = "#ParagraphShading#";
            p2.ChildElements.Add(new Label()
            {
                Text = "   texte paragraph2 avec espace avant", FontSize = "20", SpaceProcessingModeValue = SpaceProcessingModeValues.Preserve
            });
            p2.ChildElements.Add(new Label()
            {
                Text = "texte2 paragraph2 avec espace après   ", SpaceProcessingModeValue = SpaceProcessingModeValues.Preserve
            });
            p2.ChildElements.Add(new Label()
            {
                Text = "   texte3 paragraph2 avec espace avant et après   ", SpaceProcessingModeValue = SpaceProcessingModeValues.Preserve
            });
            page1.ChildElements.Add(p2);

            var table = new Table()
            {
                TableWidth = new TableWidthModel()
                {
                    Width = "5000", Type = TableWidthUnitValues.Pct
                },
                TableIndentation = new TableIndentation()
                {
                    Width = 1000
                },
                Rows = new List <Row>()
                {
                    new Row()
                    {
                        Cells = new List <Cell>()
                        {
                            new Cell()
                            {
                                VerticalAlignment = TableVerticalAlignmentValues.Center,
                                Justification     = JustificationValues.Center,
                                ChildElements     = new List <BaseElement>()
                                {
                                    new Paragraph()
                                    {
                                        ChildElements = new List <BaseElement>()
                                        {
                                            new Label()
                                            {
                                                Text = "Cell 1 - First paragraph"
                                            }
                                        }, ParagraphStyleId = "Yellow"
                                    },
                                    new Image()
                                    {
                                        Width         = 50,
                                        Path          = @"Resources\Desert.jpg",
                                        ImagePartType = OpenXMLSDK.Engine.Packaging.ImagePartType.Jpeg
                                    },
                                    new Label()
                                    {
                                        Text = "Cell 1 - Label in a cell"
                                    },
                                    new Paragraph()
                                    {
                                        ChildElements = new List <BaseElement>()
                                        {
                                            new Label()
                                            {
                                                Text = "Cell 1 - Second paragraph"
                                            }
                                        }
                                    }
                                },
                                Fusion = true
                            },
                            new Cell()
                            {
                                ChildElements = new List <BaseElement>()
                                {
                                    new Label()
                                    {
                                        Text = "Cell 2 - First label"
                                    },
                                    new Image()
                                    {
                                        Height        = 10,
                                        Path          = @"Resources\Desert.jpg",
                                        ImagePartType = OpenXMLSDK.Engine.Packaging.ImagePartType.Jpeg
                                    },
                                    new Label()
                                    {
                                        Text = "Cell 2 - Second label"
                                    }
                                },
                                Borders = new BorderModel()
                                {
                                    BorderColor     = "#BorderColor#",
                                    BorderWidth     = 20,
                                    BorderPositions = BorderPositions.LEFT | BorderPositions.TOP
                                }
                            }
                        }
                    },
                    new Row()
                    {
                        ShowKey = "#NoRow#",
                        Cells   = new List <Cell>()
                        {
                            new Cell()
                            {
                                Fusion      = true,
                                FusionChild = true
                            },
                            new Cell()
                            {
                                VerticalAlignment = TableVerticalAlignmentValues.Bottom,
                                Justification     = JustificationValues.Right,
                                ChildElements     = new List <BaseElement>()
                                {
                                    new Label()
                                    {
                                        Text = "cellule4"
                                    }
                                }
                            }
                        }
                    }
                }
            };

            table.HeaderRow = new Row()
            {
                Cells = new List <Cell>()
                {
                    new Cell()
                    {
                        ChildElements = new List <BaseElement>()
                        {
                            new Paragraph()
                            {
                                ChildElements = new List <BaseElement>()
                                {
                                    new Label()
                                    {
                                        Text = "header1"
                                    }
                                }
                            }
                        }
                    },
                    new Cell()
                    {
                        ChildElements = new List <BaseElement>()
                        {
                            new Label()
                            {
                                Text = "header2"
                            }
                        }
                    }
                }
            };

            table.Borders = new BorderModel()
            {
                BorderPositions           = BorderPositions.BOTTOM | BorderPositions.INSIDEVERTICAL,
                BorderWidthBottom         = 50,
                BorderWidthInsideVertical = 1,
                UseVariableBorders        = true,
                BorderColor = "FF0000"
            };

            page1.ChildElements.Add(table);
            page1.ChildElements.Add(new Paragraph());

            if (File.Exists(@"Resources\Desert.jpg"))
            {
                page1.ChildElements.Add(
                    new Paragraph()
                {
                    ChildElements = new List <BaseElement>()
                    {
                        new Image()
                        {
                            MaxHeight     = 100,
                            MaxWidth      = 100,
                            Path          = @"Resources\Desert.jpg",
                            ImagePartType = OpenXMLSDK.Engine.Packaging.ImagePartType.Jpeg
                        }
                    }
                }
                    );
            }

            var tableDataSource = new Table()
            {
                TableWidth = new TableWidthModel()
                {
                    Width = "5000", Type = TableWidthUnitValues.Pct
                },
                ColsWidth = new int[2] {
                    750, 4250
                },
                Borders = new BorderModel()
                {
                    BorderPositions = (BorderPositions)63,
                    BorderColor     = "328864",
                    BorderWidth     = 20,
                },
                RowModel = new Row()
                {
                    Cells = new List <Cell>()
                    {
                        new Cell()
                        {
                            Shading       = "FFA0FF",
                            ChildElements = new List <BaseElement>()
                            {
                                new Label()
                                {
                                    Text = "#Cell1#"
                                }
                            }
                        },
                        new Cell()
                        {
                            ChildElements = new List <BaseElement>()
                            {
                                new Label()
                                {
                                    Text = "#Cell2#"
                                }
                            }
                        }
                    }
                },
                DataSourceKey = "#Datasource#"
            };

            var tableDataSourceWithPrefix = new Table()
            {
                TableWidth = new TableWidthModel()
                {
                    Width = "5000", Type = TableWidthUnitValues.Pct
                },
                ColsWidth = new int[2] {
                    750, 4250
                },
                Borders = new BorderModel()
                {
                    BorderPositions = (BorderPositions)63,
                    BorderColor     = "328864",
                    BorderWidth     = 20,
                },
                DataSourceKey             = "#DatasourcePrefix#",
                AutoContextAddItemsPrefix = "DataSourcePrefix",
                RowModel = new Row()
                {
                    Cells = new List <Cell>()
                    {
                        new Cell()
                        {
                            Shading       = "FFA0FF",
                            ChildElements = new List <BaseElement>()
                            {
                                new Label()
                                {
                                    Text    = "Item Datasource (0 index) #DataSourcePrefix_TableRow_IndexBaseZero# - ",
                                    ShowKey = "#DataSourcePrefix_TableRow_IsFirstItem#"
                                },
                                new Label()
                                {
                                    Text = "#Cell1#"
                                }
                            }
                        },
                        new Cell()
                        {
                            ChildElements = new List <BaseElement>()
                            {
                                new Label()
                                {
                                    Text    = "Item Datasource (1 index) #DataSourcePrefix_TableRow_IndexBaseOne# - ",
                                    ShowKey = "#DataSourcePrefix_TableRow_IsLastItem#"
                                },
                                new Label()
                                {
                                    Text = "#Cell2#"
                                }
                            }
                        }
                    }
                }
            };

            page1.ChildElements.Add(tableDataSource);

            page1.ChildElements.Add(tableDataSourceWithPrefix);

            // page 2
            var p21 = new Paragraph();

            p21.Justification    = JustificationValues.Center;
            p21.ParagraphStyleId = "Red";
            p21.ChildElements.Add(new Label()
            {
                Text = "texte page2", FontName = "Arial"
            });
            page2.ChildElements.Add(p21);

            var p22 = new Paragraph();

            p22.SpacingBefore    = 800;
            p22.SpacingAfter     = 800;
            p22.Justification    = JustificationValues.Both;
            p22.ParagraphStyleId = "Yellow";
            p22.ChildElements.Add(new Label()
            {
                Text = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse urna augue, convallis eu enim vitae, maximus ultrices nulla. Sed egestas volutpat luctus. Maecenas sodales erat eu elit auctor, eu mattis neque maximus. Duis ac risus quis sem bibendum efficitur. Vivamus justo augue, molestie quis orci non, maximus imperdiet justo. Donec condimentum rhoncus est, ut varius lorem efficitur sed. Donec accumsan sit amet nisl vel ornare. Duis aliquet urna eu mauris porttitor facilisis. "
            });
            page2.ChildElements.Add(p22);

            var p23 = new Paragraph();

            p23.Borders = new BorderModel()
            {
                BorderPositions = (BorderPositions)13,
                BorderWidth     = 20,
                BorderColor     = "#ParagraphBorderColor#"
            };
            p23.SpacingBetweenLines = 360;
            p23.ChildElements.Add(new Label()
            {
                Text = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse urna augue, convallis eu enim vitae, maximus ultrices nulla. Sed egestas volutpat luctus. Maecenas sodales erat eu elit auctor, eu mattis neque maximus. Duis ac risus quis sem bibendum efficitur. Vivamus justo augue, molestie quis orci non, maximus imperdiet justo. Donec condimentum rhoncus est, ut varius lorem efficitur sed. Donec accumsan sit amet nisl vel ornare. Duis aliquet urna eu mauris porttitor facilisis. "
            });
            page2.ChildElements.Add(p23);

            // Adding a foreach page :
            var foreachPage = new ForEachPage();

            foreachPage.DataSourceKey = "#DatasourceTableFusion#";

            foreachPage.Margin = new SpacingModel()
            {
                Top = 1418, Left = 845, Header = 709, Footer = 709
            };
            var paragraph21 = new Paragraph();

            paragraph21.ChildElements.Add(new Label()
            {
                Text = "Page label : #Label#"
            });
            foreachPage.ChildElements.Add(paragraph21);
            var p223 = new Paragraph();

            p223.Shading = "#ParagraphShading#";
            p223.ChildElements.Add(new Label()
            {
                Text = "Texte paragraph2 avec espace avant", FontSize = "20", SpaceProcessingModeValue = SpaceProcessingModeValues.Preserve
            });
            foreachPage.ChildElements.Add(p223);
            doc.Pages.Add(foreachPage);

            // page 3
            var page3 = new Page();
            var p31   = new Paragraph()
            {
                FontColor = "FF0000", FontSize = "26"
            };

            p31.ChildElements.Add(new Label()
            {
                Text = "Test the HeritFromParent"
            });
            var p311 = new Paragraph()
            {
                FontSize = "16"
            };

            p311.ChildElements.Add(new Label()
            {
                Text = " Success (not the same size)"
            });
            p31.ChildElements.Add(p311);
            page3.ChildElements.Add(p31);

            TableOfContents tableOfContents = new TableOfContents()
            {
                StylesAndLevels = new List <Tuple <string, string> >()
                {
                    new Tuple <string, string>("Red", "1"),
                    new Tuple <string, string>("Yellow", "2"),
                },
                Title        = "Tessssssst !",
                TitleStyleId = "Yellow",
                ToCStylesId  = new List <string>()
                {
                    "Red"
                },
                LeaderCharValue = TabStopLeaderCharValues.underscore
            };

            page3.ChildElements.Add(tableOfContents);

            paragraph = new Paragraph()
            {
                ParagraphStyleId = "#ParagraphStyleIdTestYellow#"
            };
            paragraph.ChildElements.Add(new Label()
            {
                Text = "Ceci est un test de paragraph avec Style", FontSize = "30", FontName = "Arial"
            });
            page3.ChildElements.Add(paragraph);

            doc.Pages.Add(page3);

            var page4 = new Page();
            //New page to manage UniformGrid:
            var uniformGrid = new UniformGrid()
            {
                DataSourceKey = "#UniformGridSample#",
                ColsWidth     = new int[2] {
                    2500, 2500
                },
                TableWidth = new TableWidthModel()
                {
                    Width = "5000", Type = TableWidthUnitValues.Pct
                },
                CellModel = new Cell()
                {
                    VerticalAlignment = TableVerticalAlignmentValues.Center,
                    Justification     = JustificationValues.Center,
                    ChildElements     = new List <BaseElement>()
                    {
                        new Paragraph()
                        {
                            ChildElements = new List <BaseElement>()
                            {
                                new Label()
                                {
                                    Text = "#CellUniformGridTitle#"
                                }
                            }
                        },
                        new Paragraph()
                        {
                            ChildElements = new List <BaseElement>()
                            {
                                new Label()
                                {
                                    Text = "Cell 1 - Second paragraph"
                                }
                            }
                        }
                    }
                },
                HeaderRow = new Row()
                {
                    Cells = new List <Cell>()
                    {
                        new Cell()
                        {
                            ChildElements = new List <BaseElement>()
                            {
                                new Paragraph()
                                {
                                    ChildElements = new List <BaseElement>()
                                    {
                                        new Label()
                                        {
                                            Text = "header1"
                                        }
                                    }
                                }
                            }
                        },
                        new Cell()
                        {
                            ChildElements = new List <BaseElement>()
                            {
                                new Label()
                                {
                                    Text = "header2"
                                }
                            }
                        }
                    }
                },
                Borders = new BorderModel()
                {
                    BorderPositions           = BorderPositions.BOTTOM | BorderPositions.INSIDEVERTICAL,
                    BorderWidthBottom         = 50,
                    BorderWidthInsideVertical = 1,
                    UseVariableBorders        = true,
                    BorderColor = "FF0000"
                }
            };

            page4.ChildElements.Add(uniformGrid);

            doc.Pages.Add(page4);

            var page5 = new Page();
            var tableDataSourceWithBeforeAfter = new Table()
            {
                TableWidth = new TableWidthModel()
                {
                    Width = "5000", Type = TableWidthUnitValues.Pct
                },
                ColsWidth = new int[2] {
                    750, 4250
                },
                Borders = new BorderModel()
                {
                    BorderPositions = (BorderPositions)63,
                    BorderColor     = "328864",
                    BorderWidth     = 20,
                },
                BeforeRows = new List <Row>()
                {
                    new Row()
                    {
                        Cells = new List <Cell>()
                        {
                            new Cell()
                            {
                                VerticalAlignment = TableVerticalAlignmentValues.Bottom,
                                Justification     = JustificationValues.Left,
                                ChildElements     = new List <BaseElement>()
                                {
                                    new Paragraph()
                                    {
                                        ChildElements = new List <BaseElement>()
                                        {
                                            new Label()
                                            {
                                                Text = "Cell 1 - A small paragraph"
                                            }
                                        }, ParagraphStyleId = "Yellow"
                                    },
                                    new Image()
                                    {
                                        MaxHeight     = 100,
                                        MaxWidth      = 100,
                                        Path          = @"Resources\Desert.jpg",
                                        ImagePartType = OpenXMLSDK.Engine.Packaging.ImagePartType.Jpeg
                                    },
                                    new Label()
                                    {
                                        Text = "Custom header"
                                    },
                                    new Paragraph()
                                    {
                                        ChildElements = new List <BaseElement>()
                                        {
                                            new Label()
                                            {
                                                Text = "Cell 1 - an other paragraph"
                                            }
                                        }
                                    }
                                },
                                Fusion = true
                            },
                            new Cell()
                            {
                                ChildElements = new List <BaseElement>()
                                {
                                    new Label()
                                    {
                                        Text = "Cell 2 - an other label"
                                    },
                                    new Image()
                                    {
                                        MaxHeight     = 100,
                                        MaxWidth      = 100,
                                        Path          = @"Resources\Desert.jpg",
                                        ImagePartType = OpenXMLSDK.Engine.Packaging.ImagePartType.Jpeg
                                    },
                                    new Label()
                                    {
                                        Text = "Cell 2 - an other other label"
                                    }
                                },
                                Borders = new BorderModel()
                                {
                                    BorderColor     = "00FF22",
                                    BorderWidth     = 15,
                                    BorderPositions = BorderPositions.RIGHT | BorderPositions.TOP
                                }
                            }
                        }
                    },
                    new Row()
                    {
                        Cells = new List <Cell>()
                        {
                            new Cell()
                            {
                                Fusion      = true,
                                FusionChild = true
                            },
                            new Cell()
                            {
                                VerticalAlignment = TableVerticalAlignmentValues.Bottom,
                                Justification     = JustificationValues.Right,
                                ChildElements     = new List <BaseElement>()
                                {
                                    new Label()
                                    {
                                        Text = "celluleX"
                                    }
                                }
                            }
                        }
                    }
                },
                RowModel = new Row()
                {
                    Cells = new List <Cell>()
                    {
                        new Cell()
                        {
                            Shading       = "FFA2FF",
                            ChildElements = new List <BaseElement>()
                            {
                                new Label()
                                {
                                    Text = "Cell : #Cell1#"
                                }
                            }
                        },
                        new Cell()
                        {
                            ChildElements = new List <BaseElement>()
                            {
                                new Label()
                                {
                                    Text = "Cell : #Cell2#"
                                }
                            }
                        }
                    }
                },
                DataSourceKey = "#Datasource#"
            };

            page5.ChildElements.Add(tableDataSourceWithBeforeAfter);

            doc.Pages.Add(page5);

            var page6 = new Page();

            var pr = new Paragraph()
            {
                ChildElements = new List <BaseElement>()
                {
                    new OpenXMLSDK.Engine.Word.ReportEngine.Models.Charts.BarModel()
                    {
                        Title              = "Graph test",
                        ShowTitle          = true,
                        FontSize           = "23",
                        ShowBarBorder      = true,
                        BarChartType       = BarChartType.BarChart,
                        BarDirectionValues = BarDirectionValues.Column,
                        BarGroupingValues  = BarGroupingValues.PercentStacked,
                        DataSourceKey      = "#GrahSampleData#",
                        ShowMajorGridlines = true,
                        HasBorder          = true,
                        BorderColor        = "#A80890"
                    }
                }
            };

            page6.ChildElements.Add(pr);

            doc.Pages.Add(page6);

            var page7 = new Page();

            var tableDataSourceWithCellFusion = new Table()
            {
                TableWidth = new TableWidthModel()
                {
                    Width = "5000", Type = TableWidthUnitValues.Pct
                },
                ColsWidth = new int[3] {
                    1200, 1200, 1200
                },
                Borders = new BorderModel()
                {
                    BorderPositions = (BorderPositions)63,
                    BorderColor     = "328864",
                    BorderWidth     = 20,
                },
                RowModel = new Row()
                {
                    Cells = new List <Cell>()
                    {
                        new Cell()
                        {
                            Shading       = "FFA0FF",
                            ChildElements = new List <BaseElement>()
                            {
                                new Label()
                                {
                                    Text = "#Cell1#"
                                }
                            },
                            FusionKey      = "#IsInGroup#",
                            FusionChildKey = "#IsNotFirstLineGroup#"
                        },
                        new Cell()
                        {
                            ChildElements = new List <BaseElement>()
                            {
                                new Label()
                                {
                                    Text = "#Cell2#"
                                }
                            }
                        },
                        new Cell()
                        {
                            ChildElements = new List <BaseElement>()
                            {
                                new Label()
                                {
                                    Text = "#Cell2#"
                                }
                            }
                        }
                    }
                },
                DataSourceKey = "#DatasourceTableFusion#"
            };

            page7.ChildElements.Add(tableDataSourceWithCellFusion);

            doc.Pages.Add(page7);

            // page 8
            var page8 = new Page();
            var p8    = new Paragraph()
            {
                FontColor = "FF0000", FontSize = "26"
            };

            p8.ChildElements.Add(new Label()
            {
                Text = "Label with" + Environment.NewLine + Environment.NewLine + "A new line"
            });
            page8.ChildElements.Add(p8);

            doc.Pages.Add(page8);

            // Header
            var header = new Header();

            header.Type = HeaderFooterValues.Default;
            var ph = new Paragraph();

            ph.ChildElements.Add(new Label()
            {
                Text = "Header Text"
            });
            if (File.Exists(@"Resources\Desert.jpg"))
            {
                ph.ChildElements.Add(new Image()
                {
                    MaxHeight     = 100,
                    MaxWidth      = 100,
                    Path          = @"Resources\Desert.jpg",
                    ImagePartType = OpenXMLSDK.Engine.Packaging.ImagePartType.Jpeg
                });
            }
            header.ChildElements.Add(ph);
            doc.Headers.Add(header);

            // first header
            var firstHeader = new Header();

            firstHeader.Type = HeaderFooterValues.First;
            var fph = new Paragraph();

            fph.ChildElements.Add(new Label()
            {
                Text = "first header Text"
            });
            firstHeader.ChildElements.Add(fph);
            doc.Headers.Add(firstHeader);

            // Footer
            var footer = new Footer();

            footer.Type = HeaderFooterValues.Default;
            var pf = new Paragraph();

            pf.ChildElements.Add(new Label()
            {
                Text = "Footer Text"
            });
            pf.ChildElements.Add(new Label()
            {
                IsPageNumber = true
            });
            footer.ChildElements.Add(pf);
            doc.Footers.Add(footer);

            return(doc);
        }