Jump to content

Get selected text from UniURLFrame


Isabelle

Recommended Posts

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)?

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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;

 

  • Thanks 1
Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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 !

 

Uniguii.jpg

Link to comment
Share on other sites

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:

Uniguii.jpg

 

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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...

Link to comment
Share on other sites

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

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...