Image Display problem using Aspose word

Last post 06-25-2010, 11:28 PM by alexey.noskov. 3 replies.
Sort Posts: Previous Next
  •  06-05-2008, 7:48 PM 130275

    Image Display problem using Aspose word

    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") = "<img src='" & "\\Server\Media\Images\Image.Jpg'>"


    When i open my htm File, there is NO Image, All i see the Correct path to My Image

    <img src='\\Server\Media\Images\Image.Jpg'>

    Then if i Look at the Page Source i see the following

    <span style="font-family:'Arial Narrow'; font-size:10pt; font-weight:bold; ">SmallImage</span>
     </p><p style="margin-left:36pt; margin-right:0pt; margin-top:0pt; margin-bottom:0pt; text-indent:-36pt; ">
      <span style="font-family:'Arial Narrow'; font-size:10pt; ">&lt;&lt;img src='\\Server\Media\Images\Image.Jpg'>'&gt;</span>
      
      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
         <img src='\\Server\Media\Images\Image.Jpg'>
         
      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


    ---Daljinder--
    Filed under: Aspose Image Link
     
  •  06-06-2008, 4:09 AM 130324 in reply to 130275

    Re: Image Display problem using Aspose word

    Hi

     

    Thanks for your inquiry. This occurs because you insert HTML into the document as plain text. You should use MergeField event handler for inserting HTML snippets into the document during mail merge. Please see the following link to learn more.

    http://www.aspose.com/documentation/file-format-components/aspose.words-for-.net-and-java/aspose.words.reporting.mailmerge.mergefield.html

     

    Hope this helps.

     

    Best regards.


    Alexey Noskov
    Developer/Technical Support
    Aspose Auckland Team
     
  •  06-25-2010, 7:46 PM 245611 in reply to 130324

    Re: Image Display problem using Aspose word

    the link you refer to is invalid...does not go to anything..please correct
     
  •  06-25-2010, 11:28 PM 245623 in reply to 245611

    Re: Image Display problem using Aspose word

    Hi

     

    Thanks for your request and my apologizes for inconvenience. The link was broken after refactoring our documentation some time ago. Here is correct link to this article:

    http://www.aspose.com/documentation/.net-components/aspose.words-for-.net/aspose.words.reporting.mergefieldeventhandler.html

     

    Hope this helps. Please let me know if you need more assistance, I will be glad to help you.

     

    Best regards.   


    Alexey Noskov
    Developer/Technical Support
    Aspose Auckland Team
     
View as RSS news feed in XML