I'm trying to export a report to PDF directly, without any report viewer control, just one button which exports to PDF and I've been using the ReportWriter class. I know that we can't directly export charts to a report due to UWP limitations as answered here:
So I decided to take a workaround and trying to generate that chart to an image and then loading it into the report dynamically from a local path. Now here comes the different points of view about the problem which I'm stuck at.
On my sample which I've attached below, there's an imagePath property with a local path that needs to point to any image locally.
And then if we take a look at the report we can see 3 images with some borders of different colors:
- The first one is an external type of image (source set to "External") set with a local value, the value is assigned via a parameter and programmatically from the code. I've tried a lot of ways of writing the path, none of them worked, till I decided to try an external image with a image online from a website. (Black border)
- This second image, is the external image loaded up from a website with its source set to "External", it is showing correctly on the report designer, no issues there so far. (Red border)
- And the last image which we have, has the source selected to "Embedded", now this image is also showing on the designer. (Blue border)
Once we launch the sample and click the export button, the filepicker opens up correctly and we can select the path on where to save the PDF. When we open the PDF we can see the following images:
- The external image is NOT seen, just the black border.
- The external image is NOT seen, even though we can see it in the designer correctly.
- The embedded image is seen correctly.
Now the question is, how can we solve this? I know that UWP has some limitations, but we really need to be able to export some kind of chart and now it's just a simple image which we're trying to load dynamically.
Also lastly, we would like to avoid the use of a WebAPI just for that.
Thanks and have a nice day,