FastReport icon indicating copy to clipboard operation
FastReport copied to clipboard

How to put small and large images on the same report

Open lipe123 opened this issue 8 months ago • 4 comments

We are developing a report writing application and sometimes the pictures of deficiencies are small and we want to print up to 6 images on a page in a 2x3 grid. This is easily done by making a databand with 2 columns. However; other images needs to be larger and we need them to be the full width of a page (0 columns) AND We want the images to print in the intended order of how the inspection was done. So it could be

SS L L SS SS

Or any combination of Large and Small images.

I tried sub databands, subreports etc. When i create two sub data bands inside a larger band the 2 columns band no longer tiles across and everything just prints vertically in one column. I can make two separate bands, one that only prints large images and one for small but this breaks the order in which we want to display the images.

I even tried with script to alter the databand columns as we generate the report but I get index out of bounds errors. I'm guessing because altering the databand will alter all instances of it, even the prior ones that already has 2 columns with 2 images. So trying to alter it to one column later down the line breaks everything.

I just can't wrap my brain around the problem in a creative easy to implement way, does anyone have suggestions?

lipe123 avatar Apr 01 '25 16:04 lipe123

@lipe123 how are you setting images on your report? I can't get the image to appear in the report.

I set the PictureObject in report with designer and I have the fallowing code:

webReport = new WebReport();
Config.WebMode = true;

webReport.Report.Load(reportPath);
webReport.Report.Dictionary.Connections[0].ConnectionString = jsonConnectionString;
webReport.Report.Prepare();

//setting image in component
byte[] imageByteArray = System.IO.File.ReadAllBytes("C:\\Users\\Fernando\\Pictures\\Robo.png");
PictureObject)webReport.Report.FindObject("poEmitLogo")).SetImageData(imageByteArray);

MemoryStream stream = new();
webReport.Report.Export(new PDFSimpleExport(), stream);
stream.Flush();
stream.Position = 0;

return stream;

All information is generated correctly, but the image does not appear.

fernandocristan avatar Apr 02 '25 18:04 fernandocristan

Bit of a hijack mate but sure, we are not building the report with code. Just using the designer. We just set the file path in the ImageLocation property.

lipe123 avatar Apr 02 '25 19:04 lipe123

Bit of a hijack mate but sure, we are not building the report with code. Just using the designer. We just set the file path in the ImageLocation property.

ok, I found the solution.

  • setting image in component was after the prepare statement

fernandocristan avatar Apr 03 '25 11:04 fernandocristan