cancel
Showing results for 
Search instead for 
Did you mean: 

Converting Xstring output of RFC to the PDF format

Former Member
0 Kudos

Hi,

1. I have created one web dynpro application, in which i am accessing rfc function.

2. Rfc function's output is XString type (Smart form).

3. In web dynpro i am using the following code to display the same.

byte[] text = null;

text = wdContext.currentOutputElement().getBin_File();

wdContext.currentContextElement().setCtx_va_att(convertXStringToUrl(text));

public static String convertXStringToUrl(byte[] docContent)

{

String url = "";

WDWebResourceType resourceType = WDWebResourceType.PDF;

IWDWebResource webResource = WDWebResource.getWebResource(docContent,resourceType);

try {

url = webResource.getURL();

} catch (WDURLException e) {

// TODO Auto-generated catch block

url = e.getMessage();

return url;

}

return url;

}

4.I am setting this url to Source attribute of iFrame.

5. But in the output, it displays only the empty iFrame component.

6. I am using ep6 & netweaver ver 7.0.09

7. Also tried using WebCacheResource. It opens the Acrobat reader but displays error File does not start with '%PDF'.

7. What could be the error?

Thanks in advance,

Nilesh

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

Thanks a lot.

Former Member
0 Kudos

Hi,

Can you share how you resolved the issue?

Thanks.

Former Member
0 Kudos

Hi Nilesh,

Please check the Acrobat Reader is properly installed and its version and try the following code,

byte[] pdfContent = wdContext.currentXtstingElement().getE_Xstring();

String pdfFileName = "Test";

WDDeployableObjectPart objpart=wdThis.wdGetAPI().getComponent().getDeployableObjectPart();

IWDCachedWebResource pdfResource= WDWebResource.getPublicCachedWebResource(pdfContent,WDWebResourceType.PDF,WDScopeType.APPLICATION_SCOPE,objpart,"Page1");

try {

wdComponentAPI.getWindowManager().createNonModalExternalWindow(pdfResource.getURL(),pdfFileName).show();

}

catch (WDURLException e)

{ wdComponentAPI.getMessageManager().reportException(e.getMessage(),false); }

Regards,

Suresh T

Former Member
0 Kudos

Hi Nilesh,

You can use this code:



public static String convertXStringToUrl()
{
String url = "";

IWDCachedWebResource l_file = WDWebResource.getWebResource(wdContext.currentOutputElement().getBin_File(),WDWebResourceType.PDF);

try {
url =  l_file.getAbsoluteURL()
} catch (WDURLException e) {
// TODO Auto-generated catch block
url = e.getMessage();
return url;
}

return url;
}

Please Note: The important change made is use of IWDCachedWebResource and the URL has to be absoluteURL.

This should definetely solve your problem as i have gone through this once and followed this approach.

-Kunal Kotak

Edited by: kunal kotak on Jan 2, 2009 10:30 AM