/// <summary> /// Crea el documento de las páginas /// </summary> private void CreatePage(string strBookTitle, string pathTemp, DocWriterFactory writerFactory, DocumentModel documentRoot, IndexItem page) { string fileName = GetFileName(pathTemp, page); // Crea la página if (File.Exists(fileName)) { string content = ConvertPageToNhtml(HelperFiles.LoadTextFile(fileName)); DocumentModel document; // Si hay algo que meter en el documento ... if (!content.IsEmpty()) { document = writerFactory.CreatePage(documentRoot, $"{page.PageNumber:000}. {page.Name}", strBookTitle + " - " + page.Name, documentRoot.Description + " - " + page.Name, documentRoot.KeyWords, content); } else { document = documentRoot; } // Crea los documentos de las páginas hija if (page.Items != null && page.Items.Count > 0) { foreach (IndexItem item in page.Items) { CreatePage(strBookTitle, pathTemp, writerFactory, document, item); } } } }
/// <summary> /// Compila el contenido del libro /// </summary> private void Compile(Book book, string pathTemp, string title, string description, string keyWords, string content, string pathTarget) { DocWriterFactory writerFactory = new DocWriterFactory(pathTarget); ProjectModel project = writerFactory.CreateProject(); DocumentModel documentRoot; // Crea el documento raíz documentRoot = CreateRoot(title, description, keyWords, content, writerFactory); // Crea los documentos de las páginas foreach (IndexItem page in book.Index) { CreatePage(title, pathTemp, writerFactory, documentRoot, page); } // Crea el índice y graba de nuevo el documento raíz documentRoot.Content += Environment.NewLine + GetIndex(project, documentRoot); new LibDocWriter.Application.Bussiness.Documents.DocumentBussiness().Save(documentRoot); // Copia las imágenes CopyImages(book, pathTemp, documentRoot.File.FullFileName); // Borra el archivo de proyecto y el archivo de solución HelperFiles.KillFile(project.File.FullFileName); HelperFiles.KillFile(project.Solution.FullFileName); }
/// <summary> /// Crea el documento raíz /// </summary> private DocumentModel CreateRoot(string title, string description, string keyWords, string content, DocWriterFactory writerFactory) { return(writerFactory.CreateCategory(null, title, title, description, keyWords, content, DocumentModel.ShowChildsMode.None, false, true)); }