Copy link to clipboard
Copied
Hi,
I select text using the PDTextSelectCreateWordHilite method. I need to change the color of the text characters. How to do it.
Thanks.
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.
PDETextSplitRunAt
Copy link to clipboard
Copied
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?
Copy link to clipboard
Copied
Where does you change the color of the text?
Copy link to clipboard
Copied
I want to change the color of the text in the selected fragment of the PDF document. For this fragment
AVDocGetSelectionType (avDoc) == ASAtomFromString ("Text"))
Copy link to clipboard
Copied
May be that you must create or change the graphic state.
Copy link to clipboard
Copied
Perhaps, but which parameter is responsible for the graphic state. In the PDTextSelectEnumTextProc method, I did not find such a parameter.
Copy link to clipboard
Copied
Dear colleagues, maybe someone knows how to change the color of the text and at the same time the text itself. What method should be used for this. In the examples that I have, these questions are not considered.
Copy link to clipboard
Copied
You will get the graphic state with::
PDEElementGetGState - Gets the graphics state information for an element.
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
Thank you very much. Now there is where to dig.
Copy link to clipboard
Copied
If you want to change the color, or any other content stream parameters, you have to rebuild the content stream.
Copy link to clipboard
Copied
In the SnippetRunner project, I found the TextChangeColourSnip.cpp module, which changes the text color of the first page of a pdf document. Text replacement occurs for each
text run. It doesn't suit me. I need to replace the color of certain characters. I know the offset of the first character from the top of the page and the number of characters. In the PDETextGetGState method, one of the parameters is PDETextFlags that specifies whether index refers to the character offset from the beginning of the text object or the index of the text run in the text object. I set it to kPDETextChar. PDETextRunSetGState statement (textObject, t, & stateOfRun, sizeof (stateOfRun)); set the text run to the new graphic state. I need to set a similar operator for a character, not for text run. In the Acrobat API, I did not find the method I needed. Please help how to solve this problem. Thanks.
Copy link to clipboard
Copied
May be that you must split the text into several text runs.
Copy link to clipboard
Copied
Which method divides text into text runs?
Copy link to clipboard
Copied
PDETextSplitRunAt
Copy link to clipboard
Copied
Thank you very much for your reply. It helped me. Everything has worked out.