Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,6 @@
/package-lock.json
.DS_Store
/.idea
dist.zip
dist
package-lock.yaml
1 change: 0 additions & 1 deletion src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,5 @@ export default {
-moz-osx-font-smoothing: grayscale;
text-align: center;
color: #2c3e50;

}
</style>
2 changes: 1 addition & 1 deletion src/components/HelloWorld.vue
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,7 @@ export default {
parseOfdDocument({
ofd: file,
success(res) {
console.log(res)
console.log("返回内容",res)
let t1 = new Date().getTime();
console.log('解析ofd',t1 - t);
that.ofdObj = res[0];
Expand Down
1 change: 0 additions & 1 deletion src/utils/ofd/ofd.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ const doParseOFD = function (options) {
}
})
.catch(res => {
console.log(res)
if (options.fail) {
options.fail(res);
}
Expand Down
2 changes: 1 addition & 1 deletion src/utils/ofd/ofd_parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ const getAnnotations = async function (annoBase, annotations, doc, zip) {
const pageId = anno['@_PageID'];
let fileLoc = anno['ofd:FileLoc'];
fileLoc = replaceFirstSlash(fileLoc);
if (annoBase && fileLoc.indexOf(annoBase) === -1) {
if (annoBase && fileLoc.indexOf(annoBase + "/") === -1) {
fileLoc = `${annoBase}/${fileLoc}`;
}
if (fileLoc.indexOf(doc) === -1) {
Expand Down
8 changes: 7 additions & 1 deletion src/utils/ofd/ofd_render.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ export const calPageBox = function (screenWidth, document, page) {
let array = box.split(' ');
const scale = ((screenWidth - 10) / parseFloat(array[2])).toFixed(1);
setMaxPageScal(scale);
//设置初始页面展示内容比例大小
setPageScal(scale);
box = parseStBox( box);
box = converterBox(box)
Expand Down Expand Up @@ -138,6 +139,7 @@ const renderLayerFromTemplate = function (tpls, template, pageDiv, fontResObj, d
}

export const renderPage = function (pageDiv, page, tpls, fontResObj, drawParamResObj, multiMediaResObj) {
console.log("Render Page", page);
const pageId = Object.keys(page)[0];
const template = page[pageId]['json']['ofd:Template'];
if (Array.isArray(template)) { // 当使用多个模板时
Expand Down Expand Up @@ -216,7 +218,7 @@ const renderSealPage = function (pageDiv, pages, tpls, isStampAnnot, stampAnnot,
const layers = tpls[template['@_TemplateID']]['json']['ofd:Content']['ofd:Layer'];
let array = [];
array = array.concat(layers);
for (let layer of array) {
for (let layer of array) {
if (layer) {
renderLayer(div, fontResObj, drawParamResObj, multiMediaResObj, layer, isStampAnnot);
}
Expand All @@ -225,6 +227,7 @@ const renderSealPage = function (pageDiv, pages, tpls, isStampAnnot, stampAnnot,
const contentLayers = page[pageId]['json']['ofd:Content']['ofd:Layer'];
let array = [];
array = array.concat(contentLayers);
console.log("开始渲染层====================", array);
for (let contentLayer of array) {
if (contentLayer) {
renderLayer(div, fontResObj, drawParamResObj, multiMediaResObj, contentLayer, isStampAnnot);
Expand All @@ -235,6 +238,7 @@ const renderSealPage = function (pageDiv, pages, tpls, isStampAnnot, stampAnnot,
}

const renderLayer = function (pageDiv, fontResObj, drawParamResObj, multiMediaResObj, layer, isStampAnnot) {
console.log("layer=========================", layer);
let fillColor = null;
let strokeColor = null;
let lineWith = converterDpi(0.353);
Expand Down Expand Up @@ -283,6 +287,7 @@ const renderLayer = function (pageDiv, fontResObj, drawParamResObj, multiMediaRe
const textObjects = layer?.['ofd:TextObject'];
let textObjectArray = [];
textObjectArray = textObjectArray.concat(textObjects);
console.log("textObjectArray", textObjectArray);
for (const textObject of textObjectArray) {
if (textObject) {
let svg = renderTextObject(fontResObj, textObject, fillColor, strokeColor);
Expand Down Expand Up @@ -361,6 +366,7 @@ export const renderTextObject = function (fontResObj, textObject, defaultFillCol
const size = converterDpi(parseFloat(textObject['@_Size']));
let array = [];
array = array.concat(textObject['ofd:TextCode']);
console.log("开始渲染ofd:TextCode", array);
const textCodePointList = calTextPoint(array);
let svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
svg.setAttribute('version', '1.1');
Expand Down
Loading