on 03-29-2008 7:35 PM
Hi, do you know how can I change a file from type binary to com.sap.something.Resource? Thanks in advance, Balmer
Hi ,
To convert binary to PDF,
Insert a UI of type IFrame and Create value Attribute called PdfUrl.
Bind PdfUrl to IFrames source.
byte[] pdfContent = wdContext.currentOutput<Element>.getBin_File();
IWDCachedWebResource pdfResource = WDWebResource.getWebResource(pdfContent,WDWebResourceType.PDF);
try
{
wdContext.currentContextElement().setPdfUrl(pdfResource.getURL());
}
catch(Exception e)
{
wdComponentAPI.getMessageManager().reportException(e.getMessage(),true);
}
Regards,
Sunitha Hari.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi
Use the following
byte[] data = //Your byte data
IWDResource resource = WDResourceFactory.createInputStream(data)
Regards
Ayyapparaj
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
But why are using IWDInputStream in between. You can directly IWDResource from the byte content as:
byte[] byteArr = // your content.
IWDResource cache = WDResourceFactory.createCachedResource(byteArr,fileName,WDWebResourceType.JPG_IMAGE);
thanks & regards,
Manoj
Edited by: Manoj Kumar on Apr 3, 2008 4:34 PM
Ok, thanks for help. Could you please advice why this code dont project my picture?
ResultSet rs = stmt.getResultSet();
while (rs.next()){
byte[] b=rs.getBytes(1);
//IPrivateMyProjectView.IContextElement imageEle=wdContext.createContextElement();
IWDResource cache = WDResourceFactory.createCachedResource(b,"photo",WDWebResourceType.JPG_IMAGE);
if (cache != null) {
setImage2(cache.getUrl(WDFileDownloadBehaviour.OPEN_INPLACE.ordinal()));
}
}
}
catch(Exception e){
wdComponentAPI.getMessageManager().reportWarning(e.toString());
}
Image2 - context of the Child Image, type String. Regards, Balmer.
"What is setImage2 here?"
Image2 - Image Child, setImage2 -method. I was able to project picture this way from upload file. This below works fine
IMyProjectView.IContextElement element1 = wdContext.currentContextElement();
if (element1.getFileResource1() != null)
{
Object IMessageMyProject = null;
IWDResource resource1 = element1.getFileResource1();
if (element1.getFileResource1() != null) {
element1.setImage1(element1.getFileResource1().getUrl(WDFileDownloadBehaviour.OPEN_INPLACE.ordinal()));
}
I did equivalent thing like with element1 here but it didnt help
"Are you sure that you are getting data from the ResultSet?"
yes
"And you have mapped the source property od your image UI with setImage2?"
since I made it working in upload I think yes
Thanks for help and looking for a reply, Balmer.
To get the URL of the resource, you can just use toString().
IWDResource image = WDResourceFactory.createCachedResource(b,"photo",WDWebResourceType.JPG_IMAGE);
String url = image.toString();
Armin
User | Count |
---|---|
89 | |
10 | |
9 | |
9 | |
9 | |
6 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.