Is it possible to realize the box selection function in the PDF viewer, and make the text selected by the box consistent with the data of the text selected by ordinary click and drag (even though it may not be possible immediately, but could you give me an idea)? #17897
Unanswered
ouleioulei
asked this question in
Q&A
Replies: 2 comments
-
Remark: |
Beta Was this translation helpful? Give feedback.
0 replies
-
What I expect is that after selecting text in the two interactive methods, the character content and order obtained by executing window.getSelection().toString() will be the same, not just the data in my example. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Attach (recommended) or Link to PDF file here(In fact, any PDF file is the same):
test.PDF
Configuration:
Internet browser and its version:
Chromium Browser, version 120.0.6074.0 (developer build) (64-bit)
Operating system and its version:
Windows 10 Pro
PDF.js version:
I don’t know which version it is, but it is the pdf.js-master downloaded on October 23, 2023.
is a browser extension:
no
Steps to reproduce the problem(It can't be considered a problem, it just means that the viewer now looks like this):
![紧贴](https://private-user-images.githubusercontent.com/34880715/319186851-64e81ce4-edc8-4945-91f5-86d59b988270.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzk5MTMxNDgsIm5iZiI6MTczOTkxMjg0OCwicGF0aCI6Ii8zNDg4MDcxNS8zMTkxODY4NTEtNjRlODFjZTQtZWRjOC00OTQ1LTkxZjUtODZkNTliOTg4MjcwLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMTglMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjE4VDIxMDcyOFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTU2ZDhlYWZhN2VjZjUzMzc2M2JhOWQxNThiYzliOTY4NGJhMTk3MDUwMTQxNTNiNGUzMzk5NzFmNTYxYTcxZWYmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.fmmnvcVNt_Gpzlq6y1CQ7hBDNgKkRoMMA1rPEi55RU4)
1.Run viewer.html (pdf.js-master\web\viewer.html), or: https://mozilla.github.io/pdf.js/web/viewer.html
2.Open the pdf I uploaded
3.Close text selection (this selection method is actually the only way I currently know to select text interactively in the PDF viewer) as shown below:
4.Enter: window.getSelection().toString() in the browser console, if prompted "Warning: Don't paste code into the DevTools Console that you don't understand or haven't reviewed yourself. This could allow attackers to steal your identity or take control of your computer. Please type 'allow pasting' below and hit Enter to allow pasting.", then just do as required. After actually executing window.getSelection().toString(), you can get the selected text It will automatically be arranged in order: '1.10 +0.1\n0'
What is the expected behavior? (This is actually the effect I want to create)
![框选](https://private-user-images.githubusercontent.com/34880715/319190132-aafe1294-4632-4096-89f8-6d0d01d7d0f4.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzk5MTMxNDgsIm5iZiI6MTczOTkxMjg0OCwicGF0aCI6Ii8zNDg4MDcxNS8zMTkxOTAxMzItYWFmZTEyOTQtNDYzMi00MDk2LTg5ZjgtNmQwZDAxZDdkMGY0LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMTglMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjE4VDIxMDcyOFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTYzMzRlMTAxYTcwNGQ2NzJlMWM0NGRhOGYwNWM2MmIwNmEyNDQ0MTI5Y2ZhMmZiMDEzMzM1N2I2MjNkYTUxMjkmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.gKGz8AK32lP_qJK_WrkRZeXe3ihrCpKa4_55gsAHR-I)
I now plan to use box selection to realize text selection. The picture below is the effect I currently use Foxit PDF Reader, and the window.getSelection().toString() I expected still gets '1.10 +0.1\ n0' (that is, the character content and order of the result data remain unchanged after changing the interactive form), and it must be theoretically feasible.
What went wrong?
No wrong, I just wanted to add new functionality.
Link to a viewer :
https://mozilla.github.io/pdf.js/web/viewer.html
Beta Was this translation helpful? Give feedback.
All reactions