Files
web/public/yhofd/yhofd.html
2025-10-22 15:39:40 +08:00

59 lines
2.1 KiB
HTML
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1">
<link rel="icon" href="favicon.ico">
<title>SCOFDReader demo</title>
<style>
html,
body {
padding: 0;
margin: 0;
width: 100vw;
height: 100vh
}
</style>
<script src="./SCReader.umd.min.js"></script>
<link rel="stylesheet" href="./SCReader.css">
</head>
<body>
<div id="ofdBox"></div>
</body>
<script>
/** 实例化ofd对象并指定容器id实例中容器id为“app”
* 1、实例化方法中1234567为后期正式采购的授权码将授权码填写后阅读器无未授权提示该效果不影响功能调试
* 2、实例化方法中json为初始化配置参数可选择性控制界面功能按钮隐藏或显示
* 3、如需只显示内容主界面将配置参数中on document:active 代码片段解开即可
*/
// 动态获取URL参数
const params = new URLSearchParams(window.location.search);
const fileName = params.get('name');
const username = sessionStorage.getItem("username")
const fileUrl = params.get('url');
let ofd = new SCOFDReader(window.ofdBox, {
server: "http://192.168.101.121:9001", // 服务器地址
showToolsbar: true, //是否显示文档工具栏
showNavigation: false, //是否显示文档导航栏
showPanel: false, //是否显示左侧面板
single: true //单文件模式(开启则再打开文件时,会关闭自动以前打开的文件)
});
// 设置打开o;
// fd文件传入参数支持url文件、文件流对象、文件对象
ofd.openFile(fileUrl, { name: fileName });
ofd.registerRepeatTextWatermark(username, 15, '仿宋', '#888888', -45, 100, { x: 50, y: 30 }, () => !0, false);
// 显示左侧导航栏 leftPanel setShowLeftPanel(boolean)
//ofd.vm.setShowLeftPanel(true)
// 显示工具栏 tool + 文档信息 setShowTools(boolean)
//ofd.vm.setShowTools(true)
// 显示底部工具栏 state setShowState(boolean)
//ofd.vm.setShowState(true)
</script>
</html>