• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

How to change text color in Acrobat DC SDK

Explorer ,
Nov 28, 2019 Nov 28, 2019

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.

TOPICS
Acrobat SDK and JavaScript

Views

2.6K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 2 Correct answers

LEGEND , Dec 03, 2019 Dec 03, 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.

Votes

Translate

Translate
Community Expert , Dec 04, 2019 Dec 04, 2019

PDETextSplitRunAt

Votes

Translate

Translate
Explorer ,
Dec 02, 2019 Dec 02, 2019

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?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 02, 2019 Dec 02, 2019

Copy link to clipboard

Copied

Where does you change the color of the text?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Dec 02, 2019 Dec 02, 2019

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"))

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 02, 2019 Dec 02, 2019

Copy link to clipboard

Copied

May be that you must create or change the graphic state.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Dec 03, 2019 Dec 03, 2019

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Dec 03, 2019 Dec 03, 2019

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 03, 2019 Dec 03, 2019

Copy link to clipboard

Copied

You will get the graphic state with::
PDEElementGetGState - Gets the graphics state information for an element.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Dec 03, 2019 Dec 03, 2019

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Dec 03, 2019 Dec 03, 2019

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 03, 2019 Dec 03, 2019

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.

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Dec 04, 2019 Dec 04, 2019

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 04, 2019 Dec 04, 2019

Copy link to clipboard

Copied

May be that you must split the text into several text runs.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Dec 04, 2019 Dec 04, 2019

Copy link to clipboard

Copied

Which method divides text into text runs?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 04, 2019 Dec 04, 2019

Copy link to clipboard

Copied

PDETextSplitRunAt

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Dec 07, 2019 Dec 07, 2019

Copy link to clipboard

Copied

LATEST

Thank you very much for your reply. It helped me. Everything has worked out.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines