Search code examples
devexpress-wpf

RichEditDocumentServer docx conversion to pdf not working


I am trying to convert a word document(.docx) into PDF. I am trying to pass Stream object into load document method of RichEditDocumentServer,but my bad ,I am getting a blank pdf. I tried passing the file path in load document method ,which worked fine. But my requirement has to meet with stream object. Can anyone help me to fix the issue. A sample code has been added below.

 private Stream ConvertToPdf(Stream fileStream)
        {
            RichEditDocumentServer server = new RichEditDocumentServer();
            fileStream.Seek(0, SeekOrigin.Begin);
            server.LoadDocument(fileStream, DocumentFormat.Doc);
            Stream convertStream = new MemoryStream();
            server.ExportToPdf(convertStream);
            convertStream.Seek(0, SeekOrigin.Begin);
            return convertStream;
        }

Solution

  • it worked with the below link

    https://www.devexpress.com/support/center/Question/Details/T340655#answer-9c3224dd-383a-4faa-9672-9b34e36c1c7a

    server.LoadDocument(fileStream, DocumentFormat.OpenXml);