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

How to make every other word in red?

New Here ,
Sep 03, 2021 Sep 03, 2021

I have a document in Adobe reader but I needed a way to change the colour of every other word automatically. Any help is appreciated. Thanks in advance.

 

[Spelling mistake corrected for clarity]

TOPICS
Acrobat SDK and JavaScript , Windows
796
Translate
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 ,
Sep 03, 2021 Sep 03, 2021

Not possible with Acrobat Reader.

Translate
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
New Here ,
Sep 04, 2021 Sep 04, 2021

What about in Acrobat DC?

Translate
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 ,
Sep 04, 2021 Sep 04, 2021

Are you wanting to make a program to edit the colour of text on a page? Are you an experienced C++ programmer with Visual Studio installed?

Translate
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
New Here ,
Sep 04, 2021 Sep 04, 2021

No I am not skilled in any of those. I was hoping I could use some sort of script to change every other word in a sentence to the colour red.

Translate
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 ,
Sep 04, 2021 Sep 04, 2021

Unless this text is a part of a form field or comment it's impossible to do it with a script.

Translate
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
New Here ,
Sep 04, 2021 Sep 04, 2021

Oh alright. I was hoping that it was possible with the JavaScript function because I've used it before to delete every other page in a document. What I wanted was so that it selects every nth word (in my case every second word) and changes the colour to red.

Translate
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 ,
Sep 04, 2021 Sep 04, 2021

No, JS has no access to the properties of the static text on a PDF. It can only read its contents and location. The latter can be used to delete it using Redaction. However, it's also possible to use both of these things to "re-create" text, by placing a field or a comment over it with the desired formatting settings (such as red text).

This has a couple of limitations, though: The script can't know what font was originally used for the text, so you have to hard-code a specific font selection into it. It also can't know what's the color of the text itself (not a problem in this case, since you want to replace it with red text anyway), nor the background color on which it is placed. So if the text is not placed on top of a white background, and you don't hard-code the proper color into the script, the result will appear very odd.

The font size can be estimated based on the size of the area the text takes on the page, but it won't be 100% accurate, either.

 

If all of these issues are OK with you, or can be easily solved in your case (if the font, color, background color and text size are the same throughout the document), then yes, it can be done using a script, but it's quite a complicated task that will require the development of a custom-made tool.

 

Feel free to contact me privately via [try6767 at gmail.com] to discuss it further if you're interested in hiring a professional to create such a script for you.

Translate
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 ,
Sep 04, 2021 Sep 04, 2021
LATEST

Actually, I've use the redact annotation to replace text on the page. You can set the text that is dispalyed in the area where the redaction happens with a property on the annotation. For a word size area this would amount to a replacment. I don't know if the font properties can be set.  

 

However, actually replacing half the text on a page might have some negative consequences.  I wouldn't recomend it. 

 

An easy alternative would be to place highlight annotations over every word. 

 

 

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

Translate
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