DocX icon indicating copy to clipboard operation
DocX copied to clipboard

The Picture Can't Be Displayed When Picture Is in a Table Inserted in a Word Doc Header

Open ramayanabali opened this issue 3 years ago • 3 comments

In xceed Words for NET 2.3 I constructed a one row table with two cells. I place a picture in the cells of the table. When I add the table to the document the table is displayed with the pictures. But when I add the table to the header or the footer, “The Picture Can’t Be Displayed.”

VB Code looks like this:

        document = xceed.Words.NET.DocX.Create(mstream)

        ' set margins 

        document.MarginTop = 72
        document.MarginBottom = 72
        document.MarginLeft = 40
        document.MarginRight = 40 
        
        ' get the logo 

        Dim LogoDrawing As System.Drawing.Image
        LogoDrawing = System.Drawing.Image.FromFile(HttpContext.Current.Server.MapPath("~/Images/" & LogoGif))
        Dim LogoImage As Xceed.Words.NET.Image
        LogoImage = document.AddImage(HttpContext.Current.Server.MapPath("~/Images/" & LogoGif))
        Dim LogoPicture As Xceed.Words.NET.picture = LogoImage.CreatePicture(LogoDrawing.Height, LogoDrawing.Width)
    
        ' set up the header table 
    
        Dim hdtb As Xceed.Words.NET.Table = document.AddTable( 1, 2 )
        Dim widths(2) As Single
        widths(0) = 300
        widths(1) = 300
        hdtb.SetWidths(widths)
        hdtb.Rows(0).Cells(0).Paragraphs(0).Append("").AppendPicture(LogoPicture)
        hdtb.Rows(0).Cells(1).Paragraphs(0).Append("").AppendPicture(LogoPicture) 

        ' generate header

        document.AddHeaders()
        document.Headers.Odd.InsertParagraph().Append("").InsertTableAfterSelf(hdtb)
        document.Headers.Even.InsertParagraph().Append("").InsertTableAfterSelf(hdtb)
                      
        document.InsertTable(hdtb)
    
        ' generate footer 

        document.AddFooters()
        document.Footers.Odd.InsertParagraph.Append("").InsertTableAfterSelf(hdtb)
        document.Footers.Even.InsertParagraph.Append("").InsertTableAfterSelf(hdtb)

Thank you for your help Chad sample.docx

ramayanabali avatar Jun 23 '22 17:06 ramayanabali

Hello, Yes, I think there is a problem. I can reproduce this issue. We will try to fix this. Thanks for reporting it.

XceedBoucherS avatar Jun 29 '22 12:06 XceedBoucherS

Hi, The issue has been found. The fix will be part of the next release : v2.4. Thank you.

XceedBoucherS avatar Jun 29 '22 14:06 XceedBoucherS

That's great. I thought i was losing my mind, although I may still be losing my mind. For now, I work around not having a table by putting everything one image and then adding that picture in the header. Thanks for your response. I will look out for v2.4.

ramayanabali avatar Jul 01 '22 14:07 ramayanabali