cancel
Showing results for 
Search instead for 
Did you mean: 

Error on opening PDF using link to action

Former Member
0 Kudos

Hi Experts,

For one of my requirements, I have generated and sent a PDF file in XSTRING format through one RFC function module. That file is recieved from RFC and we are able to open it as well.

Now, we are trying to resend that file back via RFC function module and I am trying to open it in WebDynpro. For this I have used one link to action and onAction I have written the following code after executing the RFC:

	   byte[] b = wdContext.currentOutput_Send_PdfElement().getP_File();
	         
	   if(null != b) {       
		IWDResource file = WDResourceFactory.createCachedResource(b, "PDF_URL", WDWebResourceType.PDF);
			//Get the URL of the PDF.  
			wdContext.currentContextElement().setVa_PdfURL(file.getUrl(WDFileDownloadBehaviour.OPEN_INPLACE.ordinal()));
	   }
	
	try
	{
		IWDCachedWebResource cachedWebResource=WDWebResource.getWebResource(b,WDWebResourceType.PDF);
									  cachedWebResource.setResourceName(".pdf");
									  wdContext.currentContextElement().setResource(cachedWebResource.getURL());
									IWDWindow window=wdComponentAPI.getWindowManager().createExternalWindow(cachedWebResource.getURL(),"PDF_URL",true);
		//	   Eliminate some features of the window
									window.removeWindowFeature(WDWindowFeature.ADDRESS_BAR);
									window.removeWindowFeature(WDWindowFeature.MENU_BAR);
									window.removeWindowFeature(WDWindowFeature.STATUS_BAR);
									window.removeWindowFeature(WDWindowFeature.TOOL_BAR);
									window.setWindowSize(780,430);
									window.setWindowPosition(20,140);
									window.open();
	}
	catch (WDURLException e1)
	{
		// TODO Auto-generated catch block
		e1.printStackTrace();
	}

Now, when I click the link to open the file, I get one adobe pop up stating: File does not begin with '%PDF-'

I am getting the data in XSTRING format only and I have converted that to Byte as per the code above.

I have followed the following links:

[|]

Thanks in advance.

Regards,

Gaurav Bhardwaj

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi,

Refer these links,

/docs/DOC-8061#48 [original link is broken]

/docs/DOC-8061#50 [original link is broken]

Regards,

Sunaina Reddy T

Former Member
0 Kudos

Hi,

Try to open the byte file in txt format and see whether it is starting with %PDF

Check the same for the file recieved while executing the RFC.

Best Wishes

Idhaya R