我在我的应用程序中使用单词加载项,我的应用程序中有一些Word文档,我想在MS-word中打开它们。但是,当我尝试打开任何文档时,它都没有页眉和页脚。
当我单击打开文档时,它被编码为base64image。 现在我想在MS-Word中打开它,因为我正在使用
var mySelection = thisDocument.getSelection();
mySelection.insertFileFromBase64(result.base64imgage, "replace");
此代码
,但看不到文档的页眉和页脚。 我知道insertFileFromBase64()会忽略页眉和页脚,但是我应该怎么做才能显示页眉和页脚?
我在jquery中的代码---
var _loadDocumentToWord = function (result) {
Word.run(function (context) {
var contentControls = context.document.contentControls;
contentControls.load("cannotEdit, cannotDelete");
return context.sync()
.then(function () {
// Allow any content controls to be deleted so that we can load the new document
for (var i = 0; i < contentControls.items.length; i++) {
contentControls.items[i].cannotDelete = false;
}
// Create a proxy object for the document.
var thisDocument = context.document;
var thatdocument = result.base64imgage.getSelection();
// Queue a command to clear the body contents.
thisDocument.body.clear();
// Create a proxy object for the default selection.
var mySelection = thisDocument.getSelection();
// Queue a command to insert the file into the current document.
mySelection.insertFileFromBase64(result.base64imgage, "replace");
// Synchronize the document state by executing the queued commands,
// and return a promise to indicate task completion.
return context.sync()
.then(function () {
var contentControls = context.document.contentControls;
contentControls.load("cannotEdit, cannotDelete");
return context.sync()
.then(function () {
// Allow any content controls to be deleted so that we can load the new document
for (var i = 0; i < contentControls.items.length; i++) {
contentControls.items[i].cannotEdit = true;
contentControls.items[i].cannotDelete = true;
}
pageManager.hideAlert();
thisDocument.untrack();
});
});
});
})
预期结果---用页眉和页脚打开文档 实际结果---打开文档时没有页眉和页脚。