Free Support Forum - aspose.com

Font changing in bookmarks from what was in initial template

Hi,

we have a template with bookmarks used for data substitution - when the document is udpdated the font in some of the bookmarks changes from what was in the template. Can you please have a look at the templatre and see if there is anything in the formatting that is causing this?

Template and output are attached.

thanks
Simon

Hi

Thanks for your request. Please tell me which of bookmarks has been changed. Also, attach some code that you use to populate data.

Best regards.

Hi Vitaly,

one of the bookmarks that had text changed is Nationality another is LanguageDescription -as well as that some of the statis text in the table such as "XXX Consulting" and "Main RD YYY" has changed from Times-Roman 11 to Times-Roman 10.

Sample of code where the bookmarks have bene linked with available data fields and a sql statement is run for each bookmark to find the table/column/data type it has to retrieve data for. The GetText function etc just return strings in required format.

It has all worked fine for several other templates which makes me think that they have done something to the formatting of this one but I cannot see what. Any help would be much appreciated.

There is other code which goes through tables that have multiple rows and copies the table and then replaces the bookmarks as many times as there are rows of data however the code to do that isn't needed in this example as I cut the template down.

thanks
Simon

....
Dim oDoc As New Aspose.Words.Document(sTemplateName.ToString)
Dim bookmarks As Aspose.Words.Bookmarks = oDoc.Range.Bookmarks
Dim bookmark As Aspose.Words.Bookmark

-- parse sql statement here

For Each bookmark In bookmarks
Dim objConn As New SqlConnection(connString.ConnectionString)
Dim objCommand As New SqlCommand(sql, objConn)
Dim rs As SqlDataReader
objCommand.Parameters.Add("@TemplateID", SqlDbType.Int).Value = nTemplateID
objCommand.Parameters.Add("@WordTemplate", SqlDbType.VarChar).Value = bookmark.Name
objConn.Open()
rs = objCommand.ExecuteReader()
If rs.Read Then
Select Case rs("FieldTypeID")
Case 1
bookmark.Text = GetText(nStaffID, nTemplateID, rs("TableName"), rs("ColumnName"))
Case 2
bookmark.Text = GetBulletedText(nStaffID, nTemplateID, rs("TableName"), rs("ColumnName"))
Case 5
bookmark.Text = GetDate(nStaffID, nTemplateID, rs("TableName"), rs("ColumnName"), rs("DateFormat"))
Case 6
bookmark.Text = GetMultilineText(nStaffID, nTemplateID, rs("TableName"), rs("ColumnName"))
Case 7
bookmark.Text = GetCSVText(nStaffID, nTemplateID, rs("TableName"), rs("ColumnName"))
Case Else
bookmark.Text = GetText(nStaffID, nTemplateID, rs("TableName"), rs("ColumnName"))
End Select
End If

Hi

Thanks for additional information. I have reproduced this problem and logged to our defect base as issue # 3590. We will try to fix it in one of future releases.

But now if set font size 10 or 12, but not 11 all works well.

Best regards.

Hi

thanks for that - I have another template which I shortened and it is along the same lines as the previous one however this one when generated through the same code leaves the text as Times-Roman 11. I can't find what the difference is in the templates but there maybe some auto format setting on - is it possible for you to check please? Sorry but I don't know a lot about MS word apart from the basics.

thanks
Simon

Hi

There are different bookmarks in these documents. You can use DocumentExplorer from Aspose demo projects to analyze your documents.

Best regards.

The issues you have found earlier (filed as 3590) have been fixed in this update.