Add support for text markup annotation#121
Add support for text markup annotation#121konbraphat51 wants to merge 46 commits intocantoo-scribe:masterfrom
Conversation
|
Changing eslint and the yarn.lock doesn't seem related to that PR. Can you split it into 2 PRs please? |
|
Okey, this PR is ready for review! |
|
|
||
| const quadPointsArray = context.obj( | ||
| [ | ||
| options.quadPoints.leftbottomX, |
There was a problem hiding this comment.
According to the PDF Spec, the order should be: leftBottom, rightBottom, rightTop, leftTop, meaning that you probably inverted the top part.
There was a problem hiding this comment.
Oh, sorry for that. I fixed it
There was a problem hiding this comment.
Wait, I remembered now why I did this.
https://stackoverflow.com/questions/9855814/pdf-spec-vs-acrobat-creation-quadpoints
It seems that Adobe implemented the last two corners horizontally inverted.
I tried the order in the spec and became like this hourglass shape:

/QuadPoints [69.9398 58.8418 96.5932 58.8418 96.5932 47.3526 69.9398 47.3526 ]
There was a problem hiding this comment.
↑forgot to mention: The image is rendered by Adobe Acrobat
There was a problem hiding this comment.
We need to test in multiple readers, then. If Adobe Acrobat failed to respect the spec and other reader respected it, we need to give priority to the spec because Adobe will probably have to comply at some point.
| /** | ||
| * The quad points that define the region(s) to be marked up. | ||
| */ | ||
| quadPoints: { |
There was a problem hiding this comment.
That's a very annoying data format. Please use Rect instead. Way easier to manipulate!
There was a problem hiding this comment.
Do you mean Rect as src\utils\elements\Rectangle.ts?
Actually, qualPoints also covers trapezoids and hourglass shapes, not only rectangles. So I think that is not a good idea
my experiments (sorry it's in Japanese): https://qiita.com/konbraphat51/items/a7ddb30e5277d5e10a5a#%E8%9D%B6%E3%81%A4%E3%81%8C%E3%81%84
This needs further discussion according on https://stackoverflow.com/questions/9855814/pdf-spec-vs-acrobat-creation-quadpoints This reverts commit 2f8db96.
| * Array specifying annotation's border characteristics | ||
| * @returns The border characteristics as a PDFArray or undefined if none. | ||
| */ | ||
| Boader(): PDFArray | undefined { |
| // convert the annotation dictionaries to PDFAnnotation instances | ||
| const annotations: PDFAnnotation[] = []; | ||
| for (let i = 0; i < annotsArray.size(); i++) { | ||
| const annotDict = annotsArray.lookup(i); |
There was a problem hiding this comment.
Should we use lookupMaybe instead?
| expect(page.annotations.length).toBe(0); | ||
| }); | ||
|
|
||
| it('can add a highlight annotation to a page', async () => { |
There was a problem hiding this comment.
Add a test to edit an existing annotation
What?
This add supports reading and writing text markup annotation objects.
This adds:
PDFPage.addTextMarkupAnnotation()to add text markup annotation objectReading
PDFPage.annotations()PDFAnnotationclass instancesEditing
PDFAnnotationclassAdding
PDFPage.addTextMarkupAnnotation()Why?
How?
PDFAnnotationclass instance.PDFAnnotationTesting?
New Dependencies?
N/A
Screenshots
This is created by this code:
Suggested Reading?
Anything Else?
N/A
Checklist