Skip to Content
0
Former Member
Mar 05, 2010 at 08:10 AM

image inside word doc through webdynpro

30 Views

Hi All ,

I am working on WebDynpro Java Application. In my application i have some data in node which i want to display as word doc along with one image saved on server.

i have written following code for the same

StringBuilder htmlCode = new StringBuilder();

htmlCode.append("<html><body><p>An image from another folder:</p><img src=").

append("/home/erecuser/eRecLogo/524796671.jpg").append("width=\"33\" height=\"32\" /></body></html>");

WDResourceFactory.createCachedResource(htmlCode.toString().getBytes("UTF-8"), "MyImage.doc", WDWebResourceType.DOC).download(WDFileDownloadBehaviour.ALLOW_SAVE.ordinal());

when i run this code word doc is opening but not able to view image. My image is saved at location /home/erecuser/eRecLogo/524796671.jpg inside root directory on same server on which m running application. Please let me know how to resolve this issue or is there ant other way to show these details along with image as DOC file through WebDynpro Java

all files are saved as follows

String fileExt = resource.getResourceType().getFileExtension();

InputStream text = resource.read(false);

//InputStream text = resource.read(true);

int temp = 0;

String filePath = "";

String fileName = "";

filePath = "/home/erecuser/eRecLogo/";

filePath = filePath+wdContext.currentContextElement().getFileName();

File osFile = new File(filePath);

FileOutputStream fileOutputStream = new FileOutputStream(osFile);

/*while((temp=text.read())!=-1)

fileOutputStream.write(temp);*/

// New added

int l_int_NoOfBytes = text.available();

byte[] byteArray = new byte[l_int_NoOfBytes];

int l_int_byteRead = text.read(byteArray, 0, l_int_NoOfBytes);

fileOutputStream.write(byteArray);

// New added ends

fileOutputStream.close();

text.close();

Thanx in advance

Kavita

Edited by: kavita chavan on Mar 5, 2010 9:54 AM