Hi
Last week I downloaded an evaluation version of Aspose.Word for evaluation if this product matches to our requirement, and i have come across this Issue.
I am using Mail merge then pass a DataSet with all the fields required. When i open the file all the Merged fields have Data in them except the Merged Field whose value is Link to an Image.
I am providing my Code & my findings:
------------------------------------------------
Dim objAsposeWord As Aspose.Words.Document
Dim license As Aspose.Words.License = New Aspose.Words.License
license.SetLicense("") 'Cannot find my License file so using Empty
strGuid = objGetGuid.getGUID
strDestination = System.Configuration.ConfigurationManager.AppSettings("DownloadDirectory") & "\" & strGuid
'Open Existing Doc file with Merge Fields
objAsposeWord = New Aspose.Words.Document("C:\STOCK.doc")
objAsposeWord.MailMerge.ExecuteWithRegions(objDataset)
objAsposeWord.Save("C:\Test.htm", Aspose.Words.SaveFormat.Html)
'Another Function to Save as DOC & Embedd Images
FormatWordDocument("C:\Test.htm")
Public Function FormatWordDocument(ByRef strDocumentName As String) As Boolean
Dim objWordApp As New Word.ApplicationClass()
Dim objWordDoc As Word.Document
Dim oField As Word.Field
objWordDoc = objWordApp.Documents.Open(strDocumentName)
objWordDoc.PageSetup.TopMargin = 30
objWordDoc.PageSetup.LeftMargin = 30
objWordDoc.PageSetup.RightMargin = 30
objWordDoc.PageSetup.BottomMargin = 30
For Each oField In objWordDoc.Application.ActiveDocument.Fields
If oField.Type = Word.WdFieldType.wdFieldIncludePicture Then
oField.LinkFormat.SavePictureWithDocument = True
End If
Next
objWordDoc.SaveAs(Replace(strDocumentName, "htm", "doc"), Word.WdSaveFormat.wdFormatDocument)
objWordApp.Quit()
End Function
------------------------------------------------
Here are My Findings :-
In my “Stock.Doc” I have a Merged Field which provides a links to a Image
Merged Field Name = "SmallImage"
Here is how i Create a DataRow Field in my Data Set
objDataRow("SmallImage") = "\\Server\Media\Images\Image.Jpg'>"
When i open my htm File, there is NO Image, All i see the Correct path to My Image
Then if i Look at the Page Source i see the following
SmallImage
<<img src='\\Server\Media\Images\Image.Jpg'>>
You can the Link to Image is Missing < before IMG SRC
<img src='\\Server\Media\Images\Image.Jpg'>
If i add < Manually and change the above text to
I can see the Image.
I cannot understand i am making a mistake, Because when i Create a Link in My DataSet the string is Fine.
Can you help?
Daljinder