Skip to main content
Boris56
Known Participant
November 28, 2019
Answered

How to change text color in Acrobat DC SDK

  • November 28, 2019
  • 2 replies
  • 3766 views

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 has been closed for replies.
Correct answer Bernd Alheit

Which method divides text into text runs?


PDETextSplitRunAt

2 replies

Legend
December 3, 2019

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.

Boris56
Boris56Author
Known Participant
December 3, 2019

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

Thom Parker
Community Expert
Community Expert
December 3, 2019

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

Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often
Boris56
Boris56Author
Known Participant
December 2, 2019

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?

Bernd Alheit
Community Expert
Community Expert
December 2, 2019

Where does you change the color of the text?

Boris56
Boris56Author
Known Participant
December 2, 2019

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