ViewOptions.setViewType() does not work as expected on Microsoft Office 2013

Hi,


We’ve encountered a bug when trying to set the document layout programatically, using ViewOptions.setViewType(). This method doesn’t seem to work as expected on all Microsoft Office versions, as documents produced by the sample code below and opened with different Office versions are not always displayed in the desired layout.
final Document doc = new Document(“test.docx”);
for (int viewType = 0; viewType < 6; viewType++) {
if (viewType == 2) continue;
doc.getViewOptions().setViewType(viewType);
doc.save(ViewType.getName(viewType) + “.docx”);
}
Changing the layout seems to work as expected on some Microsoft Office versions (Office 2011 for Mac, Office 2016 for Windows), but the same documents are always opened in the Print Layout View (or in Reading Mode, when editing is disabled) on Office 2013 for Windows.

I have attached an archive containing the file we used to test this issue and the output files produced by the code snippet above.

For example, in Office 2011 for Mac, the output file WEB.docx is opened in the Web View, OUTLINE.docx is opened in the Outline View, NORMAL.docx is opened in the Draft View and PAGE_LAYOUT.docx is opened in the Print Layout View.

How can we obtain a consistent behaviour for all Office versions?

Thank you,
Oana
Hi Oana,

Thanks for your inquiry.

The ViewOptions.ViewType property controls the view mode in Microsoft Word. Although Aspose.Words is able to read and write this option, its usage is application-specific. For example MS Word 2013 and 2016 do not respect the value of this option.

Thank you for confirming this, we also had our suspicions that this was an MS Office issue.

Marking this as a known issue.

Have a great day!
Oana