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