Example #1
0
        /// <summary>
        /// Assigns the section properties.
        /// </summary>
        /// <param name="document">The document.</param>
        /// <param name="secProperties">The sec properties.</param>
        private void AssignSectionProperties(Document document, SectionProperties secProperties)
        {
            if (document == null)
            {
                throw new ArgumentNullException("document");
            }

            if (secProperties != null)
            {
                PageSize pageSize = secProperties.Descendants <PageSize>().FirstOrDefault();

                if (pageSize != null)
                {
                    pageSize.Remove();
                }

                PageMargin pageMargin = secProperties.Descendants <PageMargin>().FirstOrDefault();

                if (pageMargin != null)
                {
                    pageMargin.Remove();
                }

                document.AppendChild(new Paragraph(new ParagraphProperties(new SectionProperties(pageSize, pageMargin))));
            }
        }