该文是我国版式文档格式OFD前端WEB展示之EasyOFD的版本升级。
DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>title>
head>
<script type="text/javascript">
function load(){
let yourElement=document.getElementById("yourElementId");
let easyOfd = new EasyOFD('myofdID', yourElement);
//你的文件url地址下载后传递给 loadFromBlob方法
easyOfd.loadFromBlob(blob);
}
script>
<style>
.OfdButton{
padding: 10px 20px;
background-color: #007bff;
color: #fff;
border: none;
border-radius: 5px;
cursor: pointer;
margin-right: 10px;
}
style>
<body onload="load()" style="
margin: 0;">
<div id='yourElement'>
div>
<body>
body>
<script type="text/javascript" src="./lib/x2js.js">script>
<script type="text/javascript" src="./lib/jszip.min.js">script>
<script type="text/javascript" src="./lib/eaysjbig2.js">script>
<script type="text/javascript" src="./lib/opentype.min.js">script>
<script type="text/javascript" src="./EasyOFD.js">script>
html>
创建项目,增加依赖
npm create vue@latest
//依赖
npm i jszip
npm i x2js
npm i jb2
npm i opentype //字体图元的支持
//本程序
npm i easyofd
在vue控件内使用
<script setup>
import EasyOFD from "easyofd";
import { onMounted } from 'vue'
onMounted(() => {
let yourElement=document.getElementById("1111111");
let ofd=new EasyOFD('myofdID', yourElement);
//ofd.loadFromBlob(blob);
})
</script>
<template>
<div id="1111111"> </div>
</template>
<style >
.OfdButton{
padding: 10px 20px;
background-color: #007bff;
color: #fff;
border: none;
border-radius: 5px;
cursor: pointer;
margin-right: 10px;
}
</style>