height offset

This commit is contained in:
Timo Bejan 2022-02-09 12:48:36 +02:00
parent e8255a580e
commit 2bf40effe3

View File

@ -435,7 +435,7 @@ export class AnnotationActionsService {
this._annotationDrawService.annotationToQuads(viewerAnnotation, viewer);
}
acceptResize(
async acceptResize(
$event: MouseEvent,
viewer: WebViewerInstance,
annotationWrapper: AnnotationWrapper,
@ -443,6 +443,7 @@ export class AnnotationActionsService {
) {
const data = { dossier: this._dossier };
const fileId = this._screenStateService.fileId;
const textAndPositions = await this._extractTextAndPositions(viewer, annotationWrapper.id);
this._dialogService.openDialog('resizeAnnotation', $event, data, async (result: { comment: string }) => {
const textAndPositions = await this._extractTextAndPositions(viewer, annotationWrapper.id);
const text =
@ -558,18 +559,20 @@ export class AnnotationActionsService {
// TODO: this is an educated guess for lines that are close together
// TODO: so that we do not extract text from line above/line below
const fivePercentHeightOffset = rect.height / 20;
const percentHeightOffset = rect.height / 10;
const pdfNetRect = new viewer.Core.PDFNet.Rect(
rect.topLeft.x,
rect.topLeft.y + fivePercentHeightOffset,
rect.topLeft.y + percentHeightOffset,
rect.topLeft.x + rect.width,
rect.topLeft.y + rect.height - fivePercentHeightOffset,
rect.topLeft.y + rect.height - percentHeightOffset,
);
const quadWords = await this._extractTextFromRect(viewer, page, pdfNetRect);
words.push(...quadWords);
}
console.log(words.join(' '));
return {
text: words.join(' '),
positions: rectangles,