Load document from Stream

There might be the case when your document is not physically located on the disk. Instead, you have the document in the form of a stream. In this case, to avoid the overhead of saving stream as a file on disk, GroupDocs.Conversion enables you to convert the file streams directly.

The following are the steps to be followed:

  • Specify the method to obtain document stream; 
  • Pass method’s name to Converter class constructor.

Following code snippet serves this purpose:

try{
    Converter converter = new Converter(new FileInputStream("sample.docx"));
    PdfConvertOptions options = new PdfConvertOptions();

    converter.convert("converted.pdf", options);
} catch (Exception e){
    throw new GroupDocsConversionException(e.getMessage());
}