LimeReport Forum

General Category | Основное => Discussion | Обсуждение => Topic started by: salvo on June 04, 2020, 11:04:24 AM

Title: Problem with setReportVariable and img source
Post by: salvo on June 04, 2020, 11:04:24 AM
Hi,

I'm having problem when trying to assign an image using setReportVariable.
This is the code:
Code: [Select]
report->dataManager()->setReportVariable("Logo", "<img source = "+ FolderPath +"/Resource/STAR2K_FONDI_CHIARI.jpg width=826 height= 237>");
Now when I run it in local the FolderPath is:  C:\Progetti\QT_Project\App and everything works fine.
When I try to install my application on another pc the FolderPath became: C:/Program Files (x86)/MyApp And suddendly it doesnt't return the image. I'm sure the image is available in the correct path in both version. It looks like there is something with blank spaces but I don't know how can I handle that.

I also tried to replace spaces with '%20' as following:
"<img source = C:/Program%20Files%20(x86)/MyApp/Resource/STAR2K_FONDI_CHIARI.jpg width=826 height= 237>"
Is this uncorrect? I'm using a text item and I checked allowHTML and allowHTMLInFields.


What am I doing wrong?

Thanks for your help!
Title: Re: Problem with setReportVariable and img source
Post by: Arin Alex on June 14, 2020, 03:49:55 PM
Hi!
You can put an image into a resource file.
Then use the resource path to init an image.
Title: Re: Problem with setReportVariable and img source
Post by: salvo on June 16, 2020, 01:40:41 PM
Hi Alex!

unfortunately I cannot do this trick. Some images are created at runtime taking a screenshot of the window and I save them into a folder pointed by FolderPath that contains the full path to the folder. So I have to use the full path to get this images.

Is there a way to do that without having the error above?
Title: Re: Problem with setReportVariable and img source
Post by: Arin Alex on June 20, 2020, 10:16:36 AM
Why are you using TextItem to show an image?
Try to add quotes
report->dataManager()->setReportVariable("Logo", "<img source =\" "+ FolderPath +"/Resource/STAR2K_FONDI_CHIARI.jpg \" width=826 height= 237>");
Title: Re: Problem with setReportVariable and img source
Post by: salvo on June 24, 2020, 10:50:45 AM
That's a good question  ;D
Unfortunately I didn't write this code, I don't know why TextItem has been choosen for this purpose...
Anyway, adding quotes still doesn't work, maybe can you point me to the correct approach I should use in this case?

Thanks again for the support! :D
Title: Re: Problem with setReportVariable and img source
Post by: Arin Alex on June 25, 2020, 05:21:51 PM
LimeReport has ImageItem for this purpose.
If you use ImageItem you can show a variable that contains an image
or resourcePath property to set up the path to an image.