cancel
Showing results for 
Search instead for 
Did you mean: 

How to get byte[] from IWDBusinessGraphics object?

Former Member
0 Kudos

I need to get byte[] value out of IWDBusinessGraphics object. Can anyone help me?

My code:

IWDBusinessGraphics bg = (IWDBusinessGraphics) view.getElement("BusinessGraphics1");

byte[] bytImage = ???;

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi John,

have you solved the problem ?

We have the same problem. In NW2004 we used the undocumented method

WebResourceInternal.getCachedWebResource - which is gone with nw2004s. But it still works with SP17.

public static BufferedImage getImage(IWDViewElement iBusinessGraphic ){

BufferedImage chart = null;

if( iBusinessGraphic != null && iBusinessGraphic instanceof BusinessGraphics ) {

BusinessGraphics bg = (BusinessGraphics)iBusinessGraphic;

// bg.createImage();

// bg.forceUpdate();

String url = bg.getImageSource();

String key = url.substring( url.indexOf( "~wd_key"), url.indexOf("/unknown.gif"));

try {

ICachedWebResource cacheRs = WebResourceInternal.getCachedWebResource( key );

ByteArrayOutputStream bo = new ByteArrayOutputStream();

cacheRs.writeSourceToOutputStream( bo);

chart = ImageIO.read( new ByteArrayInputStream( bo.toByteArray()) );

}catch( Exception e ) {

e.printStackTrace();

}

}

return chart;

}

Former Member
0 Kudos

Actually my code is like this:

IWDBusinessGraphics bg = (IWDBusinessGraphics) view.getElement("BusinessGraphics1");

AbstractIgsElement igs = (AbstractIgsElement) bg;

igs.createImage();

igs.forceUpdate();

String fullUrl = "forceEncoding:" + igs.getImageSource();

String encodedUrl = ((IWebContextAdapter) WDWebContextAdapter.getWebContextAdapter()).encodeRedirectURL(fullUrl);

wdContext.currentContextElement().setPdfSummSheetBgURL(encodedUrl);

com.lowagie.text.Image img = new com.lowagie.text.Image(new URL(encodedUrl));

But after I patched with SP17, the igs.getImageSource() behave differently.

Before patch, igs.getImageSource returns:

https://172.31.40.14:8443/webdynpro/dispatcher/local/CRRSRatingWDP/CRRSRatingApp/~wd_key1804_1151397...?

sap.session.download=1&sap-wd-cltwndid=c2&sap-wd-appwndid=Idc251b&sap-

wd-norefresh=true.

But after patched, igs.getImageSource returns

../../local/CRRSRatingWDP/CRRSRatingApp/~wd_key0_1151456666122/unknown.gif?sap.session.download=1&sap-wd-

cltwndid=d677d4e0064111db940d0003ba954bfa&sap-wd-

appwndid=Idd677d4e0064111db940d0003ba954bfa1&sap-wd-norefresh=true.

The different is, there is

no 'https://172.31.40.14:8443/webdynpro/dispatcher' at the beginning of

the URL.

Because the URL has to be pass to com.lowagie.text.Image, this change has caused an error to my application.