Skip to main content
Boris56
Known Participant
Nov 28, 2019 9:43 AM UTC
Answered

How to change text color in Acrobat DC SDK

Hi,

I select text using the PDTextSelectCreateWordHilite method. I need to change the color of the text characters. How to do it.

Thanks.

This topic is closed to new replies. Start a new post to keep the conversation going.
Bernd Alheit
Bernd AlheitCorrect answer
Community Expert
Dec 4, 2019 2:58 PM UTC

Which method divides text into text runs?


PDETextSplitRunAt

15 replies

Legend
Dec 3, 2019 12:22 PM UTC

Just because colour is passed to your Enum proc, does not mean that changing your parameters changes the colour. This is a read only method. To edit page contents use PDFEdit methods. Tip 1: PDFEdit use needs a detailed understanding of the PDF graphics and text model. Tip 2: there is no mapping from text selection to PDFEdit objects, you have to reselect the objects based on their geometry. Tip 3: This is much more work than anyone wants it to be.

Translate
Boris56
Boris56Author
Known Participant
Dec 3, 2019 3:06 PM UTC

Thank you very much. Now there is where to dig.

Translate
Thom Parker
Community Expert
Community Expert
Dec 3, 2019 6:06 PM UTC

If you want to change the color, or any other content stream parameters, you have to rebuild the content stream.

Translate
Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often
Boris56
Boris56Author
Known Participant
Dec 2, 2019 1:33 PM UTC

I found that the color of the text can be changed in the Callback PDTextSelectEnumTextProc. I have done the following:

color->space = PDDeviceRGB;
color->value[0] = 0;
color->value[1] = 0;
color->value[2] = 255;

However, the color of the characters does not change. Where am I wrong?

Translate
Bernd Alheit
Community Expert
Community Expert
Dec 2, 2019 3:11 PM UTC

Where does you change the color of the text?

Translate
Boris56
Boris56Author
Known Participant
Dec 2, 2019 3:24 PM UTC

I want to change the color of the text in the selected fragment of the PDF document. For this fragment
  AVDocGetSelectionType (avDoc) == ASAtomFromString ("Text"))

Translate