Search code examples
c#reportrdlc

How to Pass the Image(Barcode image) through c# to rdlc file


I am trying to give the barcode Image to rdlc file but i am getting that red cross symbol instead of barcode

Code I have tried:

rdlc file content:

<Image Name="imgBarcode">
        <Source>Embedded</Source>
        <Value>=(Parameters!imgBarcode.Value)</Value>
        <Sizing>FitProportional</Sizing>
        <Top>0in</Top>
        <Left>0.1in</Left>
        <Height>0.2in</Height>
        <Width>2.5in</Width>
        <ZIndex>1</ZIndex>
        <Style>
          <Border>
            <Style>None</Style>
          </Border>
          <PaddingTop>1pt</PaddingTop>
          <PaddingBottom>1pt</PaddingBottom>
        </Style>
      </Image>

And also:

<ReportParameters>
    <ReportParameter Name="imgBarcode">
      <DataType>String</DataType>
      <Prompt>ReportParameter1</Prompt>
    </ReportParameter>
  </ReportParameters>

C# code:

string BRFilepath = @"C:\dev_work\PatagoniaHealthSOURCE\tempFiles\Webcontent\0df5c4fb-56ca-47e0-ace2-0c6b435a01de\temp\Img2DBC_48e9b39e-c8e7-4b80-a9d4-7e9f01d85b39.jpg";
                
                                                                               //ReportViewer1.LocalReport.SetParameters(param);
                rptDoc.ReportPath = HttpContext.Current.Server.MapPath("../Reports/" + sReportFileName);

                ReportDataSource rptDsBHReportDetails = new ReportDataSource("dsPatientLabOrderLabels_dtPatientLabOrderLabels", dtLabOrderLables);
                rptDoc.DataSources.Add(rptDsBHReportDetails);
                ReportParameter param = new ReportParameter();
                param = new ReportParameter("imgBarcode", BRFilepath);
                
                rptDoc.SetParameters(param);
                rptDoc.Refresh();

I am converting it in pdf and showing later on after showing result i am getting like the above X red symbol.


Solution

  • I resolved by adding External instead of Embedded in source tag

    From this :

    <Image Name="imgBarcode">
            <Source>Embedded</Source>
            <Value>=(Parameters!imgBarcode.Value)</Value>
            <Sizing>FitProportional</Sizing>
            <Top>0in</Top>
            <Left>0.1in</Left>
            <Height>0.2in</Height>
            <Width>2.5in</Width>
            <ZIndex>1</ZIndex>
            <Style>
              <Border>
                <Style>None</Style>
              </Border>
              <PaddingTop>1pt</PaddingTop>
              <PaddingBottom>1pt</PaddingBottom>
            </Style>
          </Image>
    

    To this:

    <Image Name="imgBarcode">
                <Source>External</Source>
                <Value>=Parameters!imgBarcode.Value</Value>
                <Sizing>FitProportional</Sizing>
                <Top>0.09in</Top>
                <Left>0.062in</Left>
                <Height>0.24999in</Height>
                <Width>2.1in</Width>
                <ZIndex>1</ZIndex>
                <Style>
                  <Border>
                    <Style>None</Style>
                  </Border>
                </Style>
              </Image>