b2xtranslator icon indicating copy to clipboard operation
b2xtranslator copied to clipboard

"Stream with name 'WordDocument' not found."

Open NamelessHH opened this issue 6 years ago • 7 comments

I keep getting this issue when I try to use this library

`

            var file = new FileInfo(Input);

            var reader = new StructuredStorageReader(file.FullName);

            var doc = new b2xtranslator.DocFileFormat.WordDocument(reader);

            var docx = WordprocessingDocument.Create(Output, b2xtranslator.OpenXmlLib.OpenXmlPackage.DocumentType.Document);

            b2xtranslator.WordprocessingMLMapping.Converter.Convert(doc, docx);

` It throws in the instantiation of the WordDocument

NamelessHH avatar Apr 16 '18 17:04 NamelessHH

Cheers for the feedback @NamelessHH!

As a first step please could you add a unit test to the testing project that throws the exception you're seeing? That will give us a starting point for the issue. Thanks.

KeithHenry avatar Apr 17 '18 12:04 KeithHenry

I get this issue when running on Linux - same code works fine on Windows. I haven't had time to investigate much but from what I can see the issue is with StructuredStorageReader._directory - in Linux, the name property of all the entries is string.Empty.

fergalmoran avatar Jan 24 '19 09:01 fergalmoran

@fergalmoran Have you found whatt casuses the issue?

tomaszzmuda avatar Jul 05 '19 06:07 tomaszzmuda

@tomaszzmuda - sorry, no. I gave up and used libreoffice api instead.

fergalmoran avatar Jul 05 '19 08:07 fergalmoran

Just ran into this while using the library. The problem is in https://github.com/EvolutionJobs/b2xtranslator/blob/90d05a6589706cf177a245fcb74e9cba4b6264ae/Common/StructuredStorage/Common/InternalBitConverter.cs#L64.

Document metadata streams begin with a unicode character like "\u0005DocumentSummary\0\0\0\0\0\0". In windows, if you call .IndexOf("\0") on that string, it will treat the "\u0005" as a single unmatching character and return the index of the first \0 after DocumentSummary. In Linux, the null byte that is part of the "\u0005" character will get detected and it will delete everything after the initial byte.

Just replace the result = result.Remove(result.IndexOf("\0")); line with result = result.TrimEnd('\0'); and it works fine.

michaelweber avatar May 08 '20 18:05 michaelweber

The fix by michaelweber helped get past this error on .NET 6. Are there updates to nuget planned?

lansdon2 avatar Apr 27 '22 23:04 lansdon2