/// <summary> /// Inserts a power point slide into a given section in OneNote as a page /// </summary> /// <param name="slideNumber"></param> /// <param name="pptOpenXml"></param> /// <param name="imgsPath"></param> /// <param name="note"></param> /// <param name="sectionId"></param> /// <param name="showComments"></param> /// <param name="commentsStr"></param> /// <param name="showNotes"></param> /// <param name="notesStr"></param> /// <param name="hiddenSlideNotIncluded"></param> /// <returns>the page ID</returns> protected string InsertPowerPointSlideInOneNote(int slideNumber, PowerPointOpenXml pptOpenXml, string imgsPath, OneNoteGenerator note, string sectionId, bool showComments = true, string commentsStr = "Comments", bool showNotes = true, string notesStr = "Notes", bool hiddenSlideNotIncluded = true) { // skip hidden slides if (hiddenSlideNotIncluded && pptOpenXml.IsHiddenSlide(slideNumber)) { return String.Empty; } // get the image representing the current slide as HTML string imgPath = String.Format("{0}\\Slide{1}.png", imgsPath, slideNumber); Image img; try { img = Image.FromFile(imgPath); } catch (FileNotFoundException e) { Console.WriteLine("Slide {0} was not converted", slideNumber); Console.WriteLine(e.Message); img = null; } // insert the image string pageTitle = pptOpenXml.GetSlideTitle(slideNumber); pageTitle = String.IsNullOrEmpty(pageTitle) ? String.Format("Slide{0}", slideNumber) : pageTitle; string pageId = note.CreatePage(pageTitle, sectionId); if (img != null) { note.AddImageToPage(pageId, img); img.Dispose(); } // Add comments string slideComments = pptOpenXml.GetSlideComments(slideNumber, false); if (showComments && !String.IsNullOrEmpty(slideComments)) { note.AppendPageContent(pageId, commentsStr + ": \n\n" + slideComments, (int)note.GetPageWidth(pageId)); } // Add notes string slideNotes = pptOpenXml.GetSlideNotes(slideNumber); if (showNotes && !String.IsNullOrEmpty(slideNotes)) { note.AppendPageContent(pageId, notesStr + ": \n\n" + slideNotes, (int)note.GetPageWidth(pageId)); } // remove the author note.RemoveAuthor(pageId); return pageId; }