Copy link to clipboard
Copied
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.
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
...Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
I'm trying to find the selected text in the content tree
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
Okay, that helps a lot. I'll give it a try.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now