Isabelle Posted September 10, 2022 Share Posted September 10, 2022 Hi, I'm using Unigui for the first time and I find it great. In UniURLFrame a PDF file is displayed. I want to copy selected text with mouse to a UniEdit. Is it possible to do this? Thanks for your help. Quote Link to comment Share on other sites More sharing options...
Sherzod Posted September 10, 2022 Share Posted September 10, 2022 Hello, Thank you for your interest in uniGUI. 58 minutes ago, Isabelle said: In UniURLFrame a PDF file is displayed. I want to copy selected text with mouse to a UniEdit. Is it possible to do this? For what purpose? And if it is copy-protected (although I'm not sure)? Quote Link to comment Share on other sites More sharing options...
Isabelle Posted September 10, 2022 Author Share Posted September 10, 2022 Hi Sherzod, Thank you for reply. I want to copy the word selected with the mouse (after releasing the left mouse button) into a UniEdit. It's like you select a word with the mouse, then you do Ctrl + C and then you do Ctrl + V. its like : http://forums.unigui.com/index.php?/topic/6116-copy-paste-selected-text-in-tunimemo/ I want to get several words from the UniURLFrame and paste them directly to UniEdits Thank you Quote Link to comment Share on other sites More sharing options...
Sherzod Posted September 10, 2022 Share Posted September 10, 2022 Also try this approach: procedure TMainForm.UniPDFFrame1FrameLoaded(Sender: TObject); begin UniPDFFrame1.JSInterface.JSCode(#1'.getDoc().addEventListener("mouseup", function(){if ('#1'.getDoc().getSelection()){' + UniEdit1.JSName + '.setValue('#1'.getDoc().getSelection().getRangeAt(0).toString())}});') end; 1 Quote Link to comment Share on other sites More sharing options...
Isabelle Posted September 10, 2022 Author Share Posted September 10, 2022 Error : Permission Denied to access property "document" on cross-origin object : O25.getDoc().addEventListener("mouseup", function(){if (O25.getDoc().getSelection()){O70.setValue(O25.getDoc().getSelection().getRangeAt(0).toString())}}); Quote Link to comment Share on other sites More sharing options...
Isabelle Posted September 10, 2022 Author Share Posted September 10, 2022 it works fine, thank you ! But, when I launch the application I get this error: Permission Denied to access property "document" on cross-origin object : O25.getDoc().addEventListener("mouseup", function(){if (O25.getDoc().getSelection()){O70.setValue(O25.getDoc().getSelection().getRangeAt(0).toString())}}); Is it possible to do this with several UniEdit: I have 10 UniEdit. I want to copy 10 words in each UniEdit please ? Thank you Quote Link to comment Share on other sites More sharing options...
Sherzod Posted September 10, 2022 Share Posted September 10, 2022 19 minutes ago, Isabelle said: Is it possible to do this with several UniEdit: I have 10 UniEdit. I want to copy 10 words in each UniEdit please ? Please explain in more details. Quote Link to comment Share on other sites More sharing options...
Isabelle Posted September 10, 2022 Author Share Posted September 10, 2022 in the Form, I added 10 UniEdit (UniEdit1, UniEdit2, UniEdit3,... UniEdit10). I select 10 words with the mouse and each word must be copied into a UniEdit: example: - I select the first word, then it will be copied into UniEdit1. - I select the second word, then it will be copied into UniEdit2. - I select the third word, then it will be copied into UniEdit3. ... - I select the tenth word, then it will be copied into UniEdit10. thanks Quote Link to comment Share on other sites More sharing options...
Sherzod Posted September 10, 2022 Share Posted September 10, 2022 3 minutes ago, Isabelle said: I select 10 words with the mouse and each word must be copied into a UniEdit: example: ... Are you selecting the text at one time? Quote Link to comment Share on other sites More sharing options...
Isabelle Posted September 10, 2022 Author Share Posted September 10, 2022 no, one by one Quote Link to comment Share on other sites More sharing options...
Sherzod Posted September 10, 2022 Share Posted September 10, 2022 34 minutes ago, Isabelle said: no, one by one Okay, then you need to modify the code above to send the selected text to the server (using ajaxRequest), and there you will think about the logic. Quote Link to comment Share on other sites More sharing options...
Isabelle Posted September 10, 2022 Author Share Posted September 10, 2022 Ok, I don't know how to do this (using ajaxRequest). Is it possible to set text selection area in UniPDFFrame? As is shown in the attached picture. Framed areas are not fixed (areas of selected text can be anywhere in the PDF). I know you have to define the text retrieval areas, with Unigui, I don't know how to do it, but under VCL yes, I have already done it. Thank you for your help Sherzod ! Quote Link to comment Share on other sites More sharing options...
Sherzod Posted September 10, 2022 Share Posted September 10, 2022 Sorry, are you using trial edition? Which build? Quote Link to comment Share on other sites More sharing options...
Sherzod Posted September 10, 2022 Share Posted September 10, 2022 5 minutes ago, Isabelle said: but under VCL yes, I have already done it. How? Quote Link to comment Share on other sites More sharing options...
Isabelle Posted September 10, 2022 Author Share Posted September 10, 2022 I use the latest version (trial). 30 minutes ago, Sherzod said: How? It is possible to do it ? Quote Link to comment Share on other sites More sharing options...
Sherzod Posted September 10, 2022 Share Posted September 10, 2022 3 minutes ago, Isabelle said: procedure TFNDocument.PdfMouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); begin if Selecting then begin Selecting := False; if (SelectionStart >= 0) and (SelectionEnd >= 0) then begin if SelectionEnd < SelectionStart then Text := Pdf.Text(SelectionEnd, SelectionStart - SelectionEnd + 1) else Text := Pdf.Text(SelectionStart, SelectionEnd - SelectionStart + 1); Clipboard.AsText := Text; Seems there is no code of what you asked above: 23 minutes ago, Isabelle said: Quote Link to comment Share on other sites More sharing options...
Isabelle Posted September 10, 2022 Author Share Posted September 10, 2022 ok. Before getting text, you have to define the selection areas with a Shape (as in the picture). After that, I have the coordinates of the Shape (Top, Height, width and left), and finally i can get the selected text (which is framed by the Shape): Edit8.Text := coordonates It is possible to do it with Unigui ? Thank you Quote Link to comment Share on other sites More sharing options...
Sherzod Posted September 10, 2022 Share Posted September 10, 2022 I do not promise that I can do something, but in any case, could you make a testcase (maybe an exe) on VCL to understand your case completely? Quote Link to comment Share on other sites More sharing options...
Isabelle Posted September 10, 2022 Author Share Posted September 10, 2022 Hi, what I want is explained in the attached photo. The colored frames are TShape (in VCL). Text copied into TEdit is based on: Top, Left, Widht, Height of a TShape. TShape areas are user defined. Thank Sherzod 🙂 Quote Link to comment Share on other sites More sharing options...
Sherzod Posted September 11, 2022 Share Posted September 11, 2022 Hello, Sorry, I don't think this is possible with pdfviewer... Quote Link to comment Share on other sites More sharing options...
Isabelle Posted September 11, 2022 Author Share Posted September 11, 2022 13 hours ago, Sherzod said: Hello, Sorry, I don't think this is possible with pdfviewer... Hi Sherzod, Thank you. Yes, I know it's not possible with PDFView: I tested it before asking my question on this forum. PDfView is incompatible with Unigui (for VCL and FMX usage). My question was is it possible to do the same with Unigui? In my opinion, yes, it can be done with JavaScript, but how? The trick is to have : get X,Y co-ordinates of the selected Text area from PDF. Thank you. Quote Link to comment Share on other sites More sharing options...
Sherzod Posted September 11, 2022 Share Posted September 11, 2022 Hi, I don't think there is an easy solution, if you can access the content of the pdf then maybe using styles. Because if you use UniHTMLMemo, then yes there you can use styles to do this. Quote Link to comment Share on other sites More sharing options...
Isabelle Posted September 11, 2022 Author Share Posted September 11, 2022 Can a PDF file be displayed in the "UniHTMLMemo" component? Is it possible to have coordinates of selected text in UniPdfFrame? thank you Quote Link to comment Share on other sites More sharing options...
Sherzod Posted September 12, 2022 Share Posted September 12, 2022 11 hours ago, Isabelle said: Can a PDF file be displayed in the "UniHTMLMemo" component? No... 12 hours ago, Sherzod said: Because if you use UniHTMLMemo, then yes there you can use styles to do this. Sorry, I didn't mean to display pdf in UniHTMLMemo. 11 hours ago, Isabelle said: Is it possible to have coordinates of selected text in UniPdfFrame? What will it give you? Keep in mind that there is still the possibility of scaling, scrolling... Quote Link to comment Share on other sites More sharing options...
Isabelle Posted September 12, 2022 Author Share Posted September 12, 2022 Hi Sherzod, Thank you. yes, I take into account the scaling (zoom). Suppose the PDF file is scaled to 100%. We need to have the coordinates of the text capture areas (Top, Height, Left, Widht). I thought of putting a UniPanel (on the text to have) UniPDFFrame to have its coordinates. What do you think of that? Thank you Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.