Conversion gives an crazy error

Hi, i’m trying to implement a simple conversion from rtf to doc.
For input, i’m using a xtrareport from devexpress, then exporting it to rtf into a memory stream.
I’m trying to convert this stream to a doc.
But i get the attached error.
Screenshot 2023-03-03 162405.png (20.6 KB)
Screenshot 2023-03-03 162413.png (8.9 KB)

The code to convert:

  private byte[] GetBinaryContent(XtraReport report, ReportFormats format)
    {
        using (var mem = new MemoryStream())
        {
            //some ifs... 
            else if (format == ReportFormats.Doc || format == ReportFormats.Docx)
            {
                report.ExportToRtf(mem);
                _mem = mem;

                var getDocStream = new SaveDocumentStream(GetSaveFileStream);

                _memToSave = new MemoryStream();

                using (Converter converter = new Converter(GetFileStream))
                {
                    var options = new WordProcessingConvertOptions
                    {
                        Format =
                            format == ReportFormats.Doc ?
                            WordProcessingFileType.Doc :
                            WordProcessingFileType.Docx
                    };
                    var possibleConversions = converter.GetPossibleConversions();
                    converter.Convert(getDocStream, options);
                }
            }
            return mem.ToArray();
        }
    }

    private Stream GetFileStream() => _mem;
    private Stream GetSaveFileStream() => _memToSave;
1 Like

@GerenciaRiskManager

Could you please share the source/problematic file as well?

i’m afraid that besides it’s a test, the full file have sensitive info, but i can share the first 2 pages.

12.pdf (232.0 KB)

Also, i tried to read some dummy file from disk, And get this another error.

Captura de tela 2023-03-06 092952.png (66.0 KB)

manage to resolve the issue expliciting the input file format via load options.

var loadOptions = new WordProcessingLoadOptions();
    loadOptions.Format = WordProcessingFileType.Rtf;
    using (Converter converter = new Converter(GetFileStream, ()=> loadOptions))
       {...}

Thanks for the help!

1 Like

@GerenciaRiskManager

You are welcome.