Merge pull request #20179 from calixteman/add_rect_popup
[Editor] Add a Rect entry to a saved popup in order to avoid to have an invalid pdf
This commit is contained in:
commit
592d6c070a
@ -1213,9 +1213,18 @@ class AnnotationEditor {
|
|||||||
|
|
||||||
addComment(serialized) {
|
addComment(serialized) {
|
||||||
if (this.hasEditedComment) {
|
if (this.hasEditedComment) {
|
||||||
|
const DEFAULT_POPUP_WIDTH = 180;
|
||||||
|
const DEFAULT_POPUP_HEIGHT = 100;
|
||||||
|
const [, , , trY] = serialized.rect;
|
||||||
|
const [pageWidth] = this.pageDimensions;
|
||||||
|
const [pageX] = this.pageTranslation;
|
||||||
|
const blX = pageX + pageWidth + 1;
|
||||||
|
const blY = trY - DEFAULT_POPUP_HEIGHT;
|
||||||
|
const trX = blX + DEFAULT_POPUP_WIDTH;
|
||||||
serialized.popup = {
|
serialized.popup = {
|
||||||
contents: this.comment.text,
|
contents: this.comment.text,
|
||||||
deleted: this.comment.deleted,
|
deleted: this.comment.deleted,
|
||||||
|
rect: [blX, blY, trX, trY],
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4995,6 +4995,7 @@ describe("annotation", function () {
|
|||||||
rotation: 90,
|
rotation: 90,
|
||||||
popup: {
|
popup: {
|
||||||
contents: "Hello PDF.js World !",
|
contents: "Hello PDF.js World !",
|
||||||
|
rect: [1, 2, 3, 4],
|
||||||
},
|
},
|
||||||
id: "143R",
|
id: "143R",
|
||||||
ref: highlightRef,
|
ref: highlightRef,
|
||||||
@ -5010,7 +5011,7 @@ describe("annotation", function () {
|
|||||||
const popup = data[0];
|
const popup = data[0];
|
||||||
expect(popup.data).toEqual(
|
expect(popup.data).toEqual(
|
||||||
"1 0 obj\n" +
|
"1 0 obj\n" +
|
||||||
"<< /Type /Annot /Subtype /Popup /Open false /Parent 143 0 R>>\n" +
|
"<< /Type /Annot /Subtype /Popup /Open false /Rect [1 2 3 4] /Parent 143 0 R>>\n" +
|
||||||
"endobj\n"
|
"endobj\n"
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user