Hi,
I have a scenario where my input stream can be a ppt, email, excel, doc, jpg … practically anything.
For example, lets stick to slides. I have a file which will be a PPT of 30 slides, I get a inputstream which has a particular slide data and I need to create a slide with that content in aspose , do this for all 30 slides, at the end convert the entire Presentation object to a PDF.
I am following the below way. This seems to be slow. Can you suggest a better way ?
Also, I could not figure out creating only slides and adding content to it from inputstream , hence I am creating presentation object always. Ideally, I would want to create one presentation object and add multiple slides to the same and add content to it from inputstream (which will have each slide’s data)
Note : I am aware of converting the entire PPT to a PDF once , but I need to do it page by page.
Sample file uploaded1005_Construction_Site_Induction.7z (12.3 KB)
Code:
int numPages = book.getNumberOfPages(); (say 15)
ByteArrayOutputStream baos = new ByteArrayOutputStream();
for (int pageId = 0; pageId < numPages; pageId++)
{
Printable page = book.getPrintable(pageId);
jiPrintablePage currentPage = (jiPrintablePage) page;
InputStream currentInputStream =
currentPage.document.currentLocalFile(pageId).getInputStream(); //each page inputstream
//ideally want to add only to slide and not create a new presentation always
Presentation presentation = new Presentation(currentInputStream);
//save the current slide presentation to the output stream in PDF format. keep adding to output stream for all pages
presentation.save(baos,com.aspose.slides.SaveFormat.Pdf);
}
//Finally write to a document from the output stream as PDF(which will be entire PPT as PDF)
com.aspose.pdf.Document pdfDocument = new com.aspose.pdf.Document(baos.toByteArray());
pdfDocument.save("C:/temp/ImagetoPDF.pdf");
return pdfDocument;