CommentsNoPdf.vb
''
'' This code is part of GrapeCity Documents for Word samples.
'' Copyright (c) GrapeCity, Inc. All rights reserved.
''
Imports System.Collections.Generic
Imports System.Drawing
Imports System.Linq
Imports GrapeCity.Documents.Word
Imports GrapeCity.Documents.Layout

'' This sample Is identical to Comments. The only difference Is
'' that in PDF export, comments are ignored. This Is achieved by
'' providing a GetPdfConversionOptions method used by the sample
'' browser's infrastructure when it calls the SaveAsPdf method
'' on the generated document.
Public Class CommentsNoPdf
    Function CreateDocx() As GcWordDocument
        Dim user1 = "Jaime Smith" '' user name For comments' author
        Dim user2 = "Jane Donahue" '' user name For comments' author

        Dim doc = New GcWordDocument()

        Dim pars = doc.Body.Sections.First.GetRange().Paragraphs

        Dim p1 = pars.Add("Paragraph 1: This is a paragraph of text with a comment added to the whole paragraph. ")
        Dim c1 = p1.GetRange().Comments.Add("Comment added to paragraph 1.", user1, DateTime.Now, "J.S.")
        Dim c2 = c1.Reply("Reply to comment 1.", user2)
        Dim c3 = c2.Reply("Reply to comment 2, closing the thread.", user1)
        c3.Done = True

        Dim p2 = pars.Add("Paragraph 2: This is another paragraph of text, with a comment added to 3rd run. ")
        p2.GetRange().Runs.Add("This is run 2 of paragraph 2. ")
        Dim r = p2.GetRange().Runs.Add("This is run 3 of paragraph 2 with a comment. ")
        r.GetRange().Comments.Insert("Comment on run 3 of paragraph 2", user2, RangeLocation.Whole)
        p2.GetRange().Runs.Add("This is run 4 of paragraph 2. ")
        p2.GetRange().Runs.Add("This is run 5 of paragraph 2. ")
        p2.GetRange().Runs.Add("This is run 6 of paragraph 2. ")

        '' Done
        Return doc
    End Function

    '' Optional static method. If it Is defined on a sample class,
    '' these options are used when saving the document to PDF.
    Shared Function GetPdfConversionOptions() As PdfConversionOptions
        Return New PdfConversionOptions() With
            {
                .CommentsMode = PdfConversionOptions.CommentsExportMode.None
            }
    End Function
End Class