OneNoteConversionTool.OutputGenerator.OneNoteGenerator.AddPageContent C# (CSharp) Method

AddPageContent() public method

Adds the content to the corresponding page.
public AddPageContent ( string pageId, string content, int yPos = 80, int width = 520 ) : void
pageId string Page Identifier in which the content to be displayed.
content string The content which needs to be added to the page.
yPos int Starting vertical position of the block in the page in Pixels from the top of the page
width int Maximum width of the outline block where the content is added
return void
		public void AddPageContent(string pageId, string content, int yPos = 80, int width = 520)
		{
			var doc = GetPageContent(pageId);
			var page = doc.SelectSingleNode("//one:Page", GetNSManager(doc.NameTable));
			if (page == null)
				return;

			var childOutline = doc.CreateElement("one:Outline", NS);
			
			try
			{
				childOutline.InnerText = string.Format(WordOutline, yPos, content, width);
				

				page.AppendChild(childOutline);
				string childContent = Utility.UnescapeXml(childOutline.InnerXml);
				string newPageContent = doc.InnerXml.Replace(childOutline.InnerXml, childContent);
				_mApp.UpdatePageContent(newPageContent, DateTime.MinValue);
			}
			catch (Exception e)
			{
				throw new ApplicationException("Error in AddPageContent: " + e.Message, e);
			}
		}

Usage Example

		/// <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);
		}