public static PageSequence Parse(Document document, XmlDocumentDefinition xmlDocumentDefinition) { PageSequence returnValue = new PageSequence(document); foreach (XmlPageSequenceElement xmlPageSequenceElement in xmlDocumentDefinition.PageSequenceElements) { returnValue.Add(PageSequenceElement.Parse(xmlPageSequenceElement)); } return(returnValue); }
public void Load(XmlDocumentDefinition xmlDataDocument) { // If the fontpath is set, update template configuration. if (!string.IsNullOrEmpty(xmlDataDocument.FontPath)) { _configuration.SetFontPath(xmlDataDocument.FontPath, xmlDataDocument.FontPathRelative); } if (!string.IsNullOrEmpty(xmlDataDocument.Dpi)) { _dpi = Convert.ToInt32(xmlDataDocument.Dpi); } // Load metadata if (xmlDataDocument.Author != null) { _author = xmlDataDocument.Author; } if (xmlDataDocument.Subject != null) { _subject = xmlDataDocument.Subject; } if (xmlDataDocument.Title != null) { _title = xmlDataDocument.Title; } // Load fonts foreach (Font dFont in xmlDataDocument.Fonts) { var bFont = new Typography.Font(dFont.Key, _configuration.FontPath + dFont.BasePath, dFont.Encoding, dFont.IsEmbedded, dFont.DefaultFontSize); foreach (FontStyle dFontStyle in dFont.Styles) { bFont.AddStyle(new Typography.FontStyle(bFont, dFontStyle.Key, dFontStyle.File)); } Fonts.Add(bFont); } // Load colors foreach (Color color in xmlDataDocument.Colors) { var bColor = new Typography.Color(color.Key) { CMYKColor = new CMYKColor(color.CMYKColor.Cyan, color.CMYKColor.Magenta, color.CMYKColor.Yellow, color.CMYKColor.Black, color.CMYKColor.Tint), RGBColor = new RGBColor(color.RGBColor.Red, color.RGBColor.Green, color.RGBColor.Blue, color.RGBColor.Alpha) }; if (color.PMSColor != null) { bColor.PMSColor = new PMSColor(color.PMSColor.Name); } Colors.Add(bColor); } // Load pages const int pageNumber = 1; foreach (XmlPageDefinition dataPage in xmlDataDocument.Pages) { var bPage = new Page(this, dataPage.Key, dataPage.Width, dataPage.Height, dataPage.Colortype, dataPage.Bleeding, pageNumber); _staticPages.Add(bPage); // Add Elements ProcessContent(dataPage.XmlContent, bPage.Contents); } // Load pages template. foreach (XmlPageTemplateDefinition dataTemplate in xmlDataDocument.PageTemplates) { var pageTemplate = new PageTemplate(this, dataTemplate.Key, dataTemplate.Width, dataTemplate.Height, dataTemplate.Colortype, dataTemplate.Bleeding, dataTemplate.XmlLayout.VOffset.Value, dataTemplate.XmlLayout.HOffset.Value, dataTemplate.XmlLayout.Width.Value, dataTemplate.XmlLayout.Height.Value); _templates.Add(pageTemplate); // Add dynamic elements (if any) ProcessContent(dataTemplate.XmlDynamicContent, pageTemplate.DynamicContents); // Add static elements (if any) ProcessContent(dataTemplate.XmlStaticContent, pageTemplate.StaticContents); } PageSequence pageSequence = PageSequence.Parse(this, xmlDataDocument); // Create page Sequence. var pagingModule = new PagingModule(); _pages.AddRange(pagingModule.GetPages(pageSequence, _staticPages, _templates)); }