Empty Slide is Coming after merging of PPTx

Hi Team,


Iam using the below code to merge ppts, after merging I observed the first page is coming as empty, which is not at all required.

Below is the code:

package com.ppt.merge;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.util.LinkedHashMap;
import java.util.Map;

import com.aspose.slides.PresentationEx;
import com.aspose.slides.SlideExCollection;

public class PPTMerge {

public static void main(String[] args) throws IOException {
File file1 = new File(“C:/Aspose_lib/Pitchbook_TOC.pptx”);
FileInputStream input1 = new FileInputStream(file1);
PresentationEx srcPres = new PresentationEx(input1);
PresentationEx destPres = new PresentationEx();
SlideExCollection slds = destPres.getSlides();
for (int i = 0; i <= srcPres.getSlides().getCount() - 1; i++)
{
slds.insertClone(destPres.getSlides().getCount(), srcPres.getSlides().get_Item(i));
}
destPres.write(“c:/Aspose_lib/output.pptx”);
input1.close();
System.out.println(“End”);
}
}

file1 can be anything, you can keep your own pptx of 1 page and test…

Hi Kranthi,

As you are creating a new presentation file as destination file, it adds an empty slide on when empty presentation is created. After adding the slides, you can remove the first slide using destPres.getSlides().removeAt(0);. Please see the following updated code:

File file1 = new File("C:/Aspose_lib/Pitchbook_TOC.pptx");
FileInputStream input1 = new FileInputStream(file1);

PresentationEx srcPres = new PresentationEx(input1);
PresentationEx destPres = new PresentationEx();

SlideExCollection slds = destPres.getSlides();
for (int i = 0; i <= srcPres.getSlides().getCount() - 1; i++) {
    slds.insertClone(destPres.getSlides().getCount(), srcPres.getSlides().get_Item(i));
}

destPres.getSlides().removeAt(0);
destPres.write("c:/Aspose_lib/output.pptx");

input1.close();

System.out.println("End");

Thanks & Regards,

Hi Ahmad,


Thanks for your reply,

The above issue is fixed. after mering the content in ppt is getting overflow. In actual input ppt the formatting is good, but after merging the formating is not proper and the content is getting overflow.

Hi Kranthi,

Thank you for the feedback.

Please share your input presentation files and output file with us for further investigation of the issue.

Thanks & Regards,

Hi Ahmad,


How/Where to upload those ppt’s , I dont see any upload option in this forum

Thanks,

Hi Kranthi,

You can upload / attach the files using the "Add/Update" button while replying the post (right after the text editor ends). Please check the attached screenshot for reference.

Thanks & Regards,

I could not see ,maybe browser compatability issue, please share your support email id, I will send the pptx through mail

Hi Kranthi,

I am afraid, we don’t accept attachments via email. I would suggest you to try a different browser to upload the
files to the forum. If, in case, that doesn’t work, please upload your files to
some third party file hosting site like dropbox and share the link with us in your
forum thread.

Thanks & Regards,

Hi Team,


Iam attaching the 2 input ppt & resultant output

Implementation logic that we used :

public File buildPPT(final List pages, final ECMAssetDO ecmAssetDocumentDO) throws ECMException {

File finalPPTTempFile = null;
InputStream inputPPTStream = null;
final PresentationEx destPres = new PresentationEx();
final SlideExCollection slds = destPres.getSlides();
try
{
if(!pages.isEmpty()){
slds.removeAt(0);
for (int pageCnt = 0; pageCnt < pages.size(); pageCnt++) {
final ECMPage page = (ECMPage) pages.get(pageCnt);
final boolean is_active = page.getBooleanAttributeValue(ECMUtils.ECM_IS_ACTIVE_ATTR);
if (page != null && is_active) {
if (page.getContentSize() > 0) {
inputPPTStream = page.getContent();
final PresentationEx srcPres = new PresentationEx(inputPPTStream);
for (int i = 0; i <= srcPres.getSlides().getCount()-1; i++)
{
slds.addClone(srcPres.getSlides().get_Item(i));
}
}
} else {
DfLogger.warn(this, “The Slide : " + page.getSingleAttribute(TITLE) + " was not included in Build Presenation because it seems to be corrupted.”, null, null);
}
}
destPres.write(“C:\Aspose_lib\output3212.pptx”);
}
}catch (ECMException e) {
throw new ECMException(e, e.getMessage());
} catch (Exception e) {
throw new ECMException(e, e.getMessage());
}
finalPPTTempFile = new File(“C:\Aspose_lib\output3212.pptx”);
return finalPPTTempFile;
}

Hi Team,


Can you please let us know the status of the issue. ?


Hi Kranthi,

Well, you need to set the size of the slides for the new presentation as per your source presentation so that content is displayed fine after cloning. Please see the following sample code to get an idea how this can be done.

File file1 = new File("C:\\Data\\PPTX_Files\\PPTX_Files\\input-1.pptx");
FileInputStream input1 = new FileInputStream(file1);

PresentationEx srcPres = new PresentationEx(input1);
PresentationEx destPres = new PresentationEx();

destPres.getSlideSize().setType(SlideSizeTypeEx.Custom);
destPres.getSlideSize().setSize(srcPres.getSlideSize().getSize());

SlideExCollection slds = destPres.getSlides();
for (int i = 0; i <= srcPres.getSlides().getCount() - 1; i++)
{
    slds.insertClone(destPres.getSlides().getCount(), srcPres.getSlides().get_Item(i));
}

destPres.getSlides().removeAt(0);
destPres.write("c:/data/output.pptx");

Thanks & Regards,

Thanks Team,


Its working.

Hi Kranthi,

Thank you for the feedback.

We are pleased to know that your reported issue is resolved. Please feel free to contact support in case you need any further assistance.

Thanks & Regards,