Skip to Content
avatar image
Former Member

Converting binary file from rfc to excel/pdf/doc/jpg/jig etc.

Hi experts,

i need to convert binary file from output of a rfc to excel/pdf/doc/jpg/jig etc.

now while converting, only the pdf file is getting converted properly, any other file except pdf is not getting converted properly.

i need to convert and download the files.

following is the code i have used to test for each type of files. so far only the pdf is converting correctly.

public void onActionDownload(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )

  {

    //@@begin onActionDownload(ServerEvent)

  try{

  ByteArrayOutputStream baos = new ByteArrayOutputStream();

  ByteArrayInputStream bais = null;

  int count = wdContext.nodeBinfile().size();

  int destPos = 0;

  String msg = null;

  //byte[] out = new byte[1024*count];

  //byte[] Content = new byte[1024 * count];

  // Read bytes for each PO…

  for (int k = 0; k < count; k++){

  wdContext.nodeBinfile().moveTo(k);

  // Copy to content byte array

  System.arraycopy(wdContext.currentBinfileElement().getLine(), 0,Content, destPos,wdContext.currentBinfileElement().getLine().length);

  destPos = destPos + wdContext.currentBinfileElement().getLine().length;

  baos.write(Content);

  }

  out = baos.toByteArray();

  if(!out.equals(null))

  {

  //IWDResource resource =WDResourceFactory.createResource(out, ".PDF",WDWebResourceType.PDF);

  //IWDResource resource =WDResourceFactory.createResource(out, ".docx",WDWebResourceType.DOC);

  //IWDResource resource =WDResourceFactory.createResource(out, ".xls",WDWebResourceType.XLS);

  //IWDResource resource =WDResourceFactory.createResource(out, ".JPG",WDWebResourceType.JPG_IMAGE);

  //IWDResource resource =WDResourceFactory.createResource(out, ".PNG",WDWebResourceType.PNG);

  //IWDResource resource =WDResourceFactory.createResource(out, ".GIF",WDWebResourceType.GIF_IMAGE);

  String url = resource.getUrl(WDFileDownloadBehaviour.AUTO.ordinal());

  IWDWindow window = wdComponentAPI.getWindowManager().createNonModalExternalWindow(url,"File");

  window.setWindowSize(0,0);

  window.show();

  }

  }

  catch(Exception ex){

  wdComponentAPI.getMessageManager().reportException("Value." + wdContext.nodeBinfile().size() , true);

  }

  

    //@@end

  }

Please help.

Note: any image file which is less then 1024 in size, is getting converted properly.

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • avatar image
    Former Member
    Feb 05, 2014 at 08:20 AM

    We are facing a similar issue. It would be kind if somebody could look into this? 😔

    Add comment
    10|10000 characters needed characters exceeded

  • Feb 06, 2014 at 10:35 AM

    Code which was used to show excel:

    excelCSVFile is an input stream.

    cachedResource = WDResourceFactory.createCachedResource(excelCSVFile, fileName, WDWebResourceType.XLS, false);

    String excelURL = cachedResource.getUrl(WDFileDownloadBehaviour.ALLOW_SAVE.ordinal());

    Does this help?

    Add comment
    10|10000 characters needed characters exceeded