cancel
Showing results for 
Search instead for 
Did you mean: 

Binary data from R3 to be shown as document (.pdf, .doc)

Former Member
0 Kudos

Hi Experts,

I have requirement to show the binary data coming from an RFC call as a document (.pdf, .doc). The document will be accessed via a URL that will be provided in table.

I searched a lot in SDN but I am unable to found any relevant information on how to convert the binary data coming from an RFC to be shown as a document or IResource type.

Thanks in advance, helpful answer will be definately awarded.

Regards

Deepak

Accepted Solutions (0)

Answers (3)

Answers (3)

former_member214651
Active Contributor
0 Kudos

Hi Deepak,

try using an IFrame UI element in WDJ. This helps in displaying any 3rd party content (PDF, DOC, XLS) content. Just bind the source property to a string and set the URL to the strting attribute

Regards,

Poojith MV

Former Member
0 Kudos

Deepak,

Use a fileDownload UI element and bellow code to achive desired output.

and create a context node named "fileUrl" and type "IWDResource"

Then use below code to populate fileUrl context attribute.

//Here output node and attribute is where you have your binary data is.

byte[] byteFile = wdContext.current<;output_node>.get<BinaryExport>();

//condition to check if file is pdf or doc

if(<file id PDF>)

{

//Set content type for your bynary data.

IWDCachedWebResource fileResource = WDWebResource.getWebResource(byteFile,WDWebResourceType.PDF);

}

else

{

//Set content type for your bynary data.

IWDCachedWebResource fileResource = WDWebResource.getWebResource(byteFile,WDWebResourceType.DOC);

}

try

{

//fileUrl is a context attribute which you have to bind with property resource of FileDownload UI element.

wdContext.currentContextElement.setfileUrl(fileResource.getURL());

}

catch(Exception e)

{

// to catch the exception.

wdComponentAPI.getMessageManager().reportException(e.getMessage(),true);

}

Former Member
0 Kudos

Plz try this code

byte[] pdfContent =

wdContext.current<output_node>.get<BinaryExport>();

IWDCachedWebResource pdfResource = WDWebResource.getWebResource(pdfContent,WDWebResourceType.PDF);

try

{

/* PdfUrl is of type String */ wdContext.currentContextElement.setPdfUrl(pdfResource.getURL());

}

catch(Exception e)

{

wdComponentAPI.getMessageManager().reportException(e.getMessage(),true);

}

Sunitha Hari

Former Member
0 Kudos

Hi Sunitha/Ninad,

Thanks for the information and it was very helpful.

The main problem is that the binary content coming from the rfc calling is in different lines and each line is type of byte[].

The api to convert the binary data to relevant document type {WDWebResource.getWebResource(byteFile,WDWebResourceType.PDF)} only takes byte[] and not byte [] []. Please let me know how to solve this.

Also let me know the how to get the WDWebResourceType for files with extension wwi, tif, plt, msg, mpp,dwg, bmp, ai, jt etc. Will the WDWebResourceType.Unkown will work for these extension.

Regards

Deepak

Former Member
0 Kudos

Hi Deepak,

Did you try to add the interactive form UI object in you web dynpro view? point the source property to the import bynary parameter of your RFC and in the mode property select UsedPDF. This should work for PDFs

Regards,

Eduardo Campos

Former Member
0 Kudos

Hi Deepak,

I am not getting what do you mean by "binary content coming from the rfc calling is in different lines and each line is type of byte[]"

but if it is so you can try to concatenate those lines.

Ninad