Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Translate a PDTextSelect variable to a PDEElement

Community Beginner ,
Jun 30, 2016 Jun 30, 2016

I'm working with a PDTextSelect variable in order to get user selected text. Is there any way to then turn this PDTextSelect varible into a PDEElement? I have tried a couple of thing so far including reinterpret_cast<PDEElement> but nothing has worked.

TOPICS
Acrobat SDK and JavaScript
664
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

LEGEND , Jun 30, 2016 Jun 30, 2016

There is no direct conversion. They are entirely different kinds of representation. The order of text and characters may not even be the same. Once you have the coordinates of a PDTextSelect you can iterate the PDEText elements to find the elements (not necessarily consecutive) which overlap in the coordinates. The selection is likely to be only a portion of a PDETextRun. This is complicated stuff (albeit important and an obvious need). Text editing is a very complex task and generally works ent

...
Translate
LEGEND ,
Jun 30, 2016 Jun 30, 2016

There is no direct conversion. They are entirely different kinds of representation. The order of text and characters may not even be the same. Once you have the coordinates of a PDTextSelect you can iterate the PDEText elements to find the elements (not necessarily consecutive) which overlap in the coordinates. The selection is likely to be only a portion of a PDETextRun. This is complicated stuff (albeit important and an obvious need). Text editing is a very complex task and generally works entirely in the PDF edit layer, implementing its own selection logic.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Employee ,
Jun 30, 2016 Jun 30, 2016

As TSN says, this is not a trivial piece. What do you need the PDEElement for? Perhaps there are other structures that are easier to work with from the PDTextSelect that you could use instead.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jun 30, 2016 Jun 30, 2016

I'm trying to find the selected text in the content tree

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Employee ,
Jun 30, 2016 Jun 30, 2016

Then you basically need to do what TSN described.

Walk the contents (PDEElements) and compare the bounding boxes to find those inside the selection rectangle.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jul 01, 2016 Jul 01, 2016
LATEST

Okay, that helps a lot. I'll give it a try.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines