js xps external and internal links

This commit is contained in:
Kulikova Svetlana
2021-08-11 11:17:27 +03:00
parent 2627e2a7dd
commit 1034f66555
3 changed files with 130 additions and 9 deletions

View File

@ -381,6 +381,21 @@ window.onload = function()
{
this.file.getGlyphs(pageIndex, width, height);
};
this.getExternalLinks = function(pageIndex, width, height)
{
var res = this.file.getExtLinks(pageIndex, width, height);
return res;
};
this.getInternalLinks = function(pageIndex, width, height)
{
var res = this.file.getIntLinks(pageIndex, width, height);
return res;
};
this.ext = null;
this.Int = null;
this._paint = function()
{
@ -462,6 +477,10 @@ window.onload = function()
{
page.Image = this.file.getPage(i, w, h);
this.getGlyphs(i, w, h);
this.ext = this.getExternalLinks(i, w, h);
this.ext.Page = i;
this.Int = this.getInternalLinks(i, w, h);
this.Int.Page = i;
}
let x = ((xCenter * this.retinaPixelRatio) >> 0) - (w >> 1);
@ -471,6 +490,25 @@ window.onload = function()
if (this.Selection.page == i && this.Selection.IsSelection)
ctx.drawImage(this.Selection.Image, 0, 0, w, h, x, y, w, h);
if (this.ext && this.ext.Page == i)
{
ctx.fillStyle = "#FF0000";
for (let j = 0; j < this.ext.length; j++)
{
let Link = this.ext[j];
ctx.fillRect(x + Link.X, y + Link.Y, Link.W, Link.H);
}
}
if (this.Int && this.Int.Page == i)
{
ctx.fillStyle = "#00FF00";
for (let j = 0; j < this.Int.length; j++)
{
let Link = this.Int[j];
ctx.fillRect(x + Link.X, y + Link.Y, Link.W, Link.H);
}
}
ctx.strokeRect(x + lineW / 2, y + lineW / 2, w - lineW, h - lineW);
}
};