Hi,
The below is the code snippnet which i have used in my application.We do have an vilid license for this even.The version of Aspose we do use is "Aspose Slides for java 2.4.0".
This code works fine in my local but when i deploy this code in our server which contains vertical clustermembers(Webphere) the exports donot occur and i do get an empty Mater slide(which is an custom defined slide by me and not the default Aspose PPT template which i got from one of the demos in the site.I am attaching the Default Aspose slide,but i am not supposed to add the Custom slide template which i use currently as this is restricted by my client)
The custom template is nothing but an backgroung image in the footer(a thin line) having the copyright information)
String pptPath = realContextPath + "/" + "demo.ppt";
String destPath = realContextPath + "/" + "demo_new.ppt";
String licPath = realContextPath + "/" + "Aspose.Slides.lic";
runLicensce(licPath);
source = new FileInputStream(pptPath);
destination = new FileOutputStream(destPath);
int count=Integer.parseInt(session.getAttribute("counter").toString());
String[] filesToppt = new String[count];
//store files in string
for(int i = 0; i < (count); i++)
{
filesToppt[i] = serFilePath + (i + 1) + "temp.png";
}
pres = new Presentation(pptPath);
for (int i = 0; i < filesToppt.length; i++)
{
Slide slide = pres.addEmptySlide();
slide.setFollowMasterBackground(false);
slide.getBackground().getFillFormat().setType(FillType.PICTURE);
InputStream iStream = new BufferedInputStream(new FileInputStream(filesToppt[i]));
Picture pic = new com.aspose.slides.Picture(pres, iStream);
int picId = pres.getPictures().add(pic);
BufferedImage image = ImageIO.read(new FileInputStream(filesToppt[i]));
int pictureWidth = image.getWidth();
int pictureHeight = image.getHeight();
//Calculating the width and height of picture frame
int pictureFrameWidth = (pictureWidth*6);
int pictureFrameHeight = (pictureHeight*6);
//Adding picture frame to the slide
slide.getShapes().addPictureFrame(picId,(pictureWidth-350),pictureHeight,pictureFrameWidth,pictureFrameHeight);
}
pres.getSlides().removeAt(0);
pres.write(destPath);
String servletPath = request.getRequestURL().toString();
pos = servletPath.lastIndexOf("/");
String pptDemoPath = servletPath.substring(0, pos) + "/" + "demo_new.ppt";
ServletOutputStream out = response.getOutputStream();
response.setContentType("application/vnd.ms-powerpoint");
response.addHeader("Content-Disposition", "attachment; filename=");
BufferedInputStream bis = null;
BufferedOutputStream bos = null;
URL url = new URL(pptDemoPath);
// Use Buffered Stream for reading/writing.
bis = new BufferedInputStream(url.openStream());
bos = new BufferedOutputStream(out);
byte[] buff = new byte[2048];
int bytesRead;
// Simple read/write loop.
while (-1 != (bytesRead = bis.read(buff, 0, buff.length))) {
bos.write(buff, 0, bytesRead);
}
source.close();
destination.close();
bis.close();
bos.flush();
bos.close();
response.flushBuffer();
}
catch (Exception e)
{
Log.sendMessage(Log.MESSAGE_LEVEL_INFO, "pptServlet.java", "Exception: " + e.getMessage().toString());
}
Thanks®ards,
Rajesh