Adding an image as per MSDN docs makes the file unreadable by Word for Office 365 (Windows)
See original GitHub issueDescription
When creating a basic WordprocessingDocument using instructions from: https://docs.microsoft.com/en-us/office/open-xml/how-to-insert-a-picture-into-a-word-processing-document the document cannot be opened by the MS Word application specifically Microsoft Word for Office 365 MSO (16.0.12527.20986) (version 2002) on Windows 10 (also tested on macOS using the Word for Office 365 as well).
When opening the warning monit appears:
Word experienced an error trying to open the file.
The same file opens fine in Office 365 Online.
Information
- .NET Target: .NET Core 3.1
- DocumentFormat.OpenXml Version: 2.11.3
Repro Wrote a minimal reproduction. Generated ‘test.docx’ is unopenable by the mentioned Word application.
https://github.com/p-kaczynski/OpenXmlImageRepro
I have tried a number of things, like including/omitting editId, anchorId etc. vs the base code from MSDN, but the result is always the same.
Observed
An error when opening the file using Word for Office 365 on Windows/Mac
Please note, that posibly the same issue was reported on SO by someone else very recently: https://stackoverflow.com/questions/63529065/inserting-image-corrupts-open-xml-sdk-generated-word-file
Expected
The document should open correctly.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:6
Top GitHub Comments
Ok, found the issue.
This line in the MSDN docs:
is invalid, because of the
https
that should behttp
.Changing that makes the document open without issue.
@sdudnic @p-kaczynski it looks like the PR only changes one instance of the “https” error. There are several instances in the example code in that document and these should all be fixed. That doesn’t explain why the one instance your commit fixed didn’t get changed. Perhaps it takes time to publish? I can follow up with the content owner to check on that but you might want to update or submit another PR to fix all the occurrences of “https”.