Hi Support,
This topic is related to the question raised in the EU Forum: https://forum.pdf-xchange.com/viewtopic.php?f=62&t=36805
Is there any way, never mind how complex, to do the following *from code*:
1. Activate Edit Content mode
2. Find / "select" a word (/some text) inside a content item text block
3. Change the Fill Color to selected color
-žarko
Programmatically change text color for find/search results SOLVED
Moderators: TrackerSupp-Daniel, Tracker Support, Paul - Tracker Supp, Vasyl-Tracker Dev Team, Chris - Tracker Supp, Sean - Tracker, Ivan - Tracker Software, Tracker Supp-Stefan
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.
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.
-
- User
- Posts: 1371
- Joined: Thu Sep 05, 2019 12:35 pm
- Vasyl-Tracker Dev Team
- Site Admin
- Posts: 2353
- Joined: Thu Jun 30, 2005 4:11 pm
- Location: Canada
Re: Programmatically change text color for find/search results
Hi Zarko.
Unfortunately it might be too complex... Hypothetical way:
Note: its better to enumerate text blocks in reversed order because after each change you might have a new set of text blocks...
Cheers.
Unfortunately it might be too complex... Hypothetical way:
Code: Select all
text = page.GetText();
for (int i = (text.BlocksCount - 1); i >= 0; i--)
{
doc.StartEditPageText(i);
te = doc.ActiveTextEditor;
if (te == null)
break;
e = te.EditCtl;
e.GetRichText(UIX_RichText_RTF, stream, UIX_GetRichText_All);
ReplaceTextColorsInRTF(stream) ;
e.SetRichText(stream);
e = null;
te = nullptr;
doc.ApplyCachedChanges(); // stop text editor and apply changes to this text block
}
Cheers.
Vasyl Yaremyn
Tracker Software Products
Project Developer
Please archive any files posted to a ZIP, 7z or RAR file or they will be removed and not posted.
Tracker Software Products
Project Developer
Please archive any files posted to a ZIP, 7z or RAR file or they will be removed and not posted.
-
- User
- Posts: 1371
- Joined: Thu Sep 05, 2019 12:35 pm
Re: Programmatically change text color for find/search results
HI Vasyl,
Thank for a push in the needed direction
p.s.
I actually need something like that on the Core level (change font color "on" a rectangle on page). I know (/guess) something like this is not implemented in Core stuff?
-žarko
Thank for a push in the needed direction
p.s.
I actually need something like that on the Core level (change font color "on" a rectangle on page). I know (/guess) something like this is not implemented in Core stuff?
-žarko
- Vasyl-Tracker Dev Team
- Site Admin
- Posts: 2353
- Joined: Thu Jun 30, 2005 4:11 pm
- Location: Canada
Re: Programmatically change text color for find/search results
Hi Zarko.
Unfortunately, but text in pdf - it is not normal text. In common case - it is just bunch of special text-items that might be positioned and ordered absolutely chaotically in pdf content BUT you may still see all of them as normal and readable text. For example, often pdf-creators firstly add the main text to the page and then add text of header and footer. As result, in pdf-content we may see: text-items for main text firstly and after it - text-items of header and footer. So, in summary, order of text items on the page will be incorrect, because header's text items are AFTER main text-items while visibly are above that text. This is very simple example, not the worst case. In editor we trying to compose the 'normal' text from the potential mess of the text-items (IPXC_Page::GetText). And this composed text is read-only on the core-level. You may change it only via UI-TextEditor feature in Editor-level of API.
From other side - you may try to work with content-items directly (page.GetContent()). But in this case you will be stuck with your task because each text-item - it isn't a single word exactly but might be any piece of text: whole line of text, one word, half of word, one symbol etc. And in the case when you need to change color just for one word but corresponding text-item also contains other words - you need special functionality to split the text-item to certain pieces (new smaller text-items). But currently we haven't published this API for devs..
Cheers.
Unfortunately, but text in pdf - it is not normal text. In common case - it is just bunch of special text-items that might be positioned and ordered absolutely chaotically in pdf content BUT you may still see all of them as normal and readable text. For example, often pdf-creators firstly add the main text to the page and then add text of header and footer. As result, in pdf-content we may see: text-items for main text firstly and after it - text-items of header and footer. So, in summary, order of text items on the page will be incorrect, because header's text items are AFTER main text-items while visibly are above that text. This is very simple example, not the worst case. In editor we trying to compose the 'normal' text from the potential mess of the text-items (IPXC_Page::GetText). And this composed text is read-only on the core-level. You may change it only via UI-TextEditor feature in Editor-level of API.
From other side - you may try to work with content-items directly (page.GetContent()). But in this case you will be stuck with your task because each text-item - it isn't a single word exactly but might be any piece of text: whole line of text, one word, half of word, one symbol etc. And in the case when you need to change color just for one word but corresponding text-item also contains other words - you need special functionality to split the text-item to certain pieces (new smaller text-items). But currently we haven't published this API for devs..
Cheers.
Vasyl Yaremyn
Tracker Software Products
Project Developer
Please archive any files posted to a ZIP, 7z or RAR file or they will be removed and not posted.
Tracker Software Products
Project Developer
Please archive any files posted to a ZIP, 7z or RAR file or they will be removed and not posted.
-
- User
- Posts: 1371
- Joined: Thu Sep 05, 2019 12:35 pm
Re: Programmatically change text color for find/search results
Hi Vasly,
Thanks - all you said is clear
What I'm really trying to do is to change the color of text "behind" the Link type annotation.
I know there's no Text associated with the Link type annotation - but with some coding it can be extracted from the page. Same as what you do in the Links pane.
People love to have unified link appearance. It is easy to make all links have the same border color/style etc. What's not easy (actually not possible for the moment) is to change the color (or font) of the text (if there is one) behind the link.
It would be awesome if you could build this into SDK (/EU Editor)
I know I'm kind of asking too much - but I am certain EU Editor users would benefit from such a feature (at least those working with links).
p.s.
I have already asked for this here https://forum.pdf-xchange.com/viewtopic.php?f=66&t=33540 and I know it is either not possible from code or far too complex at the moment.
-žarko
Thanks - all you said is clear
What I'm really trying to do is to change the color of text "behind" the Link type annotation.
I know there's no Text associated with the Link type annotation - but with some coding it can be extracted from the page. Same as what you do in the Links pane.
People love to have unified link appearance. It is easy to make all links have the same border color/style etc. What's not easy (actually not possible for the moment) is to change the color (or font) of the text (if there is one) behind the link.
It would be awesome if you could build this into SDK (/EU Editor)
I know I'm kind of asking too much - but I am certain EU Editor users would benefit from such a feature (at least those working with links).
p.s.
I have already asked for this here https://forum.pdf-xchange.com/viewtopic.php?f=66&t=33540 and I know it is either not possible from code or far too complex at the moment.
-žarko
- Vasyl-Tracker Dev Team
- Site Admin
- Posts: 2353
- Joined: Thu Jun 30, 2005 4:11 pm
- Location: Canada
Re: Programmatically change text color for find/search results SOLVED
Agree with you, it might be useful in many scenarios to have possibility to split existing text-items. We will add it in the near future...It would be awesome if you could build this into SDK (/EU Editor)
Vasyl Yaremyn
Tracker Software Products
Project Developer
Please archive any files posted to a ZIP, 7z or RAR file or they will be removed and not posted.
Tracker Software Products
Project Developer
Please archive any files posted to a ZIP, 7z or RAR file or they will be removed and not posted.