Is the Slide class serializable?? For the above problem my approach was
to serialize the Presentation and Slide objects and pass them to the
java program. As the parent data can have any number of children I
thought to create a slide outside the java program and pass it into the
method after serializing it. But it throws an error saying
As the exception says, Slide class is not serializable. You will have to find out some other way to handle your problem, like keeping/passing the reference to presentation object and required slide number position for doing your work on it.
In the above code depending on the size of the map
(childScorecardMaplist) I am invoking my java program
“GEDFRPPTGenerationJPO” recursively which returns a slide object and I
am trying to store it into an Object array.
Now what I want is, I want to pass the reference of the
Slide object returned by the java program into a new Presentation and
go on appending it with new slide references returned by the program
and at the end write it into a file. Can you please help me into this?
Is the above approach correct?
If your new program runs inside the your current process space, then create new presentation and new slide with all of your work there and then return the presentation as a java.io.BufferedOutputStream. Then create new presentation from this stream and clone the slide from the presentation to your target presentation.
In case, if your program runs outside your current process space, then you will have to save the new presentation on disk and then read it back from disk in your present code.
Hopefully you are getting me.
What I am saying is that although, you cannot serialize slide, but you can serialize the presentation using Presentation.write method into stream. Then you can create the replica of your presentation in your present code from that stream and clone your slide from replica presentation to your target/final presentation.
e.g
//cloning the slide at nth position of target Presentation from replica Presentation
replicaPres.cloneSlide(replicaPres.getSlideByPosition(1), nthPosition,targetPres, new TreeMap());
Presentation present = new Presentation();
com.get.GEDFRPPTGenerationJPO report = new GEDFRPPTGenerationJPO();
report.generateDynamicReport(context, args, present); //args will contain parent id first
for (int i = 0; i < childScorecardMaplist.size(); i++) {
Map mObject = (Map) childScorecardMaplist.get(i);
args[0] = (String) mObject.get("id");
report.generateDynamicReport(context, args, present); //now args will contain child scorecard id
}
present.getSlides().removeAt(0);
FileOutputStream fostream = new FileOutputStream("C:/Demo.ppt");
//Writing the presentation as a PPT file
present.write(fostream);
fostream.close();
I declaring a presentation object at first and passing the reference into the method
generateDynamicReport. Then for the number of data objects in the map, I am calling the same method and going on appending the slides in the presentation and at last I am writing it into a file “Demo.ppt”. This approach is working fine but again it has other problem. If the number of slides are more than 10 then the program runs out of memory and thows an exception “Java Out Of Heap Space”. We don’t know how many slides the report may have. It may have 100 slides. Increasing the heap size also may not solve as we can increase it upto a certain limit. Any alternative??
Now I want to access three of the columns from the middle set its column width less than the other columns. But once I do this I see that the overall width of the table starts decreasing. I don't want this. I want the overall width of the table to remain the same while only the three columns should have a lesser width than others. How to achieve this?
Thanks for the help. I tried that and its working. I have a question. Suppose I have a table with three columns Baseline, Predicted, Actual as you can see from the ppt attached herewith. Under this table you can see another table with values MF/LY, Equiv R etc. This columns of this table is set dynamically after cerain calculations. Just under the column "Predicted" you can see that there are three columns MF/LY, Equiv R, DVS. The widths of these columns are set by taking the reference of column width of "Predicted" column and dividing it by 3. But after doing that still I had to subtract somewhat around 43 to get the exact width and make it symmetrical to the Predicted column. Can you tell me can't we take the reference of some other table column and divide it into 3 parts to get another column width? The width of Predicted column is 1600 and dividing it by 3 gives us 533 but we have to subtract some another 43 to get exact width. I dnt want to use any hardcoded value because it is totally dynamic.
You should keep the width of Predicted Column as multiple of 3, so that when you divide it into three parts, it could divide into 3 equal whole parts without any fractional part. For example, instead of 1600 (1600/3=533.33) use 1599 (1599/3=533) or 1602 (1602/3=534)
You can also make use of one more option, you can use separate tables vertically aligned (instead of horizontally). For example, you can have a separate table for BaseLine having 5 rows and two columns, where the columns of the first row are merged.
Likewise, you could have another table for Predicted, having 5 rows and 3 columns, where the 3 columns in the first row are merged.
In a similar way, you can construct table for Actual.
Aligning vertically will free you from tension of changing column widths.
Thanks for the help. I have finished generating the tables. Now I need to show it to the user dynamically. Once a user hits a generate button, it will call a bean class which will generate the ppt and a popup will appear showing Open, Save and Cancel buttons. If the user hits Open button the ppt should open in the browser so that the user can view it or else he can save it a certain location to view it later. I have written a code in a jsp which is already working in Apache Tomcat server.
Presentation present = new Presentation(); GEDFRPPTGeneration report = new GEDFRPPTGeneration(); //bean class report.generateAssemblyLevelDynamicReport(context, args, present); OutputStream fostream=response.getOutputStream();
But when I try to execute it in Weblogic server, the ppt opens but it is white. Instead of the tables, there is slide area with no data. If I save the file and check the size its is around 67KB and try to open it same thing happens. Can you please tell me what is the problem here? Why it is not working in Weblogic Server?
Please try to give me the solution ASAP as we have to give a demo to the client. I am stuck up with this and if demo is not given on time everything will be a waste.
In case presentation is empty or broken Aspose.Slides should throw some exceptions. If you need a solution I think it’s a good idea to provide such exceptions and generated (67kb) ppt file. Most probably your weblogic server doesn’t grant enough rights for the app or some jars not found in the classpath.
We need to add one more line for Weblogic server before writing the presentation in outputstream.
response.resetBuffer(); present.write(fostream);
The buffer is automatically set in Tomcat but not in Weblogic. Hope this helps others who might be facing this kind of issue.
I need to ask one more thing regarding this. When the powerpoint presentation opens in a browser and then we try to scroll to the next slide, the browser closes automatically and we are not able to view the next slide. We are able to see the first slide only. This behaviour is not in all browsers. It happens in some browsers only. I would like to add that we are using Internet Explorer browser and the settings are same for all. Could you please solve this issue?
I have a String variable which contains "\n" in between to display the string in a new line. However when I try to use TextFrame.setText() method, the text does not go to the next line. I am using this for slide footer.How can I show the text in a new line where there is a "\n" character?