PDF error in Aspose Convertion

We are getting the following error on some of the pdf’s which we are able to open and validate. But on conversion to Aspose the same pdf while merging with other documents, we are receiving the following error.

class com.aspose.pdf.exceptions.InvalidPdfFileFormatException: Incorrect file header
com.aspose.pdf.internal.l8n.l0v.l0h(Unknown Source)
com.aspose.pdf.internal.l8n.l0v.l0y(Unknown Source)
com.aspose.pdf.internal.l8n.l0v.lI(Unknown Source)
com.aspose.pdf.internal.l8n.l0v.(Unknown Source)
com.aspose.pdf.internal.l8n.l0v.(Unknown Source)
com.aspose.pdf.internal.l6if.lf.lI(Unknown Source)
com.aspose.pdf.internal.l8n.l0t.(Unknown Source)
com.aspose.pdf.internal.l6if.lf.lb(Unknown Source)
com.aspose.pdf.internal.l0h.l0p.lf(Unknown Source)
com.aspose.pdf.internal.l0h.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)

If we dont convert the pdf with aspose, it is working fine.

Version of Aspose PDF using - 21.2

@venkata.veerubhotla

Please try to use the latest version of the API i.e. 22.3 and if issue still persists, please share your sample PDF document along with sample code snippet so that we can test the scenario in our environment and address it accordingly.

Used the latest version 22.3 Still the same error.TestFile.pdf (79.8 KB)

The following code. If we do not convert the pdf using aspose - then the InputStream is working fine. But if we are converting then the issue is occuring.

public void convertPdfToPdfTest(InputStream sourceFile) throws Exception{
ByteArrayOutputStream byteOut = new ByteArrayOutputStream();
try {
com.aspose.pdf.Document pdfDocument = new com.aspose.pdf.Document(sourceFile);

		pdfDocument.save(byteOut);			
	}catch (Exception ex) {
		
		throw new Exception(ex);
	} finally {

	}
	log.debug("END of convertPdfToPdf");
	
	InputStream asposeins = new ByteArrayInputStream(
			((ByteArrayOutputStream) byteOut).toByteArray());	
	
	com.aspose.pdf.Document pdfDocument = new com.aspose.pdf.Document(asposeins);	
	System.out.println("Completed");
}

@venkata.veerubhotla

We were able to reproduce the issue in our environment and have logged it as PDFJAVA-41475 in our issue tracking system. We will further look into its details and keep you posted with the status of its correction. Please be patient and spare us some time.

We are sorry for the inconvenience.