public static void DefineParagraphs(Document document, ArticlesWithWordMigra article) { Paragraph paragraphTitle = document.LastSection.AddParagraph(article.Title, "Heading1"); Paragraph paragraph = document.LastSection.AddParagraph(article.Context, "Normal"); paragraphTitle.AddBookmark("Paragraphs Title"); paragraph.AddBookmark("Paragraphs"); }
public static void CreatePDFDocument(ArticlesWithWordMigra article) { // Create a MigraDoc document Document document = PDFServices.CreateDocument(article); //string ddl = MigraDoc.DocumentObjectModel.IO.DdlWriter.WriteToString(document); MigraDoc.DocumentObjectModel.IO.DdlWriter.WriteToFile(document, "MigraDoc.mdddl"); PdfDocumentRenderer renderer = new PdfDocumentRenderer(true, PdfSharp.Pdf.PdfFontEmbedding.Always); renderer.Document = document; renderer.RenderDocument(); var extension = ".pdf"; // Save the document... string filename = article.DatePublished.ToString("yyyy-MM-dd")+" " + article.Author; var fileCreated = false; var FileNameCounter = 0; while (!fileCreated) { DirectoryInfo di = new DirectoryInfo(Directory.GetCurrentDirectory()); FileInfo[] PDFFiles = di.GetFiles(filename + extension); if (PDFFiles.Length == 0) { renderer.PdfDocument.Save(filename+ extension); fileCreated = true; } else { FileNameCounter = FileNameCounter + 1; filename = filename+'('+ FileNameCounter+')'; } } //// ...and start a viewer. //Process.Start(filename); }
public static Document CreateDocument(ArticlesWithWordMigra article) { // Create a new MigraDoc document Document document = new Document(); document.Info.Title = article.Title; document.Info.Author = "Nilufar Makhmudova"; DefineStyles(document); DefineContentSection(document, article); DefineParagraphs(document, article); return document; }
/// <summary> /// Defines page setup, headers, and footers. /// </summary> static void DefineContentSection(Document document, ArticlesWithWordMigra article) { Section section = document.AddSection(); section.PageSetup.OddAndEvenPagesHeaderFooter = false; section.PageSetup.StartingNumber = 1; HeaderFooter header = section.Headers.Primary; header.AddParagraph(article.EditionName +"\t"+ article.Url); // Create a paragraph with centered page number. See definition of style "Footer". Paragraph paragraph = new Paragraph(); paragraph.AddTab(); paragraph.AddPageField(); // Add paragraph to footer for odd pages. section.Footers.Primary.Add(paragraph); }
public void Update(ArticlesWithWordMigra article) { throw new NotImplementedException(); }