/// <summary> /// Gets document comments of Doc file /// </summary> public static void GetDocumentComments() { try { // initialize DocFormat DocFormat docFormat = new DocFormat(Common.MapSourceFilePath(filePath)); //get comments... DocComment[] comments = docFormat.ExtractComments(); //get commnets by author... //DocComment[] comments = docFormat.ExtractComments("USMAN"); // display comments foreach (DocComment comment in comments) { Console.WriteLine("Author: ", comment); Console.WriteLine("Created on Date: ", comment.CreatedDate); Console.WriteLine("Initials: ", comment.Initials); Console.WriteLine("\n"); } } catch (Exception exp) { Console.WriteLine(exp.Message); } }
/// <summary> /// Updates document comments of Doc file /// </summary> public static void UpdateComments() { try { //ExStart:UpdateDocumentComment // initialize DocFormat DocFormat docFormat = new DocFormat(Common.MapSourceFilePath(filePath)); // extract comments DocComment[] comments = docFormat.ExtractComments(); if (comments.Length > 0) { // get first comment if exist var comment = comments[0]; // change comment's author comment.Author = "Jack London"; // change comment's text comment.Text = "This comment is created using GroupDocs.Metadata"; // update comment docFormat.UpdateComment(comment.Id, comment); } // save file in destination folder docFormat.Save(Common.MapDestinationFilePath(filePath)); Console.WriteLine("File saved in destination folder."); //ExEnd:UpdateDocumentComment } catch (Exception exp) { Console.WriteLine(exp.Message); } }
/// <summary> /// Gets document comments of Doc file /// </summary> public static void GetDocumentComments() { try { // initialize DocFormat DocFormat docFormat = new DocFormat(Common.MapSourceFilePath(filePath)); //get comments... DocComment[] comments = docFormat.ExtractComments(); //get commnets by author... //DocComment[] comments = docFormat.ExtractComments("USMAN"); // display comments foreach (DocComment comment in comments) { Console.WriteLine("Author: ", comment.Author); Console.WriteLine("Created on Date: ", comment.CreatedDate); Console.WriteLine("Initials: ", comment.Initials); Console.WriteLine("\n"); } } catch (Exception exp) { Console.WriteLine(exp.Message); } }