FlexReport Image And Subreport Problem

Posted by: sanjeeb.srjm on 27 December 2021, 10:15 pm EST

    • Post Options:
    • Link

    Posted 27 December 2021, 10:15 pm EST - Updated 3 October 2022, 10:45 pm EST

    Dear Sir/Mam,

    I have tried to add image to flexreport in bound mode as follows:-

    Field photoField = new Field();

    photoField.Picture = “Photo”; //images provided through flex1.DataSource.Recordset

    photoField.Height = 1500;

    photoField.Width = 1500;

    photoField.Left = 1500;

    photoField.Top = topPos;

    photoField.PictureScale = PictureScaleEnum.Stretch;

    photoField.Border.Style = DashStyle.Solid;

    photoField.Border.Width = 8;

    s.Fields.Add(photoField);

    1. photo is not being displayed in attached project sample-

    2. bills are repeating due to multiple billing items.

    please help us to solve this.

    Regards-

    Sanjeeb

  • Posted 27 December 2021, 10:23 pm EST

    please find the attachment here …

    NoPhotoNRepeatingBill.zip

  • Posted 28 December 2021, 3:48 am EST

    Sorry, forgot attachment.

    Updated.zip

  • Posted 28 December 2021, 3:49 am EST

    Hi Sanjeeb,

    attached is a reworked sample.

    The trick is that the property “Field.Picture” does not accept an “Image” object, but a base64 string. So I added a property “PhotoBase64” to your “Student” class that converts the Image to Base64, and set the “Picture” property to the name of this property.

    
      public string PhotoBase64
      {
        get
        {
          if (this.Photo == null)
          {
            return string.Empty;
          }
          MemoryStream memStream = new MemoryStream();
            
          this.Photo.Save(memStream, ImageFormat.Png);
    
          memStream.Seek(0, SeekOrigin.Begin);
    
          byte[] bytes = memStream.ToArray();
    
          memStream.Close();
          memStream.Dispose();
    
          return Convert.ToBase64String(bytes);
        }
      }
    
    

    Of course, this is probably bad performance - the base64 conversion should be done before.

    Best regards

    Wolfgang

  • Posted 28 December 2021, 4:02 am EST

    Hello Sanjeeb,

    If you want to bind the ImageField to datasource via code then you need to bind it with byte type of data. Please find the modified sample implementing the same.

    Regards,

    Prabhat Sharma.

    ReportImage_Mod.zip

  • Posted 28 December 2021, 6:00 am EST

    Dear Prabhat Sir,

    Thankx a lot for solving image bound print problem. thankx a lot sir…

    Lastly, solve the repeating bill-items of

    Aditya Chaudhary for the Same Month

    Printing two seperate bill shown in above picture.

    Please sir.

    this is last in this context.

    please edit the attached project itself so that we can understand…

    Regards-

    Sanjeeb

  • Posted 29 December 2021, 4:09 am EST

    Hello Sanjeeb,

    Your other issue has been replied to on your support case. Please continue that thread there only to avoid confusion.

    Regards,

    Prabhat Sharma.

  • Posted 5 January 2022, 2:56 am EST

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels