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

Need to find all words that have a hyphen and are the last word in a sentence, ie , have a '.'

Community Beginner ,
Nov 26, 2019 Nov 26, 2019

Copy link to clipboard

Copied

Im looking for a way in Adobe Acrobat to highlight all words, of varying length, that contain a hypen and are followed by a period, ie, the last word in a sentence.  Examples may be "con-tinued." or "wood-grain.".  Ideally this would be part of an Adobe Action so users can easily access.  Is this a relatively simple JavaScript?

TOPICS
Acrobat SDK and JavaScript

Views

239

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 ,
Nov 26, 2019 Nov 26, 2019

Copy link to clipboard

Copied

Hi, 

 

See Thom Parker quick guide here on using javascript for text  matching regular expressions:

https://acrobatusers.com/tutorials/text-matching-regular-expressions

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 ,
Nov 26, 2019 Nov 26, 2019

Copy link to clipboard

Copied

> Is this a relatively simple JavaScript?

Not really. For starters, you will need to learn how to read the contents of a PDF file using JS, which involves looping over all the words in it. Let's say you've done that and you were able to write a Regular Expression to identify those words that end with a hyphen (as a hyphen breaks a word into two parts. Also, keep in mind there are multiple types of hyphens and dashes, and that not all the ones you see on the page are actually there, depending on how the file was set up). Now you need to examine the word after this word and see if that one ends with a period (similar to the previous task). If so, you need to learn how to retrieve the quads of those two words, combine them and then add an annotation over both of them.

All of this requires quite a bit of knowledge of the Acrobat JavaScript model and its various objects, methods and properties. If you're doing this for a job I would recommend hiring someone to do it for you. If you're learning how to use Acrobat JS then it's a neat project, but might be a bit much for beginners.

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

LATEST

There is actually an easy way to do this, which is to use the Redaction search. 

Since you have a custom search pattern, you'll need to add your pattern to the ones provided by Adobe. 

Here's an article on the process.

https://blogs.adobe.com/acrolaw/2011/05/creating_and_using_custom_redact/

 

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