CommentsNoPdf.vb
  1. ''
  2. '' This code is part of Document Solutions for Word demos.
  3. '' Copyright (c) MESCIUS inc. All rights reserved.
  4. ''
  5. Imports System.Collections.Generic
  6. Imports System.Drawing
  7. Imports System.Linq
  8. Imports GrapeCity.Documents.Word
  9. Imports GrapeCity.Documents.Word.Layout
  10.  
  11. '' This sample Is identical to Comments. The only difference Is
  12. '' that in PDF export, comments are ignored. This Is achieved by
  13. '' providing a GetPdfConversionOptions method used by the sample
  14. '' browser's infrastructure when it calls the SaveAsPdf method
  15. '' on the generated document.
  16. Public Class CommentsNoPdf
  17. Function CreateDocx() As GcWordDocument
  18. Dim user1 = "Jaime Smith" '' user name For comments' author
  19. Dim user2 = "Jane Donahue" '' user name For comments' author
  20.  
  21. Dim doc = New GcWordDocument()
  22.  
  23. Dim pars = doc.Body.Paragraphs
  24.  
  25. Dim p1 = pars.Add("Paragraph 1: This is a paragraph of text with a comment added to the whole paragraph. ")
  26. Dim c1 = p1.GetRange().Comments.Add("Comment added to paragraph 1.", user1, Util.TimeNow(), "J.S.")
  27. Dim c2 = c1.Reply("Reply to comment 1.", user2)
  28. Dim c3 = c2.Reply("Reply to comment 2, closing the thread.", user1)
  29. c3.Done = True
  30.  
  31. Dim p2 = pars.Add("Paragraph 2: This is another paragraph of text, with a comment added to 3rd run. ")
  32. p2.GetRange().Runs.Add("This is run 2 of paragraph 2. ")
  33. Dim r = p2.GetRange().Runs.Add("This is run 3 of paragraph 2 with a comment. ")
  34. r.GetRange().Comments.Insert("Comment on run 3 of paragraph 2", user2, RangeLocation.Whole)
  35. p2.GetRange().Runs.Add("This is run 4 of paragraph 2. ")
  36. p2.GetRange().Runs.Add("This is run 5 of paragraph 2. ")
  37. p2.GetRange().Runs.Add("This is run 6 of paragraph 2. ")
  38.  
  39. '' Done
  40. Return doc
  41. End Function
  42.  
  43. '' Optional static method. If it Is defined on a sample class,
  44. '' these options are used when saving the document to PDF.
  45. Shared Function GetWordLayoutSettings() As WordLayoutSettings
  46. Return New WordLayoutSettings() With
  47. {
  48. .CommentMode = WordCommentMode.None
  49. }
  50. End Function
  51. End Class
  52.