on 03-23-2010 6:04 AM
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
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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);
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
User | Count |
---|---|
87 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.