Get all Chart/IChart objects in presentation

Hi There,


Im using ASPOSE SLIDES 15.8.0 for Java. Im trying to merge data from a different source to a template presentation. The template contains some predefined shapes, and depending on those shapes im trying to add data to the template. This all works pretty nice for all common textholders and I’m also able to find Table shapes, but I can’t seem to find charts. Below there is a generic snippet of code that im using and I have attached the template file that Im loading and searching through. What am I looking for? Is there another approach that I should use?

Example snippet:

//get and open the template file
Presentation pres = getNewPresentation();

ISlideCollection presslds = pres.getSlides();
for(int i=0; i<presslds.size(); i++){
ISlide slide = presslds.get_Item(i);
IShapeCollection shapes = slide.getShapes();
for (int s=0; s < shapes.size(); s++){
IShape shp = shapes.get_Item(s);
if (shp.isTextHolder()){
IAutoShape ashape = (IAutoShape) shp;
` ITextFrame tf = ashape.getTextFrame();
//WORKS
//DO MY LOGIC HERE
}else if (shp instanceof ITable){
ITable tbl = (ITable)shp;
//WORKS
//DO MY LOGIC HERE
}else if (shp instanceof Chart){
//CANT FIND THE CHART
System.out.println(“Found a Chart shape!”);
}else if (shp instanceof IChart){
//CANT FIND THE ICHART
System.out.println(“Found a Chart shape!”);
}
}
}

Okay, not sure why but I am able to get it to work now, so I guess this topic is resolved. IT actually works like in my snippet.


Seems that the overall performance of the Slides framework was giving me a hard time.

Hi Bart,



I have observed your latest comments and its good to know that your code is working now. I have also observed your comments regarding the performance of Aspose.Slides. Can you please share the performance hindrances on your term in tangible terms with us along with source data, sample code, Java details, Operating System details, application type and results achieved. We will investigate the issue further on our end to help you out.



Many Thanks,

Well, from my first quick tests it seems that the very first time I initialize a presentation object after starting my application it takes a lot of time: In this example the variable “template” is a String with the location to the template file I attached in my first post. This code:


long start = System.currentTimeMillis();
Presentation pres = new Presentation(template);
System.out.println("Init a new pres took me: "+(System.currentTimeMillis() - start));

Gives the following results:
1st time after starting application:
Init a new pres took me: 8500

2nd time:
Init a new pres took me: 353
3rd time:
Init a new pres took me: 281
4th time:
Init a new pres took me: 263

RESTARTING MY APP:
1st time after starting application:
Init a new pres took me: 7902

2nd time:
Init a new pres took me: 344
3rd time:
Init a new pres took me: 281
4th time:
Init a new pres took me: 244

I have a webapplication that runs on tomcat 7 with java 7. An my computer is pretty good:
16GB, i7 CPU. but the first time I run this code the fan actually starts to speed up…

Also stopping Tomcat normally is very fast, but it seems that when I have run this code once it takes more time to stop, my guess is a lot of stuff is loaded in memory the first time a presentation is initialized. My Tomcat memory settings are:

-Xmx1024m
-XX:MaxPermSize=512m
-XX:ReservedCodeCacheSize=128m

This should be sufficient for the things I’m doing.

If you want even more information please ask, but it seems like this is already a problem when just calling the new Presentation(file); constructor.

Hi,

I have observed your comments and like to share with you that the difference of time taken while loading the presentation for the first time and in subsequent iterations is because when presentation is loaded for the first time then all necessary resources are allocated and Document Object Model (DOM) of Aspose.Slides is loaded into memory. This is the reason you are observing difference in time.

I hope this will clarify the concept. Please share if I may help you further in this regard.

Best Regards,

Hi,

I was wondering what is happening with this. The last answer I got in this post, about a year ago was not satisfactory. I waited for about a year now, and just updated to the JAVA ASPOSE SLIDES 16.7.0 version, I just ran the same routine again and still see that it is not performing. Using your simple example: Open Presentation|Aspose.Slides Documentation still gives me performances that are not realistic. Opening a simple template file costs 10+ seconds. I also still when googling find multiple people that have/had the same problems. Still not sure if they solved it or just went on and created different solutions. I most cases i see the same awnser in the end which is something like:

“loading the presentation for the first time and in subsequent iterations is because when presentation is loaded for the first time then all necessary resources are allocated and Document Object Model (DOM) of Aspose.Slides is loaded into memory.”

Which is fine, but not when that takes up 10+ seconds to load a PPTX with only 3 slides. I really like to find a solution. Or at least a suitable workaround.

Hi Rignald,


We are sorry for your inconvenience.

I have observed your comments and request you to please share the source presentation with us with which you are having issue with. I will investigate the issue further on my end to help you out. Please also share the Java and Operating system details with us as well.

Many Thanks,