Extract link annotation text, change text color

PDF-XChange Editor SDK for Developers

Moderators: TrackerSupp-Daniel, Tracker Support, Vasyl-Tracker Dev Team, Sean - Tracker, Paul - Tracker Supp, Chris - Tracker Supp, Tracker Supp-Stefan, Ivan - Tracker Software

Forum rules
DO NOT post your license/serial key, or your activation code - these forums, and all posts within, are public and we will be forced to immediately deactivate your license.

When experiencing some errors, use the IAUX_Inst::FormatHRESULT method to see their description and include it in your post along with the error code.
Post Reply
zarkogajic
User
Posts: 351
Joined: Thu Sep 05, 2019 12:35 pm

Extract link annotation text, change text color

Post by zarkogajic » Mon Dec 02, 2019 11:57 pm

Hi support,

Say I have a Link annotation on a page. I can get its Rect (where it is on the page).

How do I get the text on the page inside that rect (if there is any, of course)?

Also, how can I change that text color (so in general set text properties inside a rect on a page)?



User avatar
Sasha - Tracker Dev Team
User
Posts: 4522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: Extract link annotation text, change text color

Post by Sasha - Tracker Dev Team » Tue Dec 03, 2019 8:48 am

Hello zarkogajic,

This should help:
viewtopic.php?f=66&t=32582&p=133499&hil ... xt#p133499


Cheers,
Alex
Join us at Google+:
https://plus.google.com/+PDFXChangeEditorTS
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ

zarkogajic
User
Posts: 351
Joined: Thu Sep 05, 2019 12:35 pm

Re: Extract link annotation text, change text color

Post by zarkogajic » Tue Dec 03, 2019 9:21 am

Hi Alex,

ok, will try...

Once I have that text - how to change the color of it?



User avatar
Sasha - Tracker Dev Team
User
Posts: 4522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: Extract link annotation text, change text color

Post by Sasha - Tracker Dev Team » Tue Dec 03, 2019 10:19 am

Hello zarko,

This should do the trick:
https://sdkhelp.tracker-software.com/vi ... _CharColor
You should change the color for every symbol that is inside of your rectangle.

Cheers,
Alex
Join us at Google+:
https://plus.google.com/+PDFXChangeEditorTS
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ

zarkogajic
User
Posts: 351
Joined: Thu Sep 05, 2019 12:35 pm

Re: Extract link annotation text, change text color

Post by zarkogajic » Tue Dec 03, 2019 11:07 am

Hi Alex,

Just to confirm: this is what I'm after - so can you let me know what coding are you internally using to get the text under the link (if more direct than steps below)?

image.png

Steps:

1. GetPage -> aPage
2. aPage ->getText (nil, true, pageText)
3. pageText -> GetLinesCount (lineCount)
4. for each line
4.1. getLineInfo (PXC_TextLineInfo tti)
5. Get line text using pageText.getChars(tti.FirstCharIndex, tti.charcount)

I would then need to get the CharRect of every char and "build" up the rectangle - and finally if the rectangle is inside annotation's rectangle - this is the text I'm after?

Is this what you are suggesting? No other method like ExtractPageText(fromGivenRectange)?

If so, can you please help with using HitTest of IPXC_PageText - as I think I should be able to locate the lineIndex directly by this and not need to iterate over all lines - however whatever I use for stPosOnPage point (and I've tried using annots rect corners) - the result is never the line index where the annotation is.

-žarko

zarkogajic
User
Posts: 351
Joined: Thu Sep 05, 2019 12:35 pm

Re: Extract link annotation text, change text color

Post by zarkogajic » Thu Dec 05, 2019 2:08 pm

Hi Alex,

I do not see how to change the color of a character. I can use Get_CharColor to get an IColor. I can even do IColor.SetRGB() - but this does not apply it to the character.

So, how to do it? And also when done, if there's a corresponding pxv document, do I need to send some notification or fire some event, or?


Post Reply