我是 Javascript 的新手,我正在学习一些关于使用 PDFTron 显示 pdf 的教程。但是我在设置自定义属性时遇到了问题。你能告诉我哪里出错了吗?
window.webviewerFunctions = {
initWebViewer: function () {
const viewerElement = document.getElementById('viewer');
WebViewer({
path: 'lib',
initialDoc: 'lib/simpledoc.pdf', // replace with your own PDF file
}, viewerElement)
.then((instance) => {
instance.setTheme('dark');
instance.disableElements(['downloadButton','printButton' ]);
instance.disableElements(['toolbarGroup-Insert']);
})
.then(function(instance) {
var modal = {
dataElement: 'meanwhileInFinlandModal',
render: function renderCustomModal(){
var div = document.createElement("div");
div.style.color = 'white';
div.style.backgroundColor = 'hotpink';
div.style.padding = '20px 40px';
div.style.borderRadius = '5px';
div.innerText = 'Meanwhile in Finland';
return div
}
}
instance.setCustomModal(modal);
instance.openElements([modal.dataElement]);
});
}
};
答案 0 :(得分:0)
Promise 处理程序需要返回 instance
,因为这是作为输入传递给链中下一个处理程序的内容。
.then((instance) => {
instance.setTheme('dark');
instance.disableElements(['downloadButton','printButton' ]);
instance.disableElements(['toolbarGroup-Insert']);
return instance;
})