Handles the interaction with the OneNote document output, including creating notebook, section, page, adding content, and other things
		public static void MyClassInitialize(TestContext testContext)
		{
			if (!Directory.Exists(Utility.RootFolder))
			{
				Directory.CreateDirectory(Utility.RootFolder);
			}
			if (!Directory.Exists(Utility.TempFolder))
			{
				Directory.CreateDirectory(Utility.TempFolder);
			}
			_mXmlNs = Utility.NS;
			_mOnGenerator = new OneNoteGenerator(Utility.RootFolder);
			//Get Id of the test notebook so we chould retrieve generated content
			//KindercareFormatConverter will create notebookName as Kindercare
			_mNotebookId = _mOnGenerator.CreateNotebook(NotebookName);

			var word = new Application();
			var doc = word.Application.Documents.Add();

			//add pages to doc
			for (int i = 1; i < DocPageTitles.Count; i++)
			{
				doc.Content.Text += DocPageTitles[i];
				doc.Words.Last.InsertBreak(WdBreakType.wdPageBreak);
			}

			var filePath = TestDocPath as object;
            doc.SaveAs(ref filePath);
            ((_WordDocument)doc).Close();
            ((_WordApplication)word).Quit();
		}
		public static void MyClassInitialize(TestContext testContext)
		{
			if (!Directory.Exists(Utility.RootFolder))
			{
				Directory.CreateDirectory(Utility.RootFolder);
			}
			if (!Directory.Exists(Utility.TempFolder))
			{
				Directory.CreateDirectory(Utility.TempFolder);
			}
			_mXmlNs = Utility.NS;
			_mOnGenerator = new OneNoteGenerator(Utility.RootFolder);
			// Get the id of the Trainer and student notebooks
			_mTrainerNotebookId = _mOnGenerator.CreateNotebook(TrainerNotebookName);
			_mStudentNotebookId = _mOnGenerator.CreateNotebook(StudentNotebookName);
		}
		public static void InitializeTestNotebook(TestContext testContext)
		{
			_mXmlNs = Utility.NS;

			_mTestNotebookDir = Path.GetTempPath();

			_mOneNoteGenerator = new OneNoteGenerator(_mTestNotebookDir);
			_mTestNotebookId = _mOneNoteGenerator.CreateNotebook(TestNotebookName);
			_mTestSectionId = _mOneNoteGenerator.CreateSection(TestSectionName, _mTestNotebookId);
			//for ValidateCreateSectionNameConflicts()
			_mOneNoteGenerator.CreateSection(TestSectionName, _mTestNotebookId);
			_mOneNoteGenerator.CreateSection(TestSectionName, _mTestNotebookId);

			_mTestPageId = _mOneNoteGenerator.CreatePage(TestPageName, _mTestSectionId);
			
			//This is ugly, but apparently creating notebook/section/page takes time
			Thread.Sleep(4000);
		}
		public static void MyClassInitialize(TestContext testContext)
		{
			if (!Directory.Exists(Utility.RootFolder))
			{
				Directory.CreateDirectory(Utility.RootFolder);
			}
			if (!Directory.Exists(Utility.TempFolder))
			{
				Directory.CreateDirectory(Utility.TempFolder);
			}
			_mXmlNs = Utility.NS;
			_mOnGenerator = new OneNoteGenerator(Utility.RootFolder);

			//Get Id of the test notebook so we chould retrieve generated content
			//KindercareFormatConverter will create notebookName as Kindercare
			_mNotebookId = _mOnGenerator.CreateNotebook(NotebookName);

			// used to generate a test docx
			var word = new Application();
			var doc = word.Application.Documents.Add();

			//construct "table of content" page
			//skip the first one, which will be generated by converter
			foreach(var s in pageTitles.Skip(1))
			{
				doc.Content.Text += s;
			}

			//construct other pages
			for (int i = 2; i < pageTitles.Count; i++)
			{
				doc.Words.Last.InsertBreak(WdBreakType.wdPageBreak);
				doc.Content.Text += pageTitles[i];
				doc.Content.Text += "this is a sample page";
			}

			//save the docx as a temporary file
			var fileFullPath = TestDocPath as object;
            doc.SaveAs(ref fileFullPath);
            ((_WordDocument)doc).Close();
            ((_WordApplication)word).Quit();
		}
		/// <summary>
		/// Converts PowerPoint presentan to OneNote while converting the sections in power point to main pages, and slides to sub pages
		/// It creates two notebooks, one for the Trainer and one for the student
		/// </summary>
		/// <param name="pptOpenXml"></param>
		/// <param name="imgsPath"></param>
		/// <param name="note"></param>
		/// <param name="sectionName"></param>
		protected override void ConvertPowerPointToOneNote(PowerPointOpenXml pptOpenXml, string imgsPath, OneNoteGenerator note,
			string sectionName)
		{
			string trainerNotebookId = String.Empty;
			string trainerSectionId = String.Empty;
			if (IncludeTrainerNotebook())
			{
				// Create the student notebook
				trainerNotebookId = note.CreateNotebook(TrainerNotebook);
				trainerSectionId = note.CreateSection(sectionName, trainerNotebookId);
			}

			string studentNotebookId = String.Empty;
			string studentSectionId = String.Empty;
			if (IncludeStudentNotebook())
			{
				// Create the student notebook
				studentNotebookId = note.CreateNotebook(StudentNotebook);
				studentSectionId = note.CreateSection(sectionName, studentNotebookId);
			}

			if (pptOpenXml.HasSections())
			{
				List<string> sectionNames = pptOpenXml.GetSectionNames();
				List<List<int>> slidesInSections = pptOpenXml.GetSlidesInSections();

				if (IncludeTrainerNotebook())
					ConvertPowerPointWithSectionsToOneNote(pptOpenXml, imgsPath, note, trainerSectionId, sectionNames, slidesInSections, true);

				if (IncludeStudentNotebook())
					ConvertPowerPointWithSectionsToOneNote(pptOpenXml, imgsPath, note, studentSectionId, sectionNames, slidesInSections, false);
			}
			else
			{
				if (IncludeTrainerNotebook())
					ConvertPowerPointWithoutSectionsToOneNote(pptOpenXml, imgsPath, note, trainerSectionId, true);

				if (IncludeStudentNotebook())
					ConvertPowerPointWithoutSectionsToOneNote(pptOpenXml, imgsPath, note, studentSectionId, false);
			}
		}
		/// <summary>
		/// Converts the Word document input file into OneNote
		/// </summary>
		/// <param name="inputFile"></param>
		/// <param name="outputDir"></param>
		public virtual bool ConvertWordToOneNote(string inputFile, string outputDir)
		{
			var retVal = false;

			string inputFileName = Path.GetFileNameWithoutExtension(inputFile);

			var tempPath = outputDir + "\\temp\\";
			if (!Directory.Exists(tempPath))
			{
				Directory.CreateDirectory(tempPath);
			}

			object tempHtmlFilePath = tempPath + inputFileName + HtmlFileExtension;
			object htmlFilteredFormat = WdSaveFormat.wdFormatFilteredHTML;

			//used to get pictures in word document
			object auxiliaryFilePath = tempPath + inputFileName + AuxFileSuffix;
			object htmlFormat = WdSaveFormat.wdFormatHTML;
			var auxiliaryFilePicFolder = auxiliaryFilePath + AuxFileLocationSuffix;
			var originalFilePicFolder = tempPath + inputFileName + AuxFileLocationSuffix;

			try
			{
				//Save the word document as a HTML file temporarily
				var word = new WordApplication();
				var doc = word.Documents.Open(inputFile);

				doc.SaveAs(ref tempHtmlFilePath, ref htmlFilteredFormat);
				doc.SaveAs(ref auxiliaryFilePath, ref htmlFormat);

                ((_WordDocument)doc).Close();
                ((_WordApplication)word).Quit();

				//Create a new OneNote Notebook
				var note = new OneNoteGenerator(outputDir);
				var notebookId = note.CreateNotebook(GetSupportedInputFormat());
				var sectionId = note.CreateSection(inputFileName, notebookId);

				//Now migrate the content in the temporary HTML file into the newly created OneNote Notebook
				if (ConvertHtmlToOneNote(tempHtmlFilePath.ToString(), originalFilePicFolder, auxiliaryFilePicFolder, note, sectionId))
				{
					//Generate table of content
					note.CreateTableOfContentPage(sectionId);
					retVal = true;
				}
			}
			finally
			{
				Utility.DeleteDirectory(tempPath);
			}

			return retVal;
		}
		/// <summary>
		/// Helper method to include the common code between the trainer and the student create notebook when converting 
		/// Power Point files that doesn't have sections
		/// </summary>
		/// <param name="pptOpenXml"></param>
		/// <param name="imgsPath"></param>
		/// <param name="note"></param>
		/// <param name="sectionId"></param>
		/// <param name="isTrainer"></param>
		private void ConvertPowerPointWithoutSectionsToOneNote(PowerPointOpenXml pptOpenXml, string imgsPath, OneNoteGenerator note,
			string sectionId, bool isTrainer)
		{
			for (var i = 1; i <= pptOpenXml.NumberOfSlides(); i++)
			{
				string pageId;
				if (isTrainer)
				{
					pageId = InsertPowerPointSlideInOneNote(i, pptOpenXml, imgsPath, note, sectionId, 
						true, StudentNotesTitle, true, TrainerNotesTitle);
				}
				else
				{
					pageId = InsertPowerPointSlideInOneNote(i, pptOpenXml, imgsPath, note, sectionId, 
						true, StudentNotesTitle, false);
				}
				if (!pageId.Equals(String.Empty))
				{
					note.SetShowDate(pageId, false);
					note.SetShowTime(pageId, false);
				}
			}
			string tocPageId = note.CreateTableOfContentPage(sectionId);
			note.SetShowDate(tocPageId, false);
			note.SetShowTime(tocPageId, false);
		}
		/// <summary>
		/// Helper method to include the common code between the trainer and the student create notebook when converting 
		/// Power Point files that have sections
		/// </summary>
		/// <param name="pptOpenXml"></param>
		/// <param name="imgsPath"></param>
		/// <param name="note"></param>
		/// <param name="sectionId"></param>
		/// <param name="sectionNames"></param>
		/// <param name="slidesInSections"></param>
		/// <param name="isTrainer"></param>
		private void ConvertPowerPointWithSectionsToOneNote(PowerPointOpenXml pptOpenXml, string imgsPath, OneNoteGenerator note, 
			string sectionId, List<string> sectionNames, List<List<int>> slidesInSections, bool isTrainer)
		{
			var pptSectionsPageIds = new List<string>();

			for (int i = 0; i < sectionNames.Count; i++)
			{
				string pptSectionPageId = note.CreatePage(sectionNames[i], sectionId);
				foreach (var slideNumber in slidesInSections[i])
				{
					string pageId;
					if (isTrainer)
					{
						pageId = InsertPowerPointSlideInOneNote(slideNumber, pptOpenXml, imgsPath, note, sectionId,
							true, StudentNotesTitle, true, TrainerNotesTitle);

					}
					else
					{
						pageId = InsertPowerPointSlideInOneNote(slideNumber, pptOpenXml, imgsPath, note, sectionId,
							true, StudentNotesTitle, false);
					}
					if (!pageId.Equals(String.Empty))
					{
						note.SetSubPage(sectionId, pageId);
						note.SetShowDate(pageId, false);
						note.SetShowTime(pageId, false);
					}
				}
				pptSectionsPageIds.Add(pptSectionPageId);
			}

			string tocPageId = note.CreateTableOfContentPage(sectionId);
			note.SetShowDate(tocPageId, false);
			note.SetShowTime(tocPageId, false);

			foreach (var pptSectionPageId in pptSectionsPageIds)
			{
				note.SetCollapsePage(pptSectionPageId);
				note.SetShowDate(pptSectionPageId, false);
				note.SetShowTime(pptSectionPageId, false);
			}
		}
		/// <summary>
		/// Converts Html file into OneNote Section of Pages
		/// </summary>
		/// <param name="inputFile"></param>
		/// <param name="originalPicFolder"></param>
		/// <param name="auxInputFolder"></param>
		/// <param name="onGenerator"></param>
		/// <param name="sectionId"></param>
		/// <returns></returns>
		protected override bool ConvertHtmlToOneNote(string inputFile, string originalPicFolder, string auxInputFolder, OneNoteGenerator onGenerator, string sectionId)
		{
			var retVal = false;

			try
			{
				string htmlContent;
				using (var sr = new StreamReader(inputFile, Encoding.Default))
				{
					htmlContent = sr.ReadToEnd();
				}

				var doc = new HtmlDocument();
				doc.LoadHtml(htmlContent);

				var content = doc.DocumentNode;

				//outer html contains format information
				var htmlBox = doc.DocumentNode;
				//list of onenote page Id 
				var pageIdList = new List<string>();
				//list of onenote page/subpage name
				var pageNameList = new List<string>();
				//separate the whole doc into pages
				var pages = SeparatePages(content) as List<List<HtmlNode>>;
				//get chapter names from table contents
				var chapterNameList = new List<string>();

				//may produce problem by calling first()
				//maybe empty page with pageNameList[0] = null, fix later
				var tableContent = pages.FirstOrDefault();
				if (tableContent != null)
				{
					foreach (var node in tableContent)
					{
						chapterNameList.Add(node.InnerText.Replace("\r\n", " ").Trim());
					}
				}

				//store errors occurred during conversion 
				var errorList = new List<Dictionary<InfoType, string>>();

				//print pages to onenote
				foreach (var page in pages)
				{
					var pageTitle = GetPageTitle(page);
					var pageId = onGenerator.CreatePage(pageTitle, sectionId);

					var errorInfo = new Dictionary<InfoType, string>();
					var pageContent = GeneratePageContent(htmlBox, page, originalPicFolder, auxInputFolder, errorInfo);
					onGenerator.AddPageContentAsHtmlBlock(pageId, pageContent);

					pageIdList.Add(pageId);
					pageNameList.Add(pageTitle);

					if (errorInfo.Count > 0)
					{
						errorInfo.Add(InfoType.Id, pageId);
						errorInfo.Add(InfoType.Title, pageTitle);
						errorList.Add(errorInfo);
					}
				}
				if (errorList.Count > 0)
				{
					CreateErrorPage(onGenerator, sectionId, errorList);
				}
				//set some pages as subpages according to observed rules
				var lastSeenChapterName = String.Empty;
				for (int i = 0; i < pageIdList.Count; i++)
				{
					var pageId = pageIdList[i];
					var name = pageNameList[i];
					//check if the page name is a chapter name (a substring of table content items)
					var isChapterName = chapterNameList.Any(x => x.Contains(name));

					bool isSubpage = !isChapterName && name != lastSeenChapterName;

					//if it is a new chapter name, set it as a page
					//if it is not a chapter name, but it is the first of consecutive same name pages, set it as a page
					if (isChapterName == false 
						&& i > 0 && name != pageNameList[i - 1] 
						&& i < pageNameList.Count && name == pageNameList[i + 1])
					{
						isSubpage = false;
					}

					if (isSubpage)
					{
						onGenerator.SetSubPage(sectionId, pageId);
					}
					if (isChapterName)
					{
						lastSeenChapterName = name;
					}
				}
				retVal = true;
			}
			catch (Exception e)
			{
				Console.WriteLine(e.Message);
				retVal = false;
			}

			return retVal;
		}
		/// <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;
		}
		/// <summary>
		/// Converts PowerPoint presentan to OneNote while converting the sections in power point to main pages, and slides to sub pages
		/// </summary>
		/// <param name="pptOpenXml"></param>
		/// <param name="imgsPath"></param>
		/// <param name="note"></param>
		/// <param name="sectionName"></param>
		protected virtual void ConvertPowerPointToOneNote(PowerPointOpenXml pptOpenXml, string imgsPath, OneNoteGenerator note,
			string sectionName)
		{
			string notebookId = note.CreateNotebook(GetSupportedInputFormat());
			string sectionId = note.CreateSection(sectionName, notebookId);

			if (pptOpenXml.HasSections())
			{
				List<string> sectionNames = pptOpenXml.GetSectionNames();
				List<List<int>> slidesInSections = pptOpenXml.GetSlidesInSections();
				var pptSectionsPageIds = new List<string>();
				for (int i = 0; i < sectionNames.Count; i++)
				{
					string pptSectionPageId = note.CreatePage(sectionNames[i], sectionId);
					foreach (var slideNumber in slidesInSections[i])
					{
						string pageId = InsertPowerPointSlideInOneNote(slideNumber, pptOpenXml, imgsPath, note, sectionId);
						if (!String.IsNullOrEmpty(pageId))
						{
							note.SetSubPage(sectionId, pageId);
						}
					}
					pptSectionsPageIds.Add(pptSectionPageId);
				}

				note.CreateTableOfContentPage(sectionId);

				foreach (var pptSectionPageId in pptSectionsPageIds)
				{
					note.SetCollapsePage(pptSectionPageId);
				}
			}
			else
			{
				for (var i = 1; i <= pptOpenXml.NumberOfSlides(); i++)
				{
					InsertPowerPointSlideInOneNote(i, pptOpenXml, imgsPath, note, sectionId);
				}
			}
		}
		/// <summary>
		/// Converts PDF file to OneNote by including an image for each page in the document
		/// </summary>
		/// <param name="inputFile">PDF document path</param>
		/// <param name="outputDir">Directory of the output OneNote Notebook</param>
		/// <returns></returns>
		public virtual bool ConvertPdfToOneNote(string inputFile, string outputDir)
		{
			//Get the name of the file
			string inputFileName = Path.GetFileNameWithoutExtension(inputFile);

			//Create a new OneNote Notebook
			var note = new OneNoteGenerator(outputDir);
			string notebookId = note.CreateNotebook(GetSupportedInputFormat());
			string sectionId = note.CreateSection(inputFileName, notebookId);

			using (var rasterizer = new GhostscriptRasterizer())
			{
				rasterizer.Open(inputFile);
				for (var i = 1; i <= rasterizer.PageCount; i++)
				{
					Image img = rasterizer.GetPage(160, 160, i);
					MemoryStream stream = new MemoryStream();
					img.Save(stream, ImageFormat.Png);
					img = Image.FromStream(stream);

					string pageId = note.CreatePage(String.Format("Page{0}", i), sectionId);
					note.AddImageToPage(pageId, img);
				}
			}

			note.CreateTableOfContentPage(sectionId);

			return true;
		}
		/// <summary>
		/// Create the error page for the section, which contains all the errors occurred during the conversion
		/// </summary>
		/// <param name="onGenerator"></param>
		/// <param name="sectionId"></param>
		/// <param name="errorList"></param>
		protected void CreateErrorPage(OneNoteGenerator onGenerator, string sectionId, IEnumerable<IDictionary<InfoType, string>> errorList)
		{
			var pageId = onGenerator.CreatePage(ErrorPageTitle, sectionId);
			var pageContent = String.Empty;
			foreach (var error in errorList)
			{
				var hyperLink = onGenerator.GetHyperLinkToObject(error[InfoType.Id]);
				pageContent += string.Format("<a href=\"{0}\">{1} : \n{2}</a>", hyperLink, error[InfoType.Title], error[InfoType.Message]) + "\n\n";
			}
			onGenerator.AddPageContent(pageId, pageContent);
		}
		/// <summary>
		/// Converts Html file into OneNote Section of Pages
		/// </summary>
		/// <param name="inputFile"></param>
		/// <param name="originalPicFolder"></param>
		/// <param name="auxPicFolder"></param>
		/// <param name="onGenerator"></param>
		/// <param name="sectionId"></param>
		/// <returns></returns>
		protected virtual bool ConvertHtmlToOneNote(string inputFile, string originalPicFolder, string auxPicFolder, OneNoteGenerator onGenerator, string sectionId)
		{
			var retVal = false;
			var htmlContent = string.Empty;

			try
			{
				using (var sr = new StreamReader(inputFile, Encoding.Default))
				{
					htmlContent = sr.ReadToEnd();
				}

				var htmlDoc = new HtmlDocument();
				htmlDoc.LoadHtml(htmlContent);

				//Preserve the HTML surrounding tags
				var content = htmlDoc.DocumentNode;

				var previousPageTitle = string.Empty;

				//store error info
				var errorList = new List<Dictionary<InfoType, string>>();

				foreach (var page in SeparatePages(content))
				{
					if (page != null)
					{
						//Get page title
						var pageTitle = GetPageTitle(page);

						//Create the page
						var pageId = onGenerator.CreatePage(pageTitle, sectionId);

						//error info
						var errorInfo = new Dictionary<InfoType, string>();

						//Add the content of the page
						var pageContent = GeneratePageContent(content, page, originalPicFolder, auxPicFolder, errorInfo);
						onGenerator.AddPageContentAsHtmlBlock(pageId, pageContent);

						//Attempt to do subpage
						if (!pageTitle.Equals(DefaultPageTitle, StringComparison.CurrentCultureIgnoreCase) &&
							pageTitle.Equals(previousPageTitle, StringComparison.CurrentCultureIgnoreCase))
						{
							onGenerator.SetSubPage(sectionId, pageId);
						}

						previousPageTitle = pageTitle;

						if (errorInfo.Count > 0)
						{
							errorInfo.Add(InfoType.Id, pageId);
							errorInfo.Add(InfoType.Title, pageTitle);
							errorList.Add(errorInfo);
						}
					}
				}
				if (errorList.Count > 0)
				{
					CreateErrorPage(onGenerator, sectionId, errorList);
				}

				retVal = true;
			}
			catch (Exception e)
			{
				Console.WriteLine(e.Message);
				retVal = false;
			}

			return retVal;
		}
		/// <summary>
		/// Converts the ePub document input file into OneNote
		/// </summary>
		/// <param name="inputFile"></param>
		/// <param name="outputDir"></param>
		/// <returns></returns>
		public virtual bool ConvertEpubToOneNote(string inputFile, string outputDir)
		{
			try
			{
				// Initialize epub reader class
				var epub = new EpubReader(inputFile, outputDir);

				// Get the page contents
				List<string> pageTitles = epub.GetPageTitles();
				List<HtmlDocument> pagesHtml = epub.GetPagesAsHtmlDocuments();
				List<string> pagePaths = epub.GetPagePaths();
				Dictionary<string, int> pagesLevel = epub.GetPagesLevel();

				// Create a new OneNote Notebook
				var note = new OneNoteGenerator(outputDir);
				string notebookId = note.CreateNotebook(GetSupportedInputFormat());
				string sectionId = note.CreateSection(epub.GetTitle(), notebookId);

				// Create pages
				var pageIds = pageTitles.Select(pageTitle => note.CreatePage(pageTitle, sectionId)).ToArray();

				// Get links to pages
				var pageLinks = pageIds.Select(pageId => note.GetHyperLinkToObject(pageId)).ToList();

				// Replace links to .html with .one
				ReplaceEpubLinksFromHtmlToOneNote(pagesHtml, pagePaths, pageLinks);

				// Add content to pages
				for (var i = 0; i < pageIds.Length; i++)
				{
					note.AppendPageContentAsHtmlBlock(pageIds[i], pagesHtml[i].DocumentNode.OuterHtml);
					if (pagesLevel.ContainsKey(pagePaths[i]))
					{
						note.SetPageLevel(pageIds[i], pagesLevel[pagePaths[i]]);
					}
				}

				return true;
			}
			catch (Exception e)
			{
				Console.WriteLine(@"Error in ConvertEpubToOneNote for file {0}: {1}", inputFile, e.Message);
				return false;
			}
		}
		/// <summary>
		/// Converts the InDesign document input file into OneNote
		/// </summary>
		/// <param name="inputFile"></param>
		/// <param name="outputDir"></param>
		/// <returns></returns>
		public virtual bool ConvertInDesignToOneNote(string inputFile, string outputDir)
		{
#if INDESIGN_INSTALLED
			// get the file name
			string inputFileName = Path.GetFileNameWithoutExtension(inputFile);

			// gets the InDesign App
			Type inDesignAppType = Type.GetTypeFromProgID(ConfigurationManager.AppSettings.Get("InDesignProgId"));
            if (inDesignAppType == null) throw new InvalidOperationException("Failed to find InDesign application. Please ensure that it is installed and is running on your machine.");

			InDesignApplication app = (InDesignApplication)Activator.CreateInstance(inDesignAppType, true);

			// open the indd file
			try
			{
				app.Open(inputFile);
			}
			catch (Exception e)
			{
				Console.WriteLine(@"Error in ConvertInDesignToOneNote for file {0}: {1}", inputFile, e.Message);
				return false;
			}
			InDesignDocument doc = app.ActiveDocument;

			// temp directory for html
			string htmlDir = Utility.CreateDirectory(Utility.NewFolderPath(outputDir, "html"));

			// Get the file name
			string htmlFile = Utility.NewFilePath(htmlDir, inputFileName, HtmlFileExtension);

			// Save the html file
			SetInDesignHtmlExportOptions(doc);
			doc.Export(idExportFormat.idHTML, htmlFile);

			// Create a new OneNote Notebook
			var note = new OneNoteGenerator(outputDir);
			string notebookId = note.CreateNotebook(GetSupportedInputFormat());
			string sectionId = note.CreateSection(inputFileName, notebookId);


			// get the html
			var htmlDoc = new HtmlDocument();
			htmlDoc.Load(htmlFile);

			// change the links to have the full path
			ModifyInDesignHtmlLinks(htmlDoc, htmlDir);

			// get the title
			string title = GetInDesignTitle(htmlDoc);

			string pageId = note.CreatePage(title, sectionId);
			note.AddPageContentAsHtmlBlock(pageId, htmlDoc.DocumentNode.OuterHtml);

			return true;
#else		
			throw new NotImplementedException();
#endif
		}
		/// <summary>
		/// Converts PowerPoint presentation into OneNote section
		/// </summary>
		/// <param name="inputFile"></param>
		/// <param name="outputDir"></param>
		/// <returns></returns>
		public virtual bool ConvertPowerPointToOneNote(string inputFile, string outputDir)
		{
			// Get the name of the file
			string inputFileName = Path.GetFileNameWithoutExtension(inputFile);

			// Convert presentation slides to images
			string imgsPath = ConvertPowerPointToImages(inputFile, outputDir);

			// Create a new OneNote Notebook
			var note = new OneNoteGenerator(outputDir);

			// Convert to OneNote
			var pptOpenXml = new PowerPointOpenXml(inputFile);
			ConvertPowerPointToOneNote(pptOpenXml, imgsPath, note, inputFileName);

			// Delete the temperory imgs directory
			Utility.DeleteDirectory(imgsPath);

			return true;
		}