Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Stream with name 'WordDocument' not found." #1

Open
NamelessHH opened this issue Apr 16, 2018 · 6 comments
Open

"Stream with name 'WordDocument' not found." #1

NamelessHH opened this issue Apr 16, 2018 · 6 comments

Comments

@NamelessHH
Copy link

NamelessHH commented Apr 16, 2018

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

@KeithHenry
Copy link
Member

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.

@fergalmoran
Copy link

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.

@tomaszzmuda
Copy link

@fergalmoran
Have you found whatt casuses the issue?

@fergalmoran
Copy link

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

@michaelweber
Copy link

Just ran into this while using the library. The problem is in

result = result.Remove(result.IndexOf("\0"));
.

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.

@lansdon2
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants