cancel
Showing results for 
Search instead for 
Did you mean: 

Binary Data to PDF and Word Doc

Former Member
0 Kudos

All,

We have requirement to open a PDF or DOC in a new window from a BAPI output structure. The field returned from the BAPI is a binary field. Following is the code that is implemented for this scenario.

for(int i=0;i<wdcontext.nodeOutput().nodePtx_Drao().size();i++)

{

IWDCachedWebResource resource = WDwebResource.getWebResource(wdcontext.nodeOutput().nodePtx_Drao().getPtx_DraoElementAt(i).getOrblk(), WdWebResourcetype.PDF);

}

IWDWindow win = wdComponentAPI.getWindowManager().createNonModalExternalWindow(resource.getUrl(WDFileDownloadBehaviour.OPEN_PLACE.ordinal()), "test");

win.open();

The problem we are facing here is when we try to open the PDF it throws an error saying "File does not begin with '%PDF-'". If we try to open a word document by changing the resource type some junk values are coming.

Has anyone come across this type of development issues?

Appreciate all your replies and new inputs in this regard.

Thanks & Regards,

Nagarajan.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

I also tried with the same using the below code. Even I am getting the same error.

byte[] test=new byte[9];test[0]=2;

IWDCachedWebResource resource = WDWebResource.getWebResource(test,WDWebResourceType.PDF);

When i tried the same code with other file type its working file.

IWDCachedWebResource resource = WDWebResource.getWebResource(test,WDWebResourceType.DOC);

From where are you getting this actual byte array? from R/3?. In internet if you search about this error we are getting the results like "The PDF file has a .mme extension rather than a .pdf extension".

Note: This is not the problem with Window or LinkToURL ui elments.

Posting this to give you an idea.

Regards,

Charan

Former Member
0 Kudos

Hi Charan,

Thanks. Yes Word document I was able to open but not sure that is the correct data looks like some junk values to be populated in the document.

The binary values are coming from R3 through a BAPI call. Ok let me try to put this in a Link to URL and see what happens.

Regards,

Nagarajan.

Former Member
0 Kudos

Hi,

Even for LinkToUrl also you get the same error for PDF. There is a problem in the type of data you are getting from backend to open it as a pdf document. I guess.

Regards,

Charan

Answers (4)

Answers (4)

Former Member
0 Kudos

if you can shoot me a mail , i can send you the sample to help yourself

thanks

meenu

Former Member
0 Kudos

Amit - The code you have provided is for opening a popup window which is not I m looking for.

Charan - There is no special chars in the filename.

Thanks,

Nagarajan.

Former Member
0 Kudos

Hi

Just try this below scenario to analyze the problem.

Create one LinkToURL ui element. And create one Context attribute "URL" and bind this attribute to the LinkToURL ui element's reference property.

Now fill the context attribute ''URL'" as below.

wdContext.currentContextElement.setURL(resource.getUrl());

Check in runtime whether it is opening the url in external browser properly or not.

Regards,

Charan

Former Member
0 Kudos

Hi,

Can you check that any special characters are there in you file name (including space char also).

Regards,

Charan

Former Member
0 Kudos

Hi,

you can try following :

//get the repository content at runtime of the Web-Dynpro-

// Window u201CAddressbookWindowu201D

IWDWindowInfo windowInfo = (IWDWindowInfo)wdComponentAPI

.getComponentInfo()

.findInWindows("AddressbookWindow");

//create the u201CAddressbookWindowu201D

IWDWindow window = wdComponentAPI.getWindowManager()

.createWindow( windowInfo, true);

//set the WindowPosition on the screen

window.setWindowPosition(300, 150);

//and show the window

window.open();

// Save WindowInstance in Context

wdContext.currentPopupElement().setWindowInstance(window);

Regards,

Amit