none
RDL/RDLC Programatically insert image at runtime. Image shows in design but not in report viewer RRS feed

  • Question

  • Hi,

    My requirements are to create a dynamic header image that is generated at the moment of running the report.

    I have managed to do this with a comination of XMLDocument, creating images converting the images to base64, inserting them in the XML.

    Everything works to a point. In the rdlc file that I generate with the embedded image, if I view this in VS2008, I can see the new image. The XML renders fine.

    In the report viewer however I get a blank image. The header adjusts to the correct size, and everything appears to work. Except for the image.

    Enable external images is true just for testing. Makes no difference. I have also tried using an external image but to no avail. Same behaviour.

    Any ideas?

    PageHeader Tag from RDLC with Image

      <PageHeader>
        <PrintOnFirstPage>true</PrintOnFirstPage>
        <ReportItems>
          <Textbox Name="textbox12">
            <rd:DefaultName>textbox12</rd:DefaultName>
            <Style>
              <FontSize>7pt</FontSize>
              <TextAlign>Left</TextAlign>
              <PaddingLeft>2pt</PaddingLeft>
              <PaddingRight>2pt</PaddingRight>
              <PaddingTop>2pt</PaddingTop>
              <PaddingBottom>2pt</PaddingBottom>
            </Style>
            <ZIndex>1</ZIndex>
            <CanGrow>true</CanGrow>
            <Left>16cm</Left>
            <Height>0.5cm</Height>
            <Value>= "Fecha: " &amp; Day(Globals!ExecutionTime)&amp; "/" &amp; Month(Globals!ExecutionTime)&amp; "/" &amp; Year(Globals!ExecutionTime)</Value>
          </Textbox>
          <Textbox Name="textbox15">
            <Top>4.75cm</Top>
            <Style>
              <Color>RoyalBlue</Color>
              <BackgroundColor>Ivory</BackgroundColor>
              <BorderColor>
                <Default>Blue</Default>
              </BorderColor>
              <BorderStyle>
                <Bottom>Solid</Bottom>
              </BorderStyle>
              <BorderWidth>
                <Default>2pt</Default>
              </BorderWidth>
              <FontWeight>700</FontWeight>
              <TextAlign>Left</TextAlign>
              <PaddingLeft>2pt</PaddingLeft>
              <PaddingRight>2pt</PaddingRight>
              <PaddingTop>2pt</PaddingTop>
              <PaddingBottom>2pt</PaddingBottom>
            </Style>
            <CanGrow>true</CanGrow>
            <Value>FICHA DATOS DE EMPRESA</Value>
          </Textbox>
          <Image Name="imganagrama" xmlns="">
    <Sizing>FitProportional</Sizing><Top>0cm</Top>
    <Width>21cm</Width>
    <MIMEType>image/jpeg</MIMEType>
    <Source>Embedded</Source>
    <Style />
    <ZIndex>1</ZIndex>
    <Left>0cm</Left>
    <Height>4.0cm</Height>
    <Value>anagrama</Value>
    </Image>
    </ReportItems>
        <Height>5.38492cm</Height>
        <PrintOnLastPage>true</PrintOnLastPage>
      </PageHeader>


    EMBEDDED IMAGE TAG
      <EmbeddedImages xmlns="">
    <EmbeddedImage Name="anagrama">
    <MIMEType>image/jpeg</MIMEType>
    <ImageData>base64data</ImageData>
    </EmbeddedImage>
    </EmbeddedImages>



    Tuesday, November 17, 2009 4:24 PM

All replies

  • FIXED!!!!!

    When creating the xml fragment there were no attributes in the image and embedded tags.

    I added this code to remove the xmlns="" attribute and now everything works!!!!

    Dim

     

    strxml As String = My.Computer.FileSystem.ReadAllText(xmlruta)

     

     

    Dim strtext As String = "xmlns=" & Chr(34) & Chr(34)

     

     

    strxml = Replace(strxml, strtext, "")

     

     

    My.Computer.FileSystem.WriteAllText(xmlruta, strxml, False)

     

     

    Return xmlruta

    Wednesday, November 18, 2009 9:21 AM