cancel
Showing results for 
Search instead for 
Did you mean: 

View a PDF file passed as a binary array (SOLIX table) from an RFC call

Former Member
0 Kudos

Hi,

I need to make a Web DynPro that shows a PDF file that is passed as the result of an RFC call. The PDF file is stored in a byte array. I've seen that an InteractiveForm component could be used for this.

I've two questions:

1) Where could I find a reference for the InteractiveForm component with some examples on how to embed and use the component into a view?

2) Is it possible to show the PDF file in a separate tab of the browser without displaying it inside the main Web DynPro window/view?

Thank you, Any help is really appreciated,

Pietro

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Peitro,

Following is the URL for the forum for SAP NetWeaver Adobe Interactive Forms:

Also, it is possible to open the Adobe Form in a new Window instead of the main WebDynpro View. What you need to do is just create a separate view with 'Interactive Form' UI element and add it in a new Web Dynpro window. Then you can open this window from your main window whenever you want.

For Adobe Interactive forms, you need to add an element 'Interactive Form' in your WD view and assign the pdfSource and datasource it.

I am not 100% sure if you'll be able to display the pdf you receive from the RFC call in the interactive form as I am not sure how will you assign the datasource to it. Needs to be explored.

Regards,

Ajay

Answers (4)

Answers (4)

Former Member
0 Kudos

I'm posting here the source code I'm using... maybe someone else will find it useful

	 
	  // Copy the content from the SOLIX table to an array
	  wdContext.nodeTbin().moveFirst();
	  int pdfLines = wdContext.nodeTbin().size();
	  
	  byte[] byteSub = new byte[255];
	  byte[] byteInfo = new byte[pdfLines*255];
	  for (int i = 0; i < pdfLines; i++) {
		  wdContext.nodeTbin().setLeadSelection(i);	  
		  byteSub = wdContext.currentTbinElement().getLine();
		  
		  System.arraycopy(byteSub, 0, byteInfo, i * 255, 255);
		  
//		  Equivalent code if System.arraycopy does not work
//		  for (int j = 0; j < 255; j++) {
//			  byteInfo[i*255 + j] = byteSub[j];
//		  }
	  }

	  // Create a PDF file resource on-the-fly with the content of the vector
	  IWDResource resource = WDResourceFactory.createCachedResource(byteInfo, 
			  "MyPDFFileName.pdf", WDWebResourceType.PDF);

	  // Show the PDF file in a new window
	  IWDWindow window = wdComponentAPI.getWindowManager().createNonModalExternalWindow(
			  resource.getUrl(WDFileDownloadBehaviour.AUTO.ordinal()));
	  window.show();

See you,

Pietro

Edited by: pietro.m on Jul 9, 2010 12:11 PM

Former Member
0 Kudos

Thanks to everyone who dropped an answer.

I tried Lavanya's code but since the .setRolePurposeURL method does not exists (don't know if it was meant as a placeholder for something else, like for currentXXXXXXElement()) I've used srinivas' code as a sketch for displaying the PDF.

Here is what I did:

byte[] byteInfo = null;

byteInfo = wdContext.currentTbinElement().getLine();

IWDResource resource = WDResourceFactory.createCachedResource(byteInfo, "Give your file name"+".pdf", WDWebResourceType.PDF);

IWDWindow window = wdComponentAPI.getWindowManager().createNonModalExternalWindow(

resource.getUrl(WDFileDownloadBehaviour.AUTO.ordinal()));

window.show();

With this code I manage to open a pop up window in Firefox. Now the result I get is a MessageBox titled "Adobe Reader" saying that "The PDF file is damaged and it could not be repaired". Perhaps the backend guys are sending me invalid data. I'll check this out.

In the meantime, thanks again.

Pietro

Former Member
0 Kudos

Hi,

Get the binary data coming from the RFc and generate a url to open PDF file in a new Browser.

Implement the below code:

byte[] byteInfo = null;

byteInfo = wdContext.currentXXXXXXElement().getYourBinaryInfoComignFromRFC();

IWDResource resource = WDResourceFactory.createCachedResource(byteInfo ,"Give your file name"+".pdf", WDWebResourceType.PDF);

wdContext.currentContextElement().setRolePurposeURL(resource.getUrl(WDFileDownloadBehaviour.AUTO.ordinal()));

Regards,

Lavanya.G

Former Member
0 Kudos

You don't need any new views. Follow this code to open the PDF in a new browser.

byte[] pdfData = wdContext.currentOutputElement().getBin_File();

if(!(pdfData.length == 0)){

String url = "";

WDWebResourceType webResType = WDWebResourceType.PDF;

IWDWebResource webResource = WDWebResource.getWebResource(pdfData, webResType);

try {

url = webResource.getURL();

} catch (WDURLException e) {

e.printStackTrace();

}

IWDWindow window = wdComponentAPI.getWindowManager().createExternalWindow(url , "Acknowledgement-", false);

window.open();

}

Hope this helps!