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

Free Support Forum - aspose.com

Trouble converting pptx file to PDF

i'm having trouble converting pptx file to PDF,
Exception :
com.aspose.slides.kt: The file is ZIP archive. It can be Microsoft PowerPoint 2007 PPTX presentation.
here is my very simple code:
import java.io.ByteArrayOutputStream;
import java.io.FileInputStream;
import java.io.FileOutputStream; import java.io.InputStream; import com.aspose.cells.SaveFormat; import com.aspose.cells.Workbook; import com.aspose.slides.Presentation; public class toSlide { public static void main(String[] args) throws Exception { convertingExcelStreamtoPDF(); }

private static FileOutputStream slideInputStreamToPDFOutputStream( InputStream stream) throws Exception
{
try{ Presentation pres = new Presentation(stream); stream.close(); ByteArrayOutputStream dstStream = new ByteArrayOutputStream(); pres.save(dstStream, SaveFormat.PDF); FileOutputStream output = new FileOutputStream("444.pdf"); output.write(dstStream.toByteArray()); return output; } catch (Exception e) { System.out.println(e.getCause()); throw new Exception(e.getCause()); } } public static void convertingExcelStreamtoPDF() throws Exception { InputStream stream = new FileInputStream("test2.pptx"); FileOutputStream output = slideInputStreamToPDFOutputStream(stream); output.close(); } }

I am using aspose-slides-8.6.0-java

the exception is thrown on this line:
Presentation pres = new Presentation(stream);

This message was posted using Email2Forum by Awais Hafeez.
What can cause this error?

I get this exception on line:
Presentation pres = new Presentation(stream);

This is my code:

import java.io.ByteArrayOutputStream;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.InputStream;
import com.aspose.cells.SaveFormat;
import com.aspose.slides.Presentation;


public class toSlide {

public static void main(String[] args) throws Exception {
convertingExcelStreamtoPDF();
}

private static FileOutputStream slideInputStreamToPDFOutputStream(
InputStream stream) throws Exception {
Presentation pres = new Presentation(stream);
stream.close();
ByteArrayOutputStream dstStream = new ByteArrayOutputStream();
pres.save(dstStream, SaveFormat.PDF);
FileOutputStream output = new FileOutputStream("444.pdf");
output.write(dstStream.toByteArray());
return output;
}
public static void convertingExcelStreamtoPDF() throws Exception {
InputStream stream = new FileInputStream("test2.pptx");
FileOutputStream output = slideInputStreamToPDFOutputStream(stream);
output.close();
}
}

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

It seems that you are opening a PPTX file using the Presentation class. To open PPTX files, please use PresentationEx class instead of Presentation class. In case you still face any issue, please share your template file with us and we will check it.

PresentationEx pres = new PresentationEx(stream);

Thanks & Regards,

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

Thanks for the confirmation that your issue got fixed. In case you need any further assistance, please feel free to contact support.

Thanks & Regards,