cancel
Showing results for 
Search instead for 
Did you mean: 

Saving and referencing images

Former Member
0 Kudos

Okay, I can get the charting component to set a directory where it will place the image.

1) What path should I tell it to write the image to?

2) How do I reference that image with a URL?

I hope that makes it easier for y'all to understand and, hopefully, answer. Thanks! --Shibli

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Shibli,

You should follow the "how to use a third party chart control" document, only if you can't get the image directly from the chart control, then do this:

in the function RenderPieChart (or RenderXYChart) first save the image, where ever you want (you should do it in a smart way, to cache as much as you can to avoid a lot of disk usage), and then just load it (from where ever you saved it) and use that as the bitmap to call to "RenderBitmap" (which will pour it to the response).

makes sense?

Regards,

Ofer

Former Member
0 Kudos

Ofer, yes, what you are saying makes sense. However, the problem is that the files are saved in the following directory:

C:\Program Files\SAP\Portal Runtime for Microsoft .NET\Server00\PortalApps

This directory is not an absolute path and not a virtual directory that is accessible to a remote user. So <IMG SRC="the path above"> doesn't work.

I can get it to save in the directory my iView resides in (C:\Program Files\SAP\Portal Runtime for Microsoft .NET\Server00\PortalApps\myiView) but I don't know how to access that via a URL either.

Thanks so much for your valuable help! --Shibli

Former Member
0 Kudos

Hi Shibli,

I think you misunderstood.

You should read the <a href="https://www.sdn.sap.comhttp://www.sdn.sap.comhttp://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/dotnet/pdk%20for%20.net/developer's%20Guide%20PDK%202.0%20for%20.NET/How%20to/ThirdPartyChartControl.htm">how-to</a> more carefully.

The how-to relies on the fact that a server can return to a client not just html, but also stream files. In order to do that, it changes the mime type and sends the file as a stream.

So what we do is write a portal component that is called actually TWICE. once for the html, and once AGAIN for the image!

first we set the source of an image control to itself (plus a query param).

like this:

Image1.Source = this.iViewPath + "?Chart=Pie";

This will eventually render like this: <IMG SRC="sameiView?Chart=Pie">

when the browser will receive this, it will call the same component AGAIN, only this time in the page load we will intercept the query and not render the regular html but return the actual image as a stream! (see how-to for the code)

Now you still have the question of how to write this code that will stream the image to the client. This is done by either "saving" the bitmap from the chart control directly to the output stream (like in the how-to), or if the chart control can't provide a real bitmap, and can only save a image somewhere (which is very strange by the way), then we will ask the chart to save the image somewhere first and then we will read it from there again to a bitmap, and then "save" it again, this time to the output stream. In both cases we need to change the mime type to "image" (as in the how-to).

Hope that clears up the confusion,

Ofer

Former Member
0 Kudos

Thank you, Ofer. I am aware of the documented method as described in the How-To. However, using that method did not work because of a bug in the FileIOPermission of the .NET runtime which yields a "Has Illegal Characters" error message because of a problem with the "?" (question mark). This is why I am saving the file to a location then reading from that location. So that takes me back to my initial problem. Where do I save the images and reference them from a location that can be called from a URL?

If anyone knows of a tried and tested method of image mapping a chart image in the .NET PDK I'd appreciate it as this has become a major stumbling block for the project. Everyone I've talked to has just told me to not bother since it's not supported and too much effort, however, this is a requirement so I can't forsake it.

Ofer, thanks again for your help! --Shibli

Former Member
0 Kudos

Hi Shibli,

a few things -

1. could you elaborate on this bug (with the "?")? I haven't heard of this... where exactly does this happen?

2. If you save the image file, you can still read it afterwards and return it in a portal component (could be a dedicated portal component). It's not the best solution, but it works.

3. There is NO way (other then what I've described in "2", or in the how-to) that you can save a file and have it exposed as URL in the portal, using the .NET PDK. but consider asking in the "regular" portal forum... they might know a "trick" that you could use.

(and let us know if you find it!)

Regards,

Ofer

Former Member
0 Kudos

Ofer,

I credited you with solving my problem since your help most definitely assisted me in doing that. Thank you so much for your valuable help! Regarding the bug in FileIOPermission that causes the "Has Illegal Characters" error I noticed it only happened when I used a class wrapper, but didn't happen otherwise. The bug is lightly documented on the net, but I'm not sure how I triggered it by using the class wrapper.

I've got charting working and clickable in the iView and hope to write something up soon so that others can benefit from my experience. Thanks again! --Shibli

Answers (0)