Annotations are not always under the complete word

Hi,

We are performing a text search of a PDF and then underlining all words that match the search term. In some cases, the annotation is not underlining the word properly, it can be off to the right.

Screenshot 2021-06-15 at 09.30.51

If I double click the word, the blue box seems to match up to the width and position of the text annotation.

Screenshot 2021-06-15 at 09.33.39

Unfortunately I am unable to share the PDF with you.

This is using version 7.3.2. Some searches do underline correctly in the same document.

This is the method we are using to search and perform the text underline:

    private search(searchTerm) {

        const { docViewer, CoreControls, annotManager, Annotations } = this.wvInstance;


        const searchMode = CoreControls.Search.Mode.PAGE_STOP | CoreControls.Search.Mode.HIGHLIGHT;

        const searchOptions = {
            fullSearch: true,
            onResult: async (result) => {
                if (result.resultCode === CoreControls.Search.ResultCode.FOUND) {

                    if (!result.quads.length) {
                        return;
                    }


                    const textQuad = result.quads[0].getPoints();

                    const annot = new Annotations.TextUnderlineAnnotation();

                    annot.StrokeColor = new Annotations.Color(220, 220, 220, 1);

                    annot.Quads = [textQuad];

                    annot.PageNumber = result.pageNum;;

                    annotManager.addAnnotation(annot);

                    annotManager.drawAnnotations(annot.PageNumber);

                }
            }

        }

        docViewer.textSearchInit(searchTerm, searchMode, searchOptions);

    }

Hey there,

This is tough to debug without having access to the document. However, text parsing/positioning issues are usually related to the core PDF.js library, which unfortunately we do not support.

It would be very useful if you could send us a redacted version of that document, or a different document with a similar issue. You can use our free online suite pdf.online to redact the PDF if that works.

Thanks!
Logan

I think I can replicate what looks like the same problem with your Demo viewer pdf.

This shows that the selection of ‘SS’ is not aligned with the PDF.

Same for annotations…

Looking at the PDF.js online viewer with your PDF, we can style the annotation layer as they seem to use HTML - whereas PDFJSExpress seems to use an annotation canvas layer.

From what we can see with PDF.js, it suggests that the different font’s used in the annotation layer have different positioning than the actual PDF. I don’t know if this is helpful, but thought I should mention.

Best, Rich.