Cannot create more than 40 slides due to large content in each slide


#1

hi!!

Just a reminder!!! Awaiting your reply as soon as possible!!!!

attatching the base presentation file, from where we get the slides and the paragraph.

the same slide is cloned as many times as we require and as u can see the placeholder.get(1) has 4 paragraphs.

depending upon the data we add the paragraphs to the cloned slides

{

/*this slide0 is from the sample.ppt which i have attatched*/

Slide slide0 = slides.get(0);
Slide cloneSlide = cloneTheSlide(slide0, indexSubItem);
indexSubItem++;

Placeholders pholders = cloneSlide.getPlaceholders();

//for the paragraph
Placeholders pholdersBase = slides.get(0).getPlaceholders();
TextHolder thBase = (TextHolder) pholdersBase.get(1);
Paragraphs parasBase = thBase.getParagraphs();

Paragraph paragraph0 = null;

paragraph0 = new Paragraph(parasBase.get(0));
slideTempTitle = templateTitle;
paras.add(indexItem,paragraph0);

paras.get(indexItem).getPortions().get(0).setText("titleDesc);

}

this function is called many times depending upon the length of the Collection.

so number of slides are cloned and paragraphs are added.

Thank U

Regards


#2

Did you replace cloneSlide function call with

cloneSlide = pres.cloneSlide(slide, slideIndex, pres, new TreeMap()); ?



I tested this code with very long text and thousands of slides. And I don’t have such problem.

Do you filter all \r \n and other characters from the text?

Try to add TextFrame to your template and use it instead of TextHolder.


#3

i tried using text frame instead of second place holder but it didn't help...it still gives the same error..

for ur reference.. giving u the entire function which create powerpoint slides

this function takes collection and iterates it and gives the output....

also sending u the new Presentation format...

private void createPowerPoint(Collection subItemColl, String forAllLevel) throws Exception
{
try
{
Slide slide0 = slides.get(0);
Slide cloneSlide = cloneTheSlide(slide0, indexSubItem);
indexSubItem++;

Placeholders pholders = cloneSlide.getPlaceholders();

TextHolder thSlideTitle = (TextHolder) pholders.get(0);
TextHolder th = (TextHolder) pholders.get(1);
//TextHolder thSlideProject = (TextHolder) pholders.get(2);

Shapes shapes = cloneSlide.getShapes();
System.out.println("****shapes.size()***"+shapes.size());
TextFrame tf = shapes.get(1).getTextFrame();
Paragraphs paras = tf.getParagraphs();
paras.clear();

//for the paragraph

Shapes shapesBase = slides.get(0).getShapes();
System.out.println("****shapes.size()***"+shapes.size());
TextFrame tfBase = shapesBase.get(1).getTextFrame();
Placeholders pholdersBase = slides.get(0).getPlaceholders();
//TextHolder thBase = (TextHolder) pholdersBase.get(1);
Paragraphs parasBase = tfBase.getParagraphs();
System.out.println("parasBase.size()::"+parasBase.size());

Iterator itrsubItemColl = subItemColl.iterator();
TableReportData data = new TableReportData();
int indexItem = 0;
String slideTempTitle = "";

Paragraph paragraph0 = null;
Paragraph paragraph1 = null;
Paragraph paragraph2 = null;
Paragraph paragraph3 = null;

while(itrsubItemColl.hasNext())
{
data = (TableReportData) itrsubItemColl.next();

Integer itemlevel1 = data.getProjectItemLevel1();
Integer itemlevel2 = data.getProjectItemLevel2();
Integer itemlevel3 = data.getProjectItemLevel3();
Integer itemlevel4 = data.getProjectItemLevel4();

int calLevel = ApplicationUtils.getTemplateItemLevel(itemlevel2,itemlevel3,itemlevel4);

String templateTitle = data.getProjectItemTitle();
String templateDesc = data.getProjectItemDesc();

if(data.getItemLabel() == null)
{
templateTitle = data.getProjectItemTitle();
}
else
{
templateTitle = data.getItemLabel();
}

/* if(templateDesc != null && !(templateDesc.trim().equals("")))
{
templateDesc = " - " + templateDesc;
}*/
if(ApplicationUtils.validateString(templateDesc))
{
templateDesc = " - " + templateDesc;
}
else
{
templateDesc = " ";
}
String titleDesc = templateTitle + templateDesc;

if(calLevel == 1)
{
paragraph0 = new Paragraph(parasBase.get(0));
slideTempTitle = templateTitle;
paras.add(indexItem,paragraph0);
paras.get(indexItem).getPortions().get(0).setText(titleDesc);
paras.get(indexItem).getPortions().get(0).setFontHeight((short)level1FontSize.shortValue());
}
else if(calLevel == 2)
{
paragraph1 = new Paragraph(parasBase.get(1));
paras.add(indexItem,paragraph1);
paras.get(indexItem).getPortions().get(0).setText(titleDesc);
paras.get(indexItem).getPortions().get(0).setFontHeight((short)level2FontSize.shortValue());
}
else if(calLevel == 3)
{
paragraph2 = new Paragraph(parasBase.get(2));
paras.add(indexItem,paragraph2);
paras.get(indexItem).getPortions().get(0).setText(titleDesc);
paras.get(indexItem).getPortions().get(0).setFontHeight((short)level3FontSize.shortValue());
}
else if(calLevel == 4)
{
paragraph3 = new Paragraph(parasBase.get(3));
paras.add(indexItem,paragraph3);
paras.get(indexItem).getPortions().get(0).setText(titleDesc);
paras.get(indexItem).getPortions().get(0).setFontHeight((short)level4FontSize.shortValue());
}
++indexItem;
}

//Shapes shapes = cloneSlide.getShapes();
if(forAllLevel != null && forAllLevel.equals("true"))
{
thSlideTitle.getParagraphs().get(0).getPortions().get(0).setText(slideTempTitle);
thSlideTitle.getParagraphs().get(0).getPortions().get(0).setFontHeight((short)level1FontSize.shortValue());
}
else
{
thSlideTitle.getParagraphs().get(0).getPortions().get(0).setText(projectName);
thSlideTitle.getParagraphs().get(0).getPortions().get(0).setFontHeight((short)level1FontSize.shortValue());
}

shapes.get(2).getTextFrame().getParagraphs().get(0).getPortions().get(0).setText(projectName);
shapes.get(3).getTextFrame().getParagraphs().get(0).getPortions().get(0).setText(projectDateStr);
//thSlideProject.getParagraphs().get(0).getPortions().get(0).setText("the "+projectName);
}
catch(Exception e)
{
logger.log(Logger.ERROR, "Exception in TableWordReportWriter.createPowerPoint :: " + e);
e.printStackTrace();
throw e;
}
}