We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Merging of PPTX InputStream into Single File

Hi Team,


We have InputStream consists of multiple pptx file.

Our requirement is to convert the above InputStream to a single file (I dont want to store this file to local copy)

Please provide us with the solution

Thanks,
Kranthi

Hi Kranthi,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

I am not able to understand your query properly. Could you please share some details (or sample code you have) to explain the issue. It will help us in assisting you properly.

Thanks & Regards,

Simple I have to merge multiple pptx files. The input will be InputStream

Hi Kranthi,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Aspose.Slides provides the feature to Clone the slides between presentations which can be used to merge the presentations. You can check the details from the following documentation link.

Cloning Slides in PresentationEx

Please try the following sample code to merge the two presentation files passed as input streams.

//Files to be used for merging

File file1 = new File("C:/data/HelloWorld.pptx");

File file2 = new File("C:/data/input.pptx");

//Opening files using input stream

FileInputStream input1 = new FileInputStream(file1);

FileInputStream input2 = new FileInputStream(file2);

//Instantiate PresentationEx class to load the source PPTX file

PresentationEx srcPres = new PresentationEx(input1);

//Instantiate PresentationEx class for destination PPTX (where slide is to be cloned)

PresentationEx destPres = new PresentationEx(input2);

//Clone the slides from the source PPTX to the destination PPTX

SlideExCollection slds = destPres.getSlides();

for (int i = 0; i <= srcPres.getSlides().getCount() - 1; i++)

{

slds.insertClone(destPres.getSlides().getCount(), srcPres.getSlides().get_Item(i));

}

//Write the destination PPTX to disk

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

//Close the streams

input1.close();

input2.close();

In case you face any issue or need further assistance, please feel free to contact support.

Thanks & Regards,

Hi Ahmad,


Thanks for the reply.

In the example you have taken pptx file as input. Here in our case the input is in the form of InputStream & output I dont want to save to local disk I want to store it in outputStream
Table Cell Background is coming as solid & font colour as white: I want cell background to be white & font colour to be blank . can you please modify the below code ? :

*************
public static void insertTableForTOC(SlideEx slide, Element tableShapeElement, String shapeID) {
ShapeEx tableShape = PPTUtil.findShape(slide, shapeID);
float xCoord = tableShape.getX();
float yCoord = tableShape.getY();
NodeList rowNodeList = tableShapeElement.getElementsByTagName(PPTUtil.TABLE_ROW);
int rowCnt = rowNodeList.getLength();
Element tempRowEle = (Element) rowNodeList.item(0);
NodeList tempCellNodeList = tempRowEle.getElementsByTagName(PPTUtil.TABLE_CELL);
double[] dblCols = new double[tempCellNodeList.getLength()];
double[] dblRows = new double[rowCnt];
for (int i = 0; i < dblRows.length; i++) {
dblRows[i] = 10;
}
for (int i = 0; i < dblCols.length; i++) {
dblCols[i] = 10;
}
tableShape.getSlide().getShapes().remove(tableShape);
int id = slide.getShapes().addTable(xCoord, yCoord, dblCols, dblRows);
TableEx table =(TableEx) slide.getShapes().get_Item(id);
table.setX(xCoord);
table.setY(yCoord);
table.setName(shapeID);
RowEx row=table.getRows().get_Item(0);
row.setMinimalHeight(10);
for(int rCnt = 0; rCnt < rowCnt; rCnt++){
row=table.getRows().get_Item(rCnt);
row.setMinimalHeight(10);
Element rowEle = (Element) rowNodeList.item(rCnt);
NodeList rowCellNodeList = rowEle.getElementsByTagName(PPTUtil.TABLE_CELL);
for (int i = 0; i < rowCellNodeList.getLength(); i++) {
CellEx cell=row.get_Item(i);
ColumnEx col = table.getColumns().get_Item(i);
if(i==0){
col.setWidth((float)PPTUtil.inchesToPixels(7.55));
}else{
col.setWidth((float)PPTUtil.inchesToPixels(2.33));
}
if(rowCellNodeList.item(i).getFirstChild() != null){
String cellText = rowCellNodeList.item(i).getFirstChild().getNodeValue();
cellText = cellText.trim();
cell.getFillFormat().setFillType(FillTypeEx.Solid);
cell.getTextFrame().getParagraphs().get_Item(0).getPortions().get_Item(0).setText(cellText);
cell.getTextFrame().getParagraphs().get_Item(0).getPortions().get_Item(0).setFontHeight(10);
}else{
cell.getTextFrame().setText("");
}
}
}
}

Hi Kranthi,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Please add the following lines of code to set the cell background color as white and cell text color as black.

cell.getFillFormat().setFillType(FillTypeEx.Solid);

cell.getFillFormat().getSolidFillColor().setColor(Color.WHITE);

cell.getTextFrame().getParagraphs().get_Item(0).getPortions().get_Item(0).getFillFormat().setFillType(FillTypeEx.Solid);

cell.getTextFrame().getParagraphs().get_Item(0).getPortions().get_Item(0).getFillFormat().getSolidFillColor().setColor(Color.BLACK);

In case you face any issue, please let us know.

Thanks & Regards,

Thanks Ahmad,


I will test meanwhile

Can you please look into the other issue which is similar to this, below is the link

http://www.aspose.com/community/forums/547954/aspose-slide-convert-the-inputstream-into-file-return-type/showthread.aspx#547954


Hi Kranthi,

I have replied to your post in the thread you mentioned above.

Thanks & Regards,