To save the conversion results to a stream, follow these steps:
Specify the method to obtain the stream where the converted file will be sent.
Pass the method’s name as the document parameter to the Convert() method implementations.
The document parameter could be of Func<Stream>, Func<FileType, Stream>, Func<int, Stream>, or Func<int, FileType, Stream> type.
The following code snippet shows how to save a file to a stream:
publicstaticvoidRun(){Func<Stream>getOutputStream=()=>GetFileStream("c:\\files\\converted.pdf");using(Converterconverter=newConverter("c:\\files\\sample.docx")){PdfConvertOptionsoptions=newPdfConvertOptions();// Pass the output stream as parameterconverter.Convert(getOutputStream,options);}Console.WriteLine($"\nSource file converted successfully.\nSent file to stream.");}// Obtain the stream for the conversion outputpublicstaticStreamGetFileStream(stringoutFile){returnnewFileStream(outFile,FileMode.OpenOrCreate);}
publicstaticvoidRun(){Func<Stream>getOutputStream=()=>GetFileStream("c:\\files\\converted.pdf");FluentConverter// Specify source file location.Load("c:\\files\\sample.docx")// Pass the output stream as parameter.ConvertTo(getOutputStream).Convert();}// Obtain the stream for the conversion outputpublicstaticStreamGetFileStream(stringoutFile){returnnewFileStream(outFile,FileMode.OpenOrCreate);}
Was this page helpful?
Any additional feedback you'd like to share with us?
Please tell us how we can improve this page.
Thank you for your feedback!
We value your opinion. Your feedback will help us improve our documentation.