mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-19 22:58:07 +02:00
[Editor] Correctly serialize highlight data (regression from #17499)
This commit is contained in:
parent
61e5dae7fd
commit
fc7c320bd8
3 changed files with 80 additions and 25 deletions
|
@ -385,19 +385,12 @@ class HighlightEditor extends AnnotationEditor {
|
|||
|
||||
#serializeOutlines(rect) {
|
||||
const [pageWidth, pageHeight] = this.pageDimensions;
|
||||
const width = this.width * pageWidth;
|
||||
const height = this.height * pageHeight;
|
||||
const [tx, ty] = rect;
|
||||
const outlines = [];
|
||||
for (const outline of this.#highlightOutlines.outlines) {
|
||||
const points = new Array(outline.length);
|
||||
for (let i = 0; i < outline.length; i += 2) {
|
||||
points[i] = tx + outline[i] * width;
|
||||
points[i + 1] = ty + (1 - outline[i + 1]) * height;
|
||||
}
|
||||
outlines.push(points);
|
||||
}
|
||||
return outlines;
|
||||
return this.#highlightOutlines.serialize(
|
||||
rect[0],
|
||||
rect[1],
|
||||
this.width * pageWidth,
|
||||
this.height * pageHeight
|
||||
);
|
||||
}
|
||||
|
||||
/** @inheritdoc */
|
||||
|
|
|
@ -301,6 +301,19 @@ class HighlightOutline extends Outline {
|
|||
return buffer.join(" ");
|
||||
}
|
||||
|
||||
serialize(x, y, width, height) {
|
||||
const outlines = [];
|
||||
for (const outline of this.#outlines) {
|
||||
const points = new Array(outline.length);
|
||||
for (let i = 0; i < outline.length; i += 2) {
|
||||
points[i] = x + outline[i] * width;
|
||||
points[i + 1] = y + (1 - outline[i + 1]) * height;
|
||||
}
|
||||
outlines.push(points);
|
||||
}
|
||||
return outlines;
|
||||
}
|
||||
|
||||
get box() {
|
||||
return this.#box;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue