cancel
Showing results for 
Search instead for 
Did you mean: 

File does not begin with %PDF- error

Former Member
0 Kudos

Hi All,

We have a scenario in which a R/3 report has to be displayed in PDF format, at front end, with the help of a webdynpro application. The data is being sent through a RFC function module. The report was working fine, but due to the upgrade of backend from 4.6C to ECC 6.0, the function module to convert data to pdf format in R/3 was not working propely.

To fix this error, we had to add a parameter of type 'Blob' in the function module, which can send the data in binary format.

I have made reqired changes in the webdynpro applicaiton to use this parameter, but it is still giving me the error " File does not begin with %PDF- "

Please help to resolve this issue.

Thanks for your time & help!

Regards,

Anupama

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi,

I have made reqired changes in the webdynpro applicaiton to use this parameter, but it is still giving me the error " File does not begin with %PDF- "--- please post the changes you have done in the code, you can read the binary data and display repsort as a file.

Could you please check the services are running to support the PDF in portal.

Refer below link(this include backend and java side code help):-

http://wiki.sdn.sap.com/wiki/display/WDJava/Creatingpdfinthebackend

Hope this may help you....

Deepak!!!

Former Member
0 Kudos

Hi please find the code that i have added :

Hi Deepak,

thanks a lot for replying!

This is the piece of code that i haev added in component controller of the application :

I am trying to fetch the data into an array of type byte. Pdf1 is the export node from R/3.

		long filelen = wdContext.nodePdf1().size();		
		byte[] temp1 = new byte[(int)filelen];

for (int i = 0; i < wdContext.nodePdf1().size(); i++) {
			temp1 = wdContext.nodePdf1().getPdf1ElementAt(i).getContent();
		}

IWDResource resource = WDResourceFactory.createCachedResource(temp1, "Job Description" + position + System.currentTimeMillis()+".pdf", WDWebResourceType.PDF);
		
		wdContext.currentContextElement().setRolePurposeURL(resource.getUrl(WDFileDownloadBehaviour.AUTO.ordinal()));
		wdComponentAPI.getMessageManager().reportSuccess("url name ....."+wdContext.currentContextElement().getRolePurposeURL());
		wdContext.currentContextElement().setRolePurposeVisible(WDVisibility.VISIBLE);

For more clarifications please come back.

Regards,

Anupama

Former Member
0 Kudos

Hi Anupama,

Please check this Note: 1146711 - Problem opening PDF files.

Thanks and Regards,

Shyam.

Former Member
0 Kudos

HI,

Instead of 'temp1' in the line

IWDResource resource = WDResourceFactory.createCachedResource(temp1, "Job Description" + position + System.currentTimeMillis()+".pdf", WDWebResourceType.PDF);

Try to use 'wdContext.nodePdf1().getPdf1ElementAt(i).getContent().getBytes();.

Use this sample code.. This will open an html file

String html="<html>Test<html>";

IWDResource res=WDResourceFactory.createResource(html.getBytes(),"HTML File",WDWebResourceType.HTML);

IWDWindow win = wdComponentAPI.getWindowManager().createNonModalExternalWindow(res.getUrl(WDFileDownloadBehaviour.OPEN_INPLACE.ordinal()),"Title");

win.open();

Best Wishes

Idhaya R

Former Member
0 Kudos

Hi Shyam,

We checked tis note.. and implemented it... but the problem is still there... as it is not relevant to our situation.

Anyways, thanks for your time and help!

Regards,

Anupama

Former Member
0 Kudos

Hi Anupama,

Try to check the value of temp1, Please post the value of temp1,resource and the URL.

Deepak!!!

Former Member
0 Kudos

HI Deepak,

The value for temp1 = [B@1dc4d3f (for a specific user) temp1 length = 255

temp1 is a byte array, in which i am taking the value fetched from R/3 FM sent in the form of Blob datatype.

Value supposed to be in temp1 will be different for different users.

The value of resource is =

xyz.com/wd~rps/MyRolePurpose/~wd_key22_1274071720178/Job+Description600223571274071720178.pdf?sap-wd-download=1&sap-wd-cltwndid=74f1f3ce616f11dfb2d20050568348a8&sap-wd-secure-id=74f1f3d0616f11dfc3d80050568348a85609101389&sap-wd-appwndid=74f1f3cf616f11dfb3fb0050568348a8&sap-wd-norefresh=X

The value of url is =

/xyz.com/wd~rps/MyRolePurpose/~wd_key22_1274071720178/Job+Description600223571274071720178.pdf?sap-wd-download=1&sap-wd-cltwndid=74f1f3ce616f11dfb2d20050568348a8&sap-wd-secure-id=74f1f3d0616f11dfc3d80050568348a85609101389&sap-wd-appwndid=74f1f3cf616f11dfb3fb0050568348a8&sap-wd-norefresh=X

Is the data sent from R/3 is encoded ?. The lenght of the array is displayed at 255, but i could see only 9 characters in the output.

Thanks & Regards,

Anupama

Former Member
0 Kudos

Hi All,

This issue is fixed now. Instead of using Blob, the data from R/3 backend was send to webdynpro application in form of XString.

Webdynpro application was able to recognize data & PDF is displayed correctly!

I thank you all for your time and judicious help!

Regards,

anupama

Former Member
0 Kudos

Any pointers provided would be helpful....

Regards,

Anupama