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

Free Support Forum - aspose.com

InvalidPdfFileFormatException when saving pdf

sample code that throws exception:

PdfJavaScriptStripper pdfStripper = new PdfJavaScriptStripper();
try (
    FileOutputStream pdfOutputStream = new FileOutputStream(filePath);  
){
  pdfStripper.strip(stream, pdfOutputStream);
}

stream is an instance of Java.io.Inputstream, filePath is a valid disk path.

stack trace:

com.aspose.pdf.exceptions.InvalidPdfFileFormatException: Incorect file format com.aspose.pdf.internal.l9j.ld.lI(Unknown Source) com.aspose.pdf.internal.l5y.l1t$lI.deserialize(Unknown Source) com.aspose.pdf.internal.l9u.le.deserialize(Unknown Source) com.aspose.pdf.internal.l8k.l0v.(Unknown Source) com.aspose.pdf.internal.l8k.l0v.(Unknown Source) com.aspose.pdf.internal.l6l.lf.lI(Unknown Source) com.aspose.pdf.internal.l8k.l0t.(Unknown Source) com.aspose.pdf.internal.l6l.lf.lb(Unknown Source) com.aspose.pdf.internal.l0n.l0p.lf(Unknown Source) com.aspose.pdf.internal.l0n.l0p.(Unknown Source) com.aspose.pdf.ADocument.lI(Unknown Source) com.aspose.pdf.ADocument.(Unknown Source) com.aspose.pdf.ADocument.(Unknown Source) com.aspose.pdf.Document.(Unknown Source) com.aspose.pdf.facades.PdfJavaScriptStripper.strip(Unknown Source)

Can someone helps me with this one? Thank you.

@rolandluo

Would you please share the sample PDF document which you are using at your side for JavaScript stripping. We will test the scenario in our environment and address it accordingly.