Convert and save results in input stream using Java

Hello guys,

Does anyone knows how to convert to List of GroupDocsInputStream for the new version 17.12-Java?

Old version
List gis = m_oHandler.<List> convert(fileName,
m_oImageOptions)

Current version
ConvertedDocument convertedDocument = conversionHandler.convert(“filename”, saveOption);

Thanks in advance.

Regards,
Erich

@ejlotilla,

Thank you for taking interest in GroupDocs.Conversion for Java and posting your concerns. In latest version of the API, converted results are only handled by ConvertedDocument class as follows:

ConvertedDocument convertedDocumentStream = conversionHandler
.<List<GroupDocsInputStream>> convert(fileName, new ImageSaveOptions());

However, we are further investigating this scenario at our end. Your investigation ticket ID is CONVERSIONJAVA-516. As we have any update, we shall inform you.

Thanks for the reply. But how to get the List of GroupDocsInputStream from the object convertedDocumentStream ? Because convertedDocumentStream got few methods only like save, also casting to a list doesn’t work. Thank you.

@ejlotilla,

We are investigating this scenario at our end. You shall be notified about the outcomes.

Thanks a lot.

@ejlotilla,

You are welcome.

@ejlotilla,

Please follow the code given below. Hope it will help you.

// Instantiating the conversion handler
ConversionHandler handler = new ConversionHandler(config);

ConvertedDocument result = handler.convert(sourceFile, new ImageSaveOptions());

ArrayList<InputStream> streams = new ArrayList<>();
for (int i = 1; i <= result.getPageCount(); i++) {
    GroupDocsOutputStream stream = new GroupDocsOutputStream();
    result.save(stream, i);
    stream.setPosition(0);
    streams.add(stream.toInputStream());
}

// Do anything with converted streams
for (InputStream stream : (Iterable<InputStream>) streams) {
    stream.close();
}

thanks a lot.

1 Like

@ejlotilla,

You are welcome.