i am sending you the code.
The first sub is used in replace evaluator. and after complete processing of the document the second sub is used to add the words and later i am adding the created section in the original document.
’’’
’’’ the subroutine below match each word from the database and if the word found it highlight the word.
’’’
Private Sub MarkSubstituteWords(ByVal run As Run)
Dim flagIsSynonym As Boolean = False
Dim word As String = run.Text
sqlCommand.CommandTimeout = 0
sqlConnection.Open()
sqlCommand = New SqlCommand("Select Words from Synonyms where Words=’" + Replace(Replace(word, "’", "’’"), "’", "’’") + "’", sqlConnection)
dataReader = sqlCommand.ExecuteReader()
While dataReader.Read()
‘run.Font.HighlightColor = System.Drawing.Color.FromArgb(255, 223, 223, 223) ‘working
‘run.Font.HighlightColor = System.Drawing.Color.FromArgb(255, 230, 230, 230) ‘not working
run.Font.Shading.BackgroundPatternColor = System.Drawing.Color.FromArgb(255, 241, 241, 241)
End While
dataReader.Close()
sqlConnection.Close()
End Sub
’’’
’’’ Subroutine to create document for the highlighted words by rarity…
’’’
Private Sub CreateDocumentSubWords(ByVal builder As DocumentBuilder)
If sqlConnection.State = ConnectionState.Closed Then
sqlConnection.Open()
End If
builder.Font.Name = "Verdana"
builder.Font.Size = 10
builder.Font.Bold = True
builder.Writeln("Highlighted Words")
builder.Font.Bold = False
builder.Writeln()
builder.CellFormat.Width = 140
builder.InsertCell()
builder.Font.Bold = True
builder.Write("Original Word")
builder.Font.Bold = False
builder.InsertCell()
builder.Font.Bold = True
builder.Write("Substitute Word(s)**")
builder.Font.Bold = False
builder.EndRow()
’ method call. the below method have two arguments- ‘’ colorCode is the color (from 9 colors) which will use to color the table
’ and create the table cell for all words with respective color
NewGetWordsFromDataBase(builder, colorCode)
builder.EndTable()
builder.Writeln()
builder.Font.Bold = False
builder.Write("** Words with suggested substitutes have ")
'builder.Font.HighlightColor = System.Drawing.Color.FromArgb(255, 223, 223, 223)
builder.Font.Shading.BackgroundPatternColor = System.Drawing.Color.FromArgb(255, 241, 241, 241)
builder.Write("gray background")
'builder.Font.HighlightColor = System.Drawing.Color.White
builder.Font.Shading.BackgroundPatternColor = System.Drawing.Color.White
builder.Write(". Please try some more documents and get the facility to color specify the words using different colors")
sqlConnection.Close()
End Sub
I have attached a document which have all the colors which I am using
please check this and help me asap.