Exemplo n.º 1
0
        private void PrintChapter(DocumentationChapter relation, Document document)
        {
            var chapter       = relation.Chapter;
            var parameters    = GetParameters(relation.Parameters);
            var chapterNumber = relation.ChapterNumber;
            var title         = parameters.ContainsKey("title") ? parameters["title"] : chapter.Name;

            if (chapter is Chapter)
            {
                GenerateChapterHeader(title, chapterNumber, relation.Title, relation.NewPage, document);

                if (!string.IsNullOrWhiteSpace((chapter as Chapter).Content))
                {
                    _parent.Add(_htmlToPdf.Parse(ChapterService.GetContent(chapter as Chapter), parameters));
                }

                Flush(document);
            }
            else if (chapter is GeneratedChapter)
            {
                GenerateChapterContent(chapter as GeneratedChapter, chapterNumber, relation.Title, relation.NewPage, parameters, document);
                Flush(document);
            }
            else if (chapter is PdfChapter)
            {
                GenerateChapterHeader(title, chapterNumber, relation.Title, relation.NewPage, document);
                var root = RootDirectory;
                var file = string.Format("{0}/{1}", root, relation.File.GetPath());
                _parent.Add(_docxToPdf.Parse(file));
                Flush(document);
            }
        }