Hi,
I have written the below code to add multiple slides and render the image to their background from the server.
when i execute the code i do get an error "Read error".can you please help me on this,if possible can i get a piece of code which helps in redering multiple images
by creating new slides.
int count=Integer.parseInt(session.getAttribute("counter").toString());
String serFilePath=session.getAttribute("filePath").toString();
String[] filesToppt = new String[count];
//store files in string
for(int i = 0; i < (count); i++)
{
filesToppt[i] = serFilePath + (i + 1) + "temp.png";
}
for (int i = 0; i < filesToppt.length; i++)
{
pres = new Presentation(source);
// Slide slide = pres.getSlideByPosition(1);
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);
slide.getBackground().getFillFormat().setPictureId(picId);
pres.write(destination);
source.close();
destination.close();
}
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=demo_new.ppt");
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);
}
Thanks®ards,
Rajesh