mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-21 07:38:07 +02:00
Annotations: implement support for line annotations
This patch implements support for line annotations. Other viewers only show the popup annotation when hovering over the line, which may have any orientation. To make this possible, we render an invisible line (SVG element) over the line on the canvas that acts as the trigger for the popup annotation. This invisible line has the same starting coordinates, ending coordinates and width of the line on the canvas.
This commit is contained in:
parent
30d63b0c50
commit
e15a2ec523
7 changed files with 125 additions and 0 deletions
1
test/pdfs/.gitignore
vendored
1
test/pdfs/.gitignore
vendored
|
@ -268,6 +268,7 @@
|
|||
!annotation-strikeout.pdf
|
||||
!annotation-squiggly.pdf
|
||||
!annotation-highlight.pdf
|
||||
!annotation-line.pdf
|
||||
!annotation-fileattachment.pdf
|
||||
!annotation-text-widget.pdf
|
||||
!annotation-choice-widget.pdf
|
||||
|
|
BIN
test/pdfs/annotation-line.pdf
Executable file
BIN
test/pdfs/annotation-line.pdf
Executable file
Binary file not shown.
|
@ -3357,6 +3357,13 @@
|
|||
"type": "eq",
|
||||
"annotations": true
|
||||
},
|
||||
{ "id": "annotation-line",
|
||||
"file": "pdfs/annotation-line.pdf",
|
||||
"md5": "fde60608be2748f10fb6522cba425ca1",
|
||||
"rounds": 1,
|
||||
"type": "eq",
|
||||
"annotations": true
|
||||
},
|
||||
{ "id": "annotation-fileattachment",
|
||||
"file": "pdfs/annotation-fileattachment.pdf",
|
||||
"md5": "d20ecee4b53c81b2dd44c8715a1b4a83",
|
||||
|
|
|
@ -1287,6 +1287,27 @@ describe('annotation', function() {
|
|||
});
|
||||
});
|
||||
|
||||
describe('LineAnnotation', function() {
|
||||
it('should set the line coordinates', function() {
|
||||
var lineDict = new Dict();
|
||||
lineDict.set('Type', Name.get('Annot'));
|
||||
lineDict.set('Subtype', Name.get('Line'));
|
||||
lineDict.set('L', [1, 2, 3, 4]);
|
||||
|
||||
var lineRef = new Ref(122, 0);
|
||||
var xref = new XRefMock([
|
||||
{ ref: lineRef, data: lineDict, }
|
||||
]);
|
||||
|
||||
var annotation = annotationFactory.create(xref, lineRef, pdfManagerMock,
|
||||
idFactoryMock);
|
||||
var data = annotation.data;
|
||||
expect(data.annotationType).toEqual(AnnotationType.LINE);
|
||||
|
||||
expect(data.lineCoordinates).toEqual([1, 2, 3, 4]);
|
||||
});
|
||||
});
|
||||
|
||||
describe('FileAttachmentAnnotation', function() {
|
||||
it('should correctly parse a file attachment', function() {
|
||||
var fileStream = new StringStream(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue