Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't find and highlight text enclosed in brackets #140

Closed
nataliia-obraztsova opened this issue Sep 3, 2024 · 0 comments · Fixed by #144
Closed

Can't find and highlight text enclosed in brackets #140

nataliia-obraztsova opened this issue Sep 3, 2024 · 0 comments · Fixed by #144

Comments

@nataliia-obraztsova
Copy link

nataliia-obraztsova commented Sep 3, 2024

Problem description

Text enclosed in brackets is not highlighted.

Example 1: phrase until brackets is matched
const highlightText = ref('Werkstudentenvertrag zwischen Galt's Gulch GmbH Hauptstrasse 100, 60000 Galt's Gulch')

image

Example 2: phrase including brackets is no longer matched
const highlightText = ref('Werkstudentenvertrag zwischen Galt's Gulch GmbH Hauptstrasse 100, 60000 Galt's Gulch (vertreten durch John Galt)')

image

Example 3: phrase including partial context in brackets is no longer matched and causes Syntax error
const highlightText = ref('Werkstudentenvertrag zwischen Galt's Gulch GmbH Hauptstrasse 100, 60000 Galt's Gulch (vertreten durch')

image

image

Error text
Uncaught (in promise) SyntaxError: Invalid regular expression: /Werkstudentenvertrag zwischen Galt's Gulch GmbH Hauptstrasse 100, 60000 Galt's Gulch (vertreten durch/gi: Unterminated group
at new RegExp ()
at yl (@tato30_vue-pdf.js?v=81477d36:20665:13)
at pl (@tato30_vue-pdf.js?v=81477d36:20750:15)
at m (@tato30_vue-pdf.js?v=81477d36:20775:97)

Expected behavior

Both strings 'Werkstudentenvertrag zwischen Galt's Gulch GmbH Hauptstrasse 100, 60000 Galt's Gulch (vertreten durch John Galt)' and 'Werkstudentenvertrag zwischen Galt's Gulch GmbH Hauptstrasse 100, 60000 Galt's Gulch (vertreten durch' are highlighted.

Additional context

  • vue-pdf: 1.11.0
  • vue: 3
  • pdfjs-dist: 4.6.82

PDF document to test

Extraction_Demo_Vertrag_Darth_Vder Galt.pdf

Code to reproduce

<template>
    <VuePDF class="rounded-md border-2 border-gray-400 border-solid p-1 m-4 flex justify-center"
            :page="props.pageNumber || 1"
            :pdf="pdf" text-layer :highlight-text="highlightText3" :highlight-options="highlightOptions"/>

</template>

<script setup lang="ts">
import { VuePDF, usePDF } from '@tato30/vue-pdf'
import { ref } from 'vue'
import '@tato30/vue-pdf/style.css';
import * as PDFJS from 'pdfjs-dist'
PDFJS.GlobalWorkerOptions.workerSrc = 'https://cdn.jsdelivr.net/npm/pdfjs-dist@4.6.82/build/pdf.worker.min.mjs'

const props = defineProps({
  pdfURL: {type: String, required: true},
  highlightText: {type: String, required: true},
  pageNumber: {type: Number, required: true}
})
const { pdf } = usePDF(props.pdfURL)

const highlightText3 = ref("Werkstudentenvertrag zwischen Galt's Gulch GmbH Hauptstrasse 100, 60000 Galt's Gulch (vertreten durch John Galt)")
const highlightOptions = ref({
  completeWords: false,
  ignoreCase: true,
})
</script>

<style scoped>
</style>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant