Issue converting tiff to pdf

Hello,

We are trying to convert a tiff document to pdf using aspose pdf for java version 24.3 and noticing the following issue. Could you please assist. Sample code we are using is provided below. We cannot provide the document here because of our data policies.

com.aspose.pdf.Document doc = new com.aspose.pdf.Document();

	// load font from resouces folder
	ArrayList fontSources = new ArrayList(Arrays.asList(FontSettings.getDefaultInstance().getFontsSources()));
	
	Path path = Paths.get(ConvertDocument.class.getResource("/").toURI());		
	FolderFontSource folderFontSource = new FolderFontSource(path.toString(), true);

	// Add the custom folder which contains our fonts to the list of existing font
	// sources
	fontSources.add(folderFontSource);

	// Convert the ArrayList of source back into a primitive array of FontSource
	// objects
	FontSourceBase[] updatedFontSources = (FontSourceBase[]) fontSources
			.toArray(new FontSourceBase[fontSources.size()]);

	// Apply the new set of font sources to use
	FontSettings.getDefaultInstance().setFontsSources(updatedFontSources);

	outByteStream = new java.io.ByteArrayOutputStream();

	// Add a page to pages collection of document
	Page page = doc.getPages().add();		

	// Create an image object
	Image image = new Image();
	image.setInNewPage(true);		
	image.setBlackWhite(true);
	
	// Add the image into paragraphs collection of the section
	page.getParagraphs().add(image);
	// Set the image file stream
	image.setImageStream(imageStream);

	doc.save(outByteStream);

This is the exception we are noticing when we run the conversion.

lass com.aspose.pdf.internal.ms.System.IO.l1p: exception —> java.io.IOException: Attempted read on closed stream.
— End of inner exception stack trace —
com.aspose.pdf.internal.l89p.lj.lI(Unknown Source)
com.aspose.pdf.internal.ms.System.IO.Stream.fromJava(Unknown Source)
com.aspose.pdf.Image.setImageStream(Unknown Source)
nj.aoc.ito.ecm.lambda.ConvertDocument.convertImageToPdf(ConvertDocument.java:576)
nj.aoc.ito.ecm.lambda.ConvertDocument.handleRequest(ConvertDocument.java:355)
nj.aoc.ito.ecm.lambda.ConvertDocument.handleRequest(ConvertDocument.java:46)
lambdainternal.EventHandlerLoader$PojoHandlerAsStreamHandler.handleRequest(EventHandlerLoader.java:207)
lambdainternal.EventHandlerLoader$2.call(EventHandlerLoader.java:925)
lambdainternal.AWSLambda.startRuntime(AWSLambda.java:273)
lambdainternal.AWSLambda.startRuntime(AWSLambda.java:208)
lambdainternal.AWSLambda.main(AWSLambda.java:198)
at com.aspose.pdf.internal.l89p.lj.lI(Unknown Source)
at com.aspose.pdf.internal.ms.System.IO.Stream.fromJava(Unknown Source)
at com.aspose.pdf.Image.setImageStream(Unknown Source)
at nj.aoc.ito.ecm.lambda.ConvertDocument.convertImageToPdf(ConvertDocument.java:576)
at nj.aoc.ito.ecm.lambda.ConvertDocument.handleRequest(ConvertDocument.java:355)
at nj.aoc.ito.ecm.lambda.ConvertDocument.handleRequest(ConvertDocument.java:46)
at lambdainternal.EventHandlerLoader$PojoHandlerAsStreamHandler.handleRequest(EventHandlerLoader.java:207)
at lambdainternal.EventHandlerLoader$2.call(EventHandlerLoader.java:925)
at lambdainternal.AWSLambda.startRuntime(AWSLambda.java:273)
at lambdainternal.AWSLambda.startRuntime(AWSLambda.java:208)
at lambdainternal.AWSLambda.main(AWSLambda.java:198)
Caused by: java.io.IOException: Attempted read on closed stream.
at org.apache.http.conn.EofSensorInputStream.isReadAllowed(EofSensorInputStream.java:107)
at org.apache.http.conn.EofSensorInputStream.read(EofSensorInputStream.java:133)
at com.amazonaws.internal.SdkFilterInputStream.read(SdkFilterInputStream.java:90)
at com.amazonaws.event.ProgressInputStream.read(ProgressInputStream.java:180)
at com.amazonaws.internal.SdkFilterInputStream.read(SdkFilterInputStream.java:90)
at com.amazonaws.internal.SdkFilterInputStream.read(SdkFilterInputStream.java:90)
[ Method :: convertImageToPdf :: convert-Excep :: [Ljava.lang.StackTraceElement;@4efac082]
[ Method :: convertImageToPdf/migration :: convert-Excep :: [Ljava.lang.StackTraceElement;@48aca48b]
at com.amazonaws.internal.SdkFilterInputStream.read(SdkFilterInputStream.java:90)
at com.amazonaws.event.ProgressInputStream.read(ProgressInputStream.java:180)
at com.amazonaws.internal.SdkFilterInputStream.read(SdkFilterInputStream.java:90)
at com.amazonaws.util.LengthCheckInputStream.read(LengthCheckInputStream.java:107)
at com.amazonaws.internal.SdkFilterInputStream.read(SdkFilterInputStream.java:90)
at com.amazonaws.services.s3.internal.S3AbortableInputStream.read(S3AbortableInputStream.java:125)
at com.amazonaws.internal.SdkFilterInputStream.read(SdkFilterInputStream.java:90)
… 11 more

@judiciary

Can you please share how you are initializing and making the image stream in your code? We will test the scenario in our environment with one of our sample files and share our feedback with you.

We are reading the file from AWS S3 bucket and the code is also running as an aws lambda

S3Object s3InputFile = s3.getObject(new GetObjectRequest(filePath, sourceFileName));
InputStream inputFileStream = s3InputFile.getObjectContent();

Note: Not all the files are having this issue.

@judiciary

Looks like the issue is related to specific type of files. We need sample file to properly address the issue by generating a ticket in our issue tracking system. If possible, could you please arrange such file that we can use?