Free Support Forum - aspose.com

Not able to export when i change the default template

Hi,

I have an issue with using Aspose slides for java.
I have used the Default ppt("demo.ppt") Template which i downloaded from one of the examples on the Aspose site,but when i try to replace the template with my custom defined template and export some data from my application in PPT it doesnot work for me and each time i do get an empty slide.

Can you please help me on this.

Thanks&Regards,
Rajesh

Hello Rajesh,

I have tried to understand the issue shared by you but unfortunately have not been able to clearly identify your issue. Please share your source presentation/template and the code snippet that you are using on your end to reproduce the issue. Please also share that which version of Aspose.Slides for .NET you are using on your end. Please also share details about the environment on your end. Once you will share the requested information we will be in position to further investigate and resolve the issue.

Thanks and Regards,

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&regards,
Rajesh

Hi Rajesh,

I will be working with the code shared by you. It will be really appreciable, if you may please try using Aspose.Slides for Java 2.6.0 on your end. Please also provide us with the information related to the environment configuration where by you are using Aspose.Slides for Java.

Thanks and Regards,

Hi,

We do use jdk 1.5.0,websphere 6.0(the server in which i got this error is an cluster member having 2 vertical clusters),IDE is NetBeans6.5.

But i could not send you the custom defined Template as it is client supplied.Just you need to add an Background image in the whole length of footer of the Master slide with some text.

Any thing else do i need to furnish.Please specify me.

Thanks&Regards,

Rajesh

Hi Rajesh,

I regret to share that I currently don't possess the environment shared by you and may need some time to establish it for further verification on my end. As you have have mentioned that your web server is using some cluster. Unfirtunately, it will not be possible to establish same environment on my end. I will try establishing environment having WebSphere installed on it. I would kindly recommend you to please try using Aspose.Slided for Java 2.6.0 and share your feedback with us. FYI, there are two separate Jar files in Aspose.Slides for Java 2.6.0. One of which is for Java 6 & 7, and other one is for Java 4 & 5. Can you please also try using JDK 1.6 on your end for necessary testing as well and share your feedback with us. I will really appreciate your cooperation in this regard.

Thanks and Regards,