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

Cross-line text cannot be highlighted. #170

Open
devyujie opened this issue Jan 16, 2025 · 6 comments
Open

Cross-line text cannot be highlighted. #170

devyujie opened this issue Jan 16, 2025 · 6 comments

Comments

@devyujie
Copy link

Additional context

  • vue-pdf: [1.11.3]
  • vue: [3.5.12]

Hello, I need some help.
when I deal with pdf containing Chinese, some text is displayed across the lines, this cross-line text can not be highlighted!

image
image

Test text:
['「清晰」', '效率的提升','不确定', '明确信息层级导向', '产品操', '品牌信赖感品牌的一致性是务']

Test pdf:
test_new.pdf

@vordimous
Copy link
Collaborator

HI @devyujie,

vue-pdf is a wrapper around the mozilla PDF.js project. Can you try rendering your pdf in plain js to see if it is an issue with it there? Mozilla has some examples with js fiddles that you can use: https://mozilla.github.io/pdf.js/examples/

@devyujie
Copy link
Author

devyujie commented Jan 20, 2025

HI @devyujie,  你好,

vue-pdf is a wrapper around the mozilla PDF.js project. Can you try rendering your pdf in plain js to see if it is an issue with it there? Mozilla has some examples with js fiddles that you can use: https://mozilla.github.io/pdf.js/examples/vue-pdf

Thanks. Can this library call iframe.contentWindow.PDFViewerApplication.findBar api?
My idea was to call the pdfjs findbar

@vordimous
Copy link
Collaborator

Can this library call iframe.contentWindow.PDFViewerApplication.findBar API?

vue-pdf doesn't use the PDFViewerApplication to render the PDF. @TaTo30 please correct me if I am wrong. So the findBar API is not available.

In the sample you provided, are you using the highlight-text property?

@TaTo30
Copy link
Owner

TaTo30 commented Jan 20, 2025

PDFViewerApplication is an API used specifically by Mozilla Viewer and is not available in pdfjs-dist: mozilla/pdf.js#9210

The problem highlighting this text: ''明确信息层级导向" is that pdf.js does not include the last char ("向") as part of the first line but does it in the second line:

Image

We had a similar issue with latin alphabet: #125 but in that case was easy to determine when a word is being "broken" looking for hyphen symbol at the end of line. How is determined in chinese that a word or phrase is being broken?

@devyujie
Copy link
Author

PDFViewerApplication is an API used specifically by Mozilla Viewer and is not available in pdfjs-dist: mozilla/pdf.js#9210

The problem highlighting this text: ''明确信息层级导向" is that pdf.js does not include the last char ("向") as part of the first line but does it in the second line:

Image

We had a similar issue with latin alphabet: #125 but in that case was easy to determine when a word is being "broken" looking for hyphen symbol at the end of line. How is determined in chinese that a word or phrase is being broken?

Chinese line breaks do not seem to have any sign ... Then I tried another program, the use of pdfjs findbar, can be achieved by highlighting multiple keywords, but there is a new problem, there are multiple keywords to be highlighted in a line, only one of them can be highlighted.

@devyujie
Copy link
Author

Can this library call iframe.contentWindow.PDFViewerApplication.findBar API?

vue-pdf doesn't use the PDFViewerApplication to render the PDF. @TaTo30 please correct me if I am wrong. So the findBar API is not available.

In the sample you provided, are you using the highlight-text property?

I used the highlight-text property

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

No branches or pull requests

3 participants