Copy link to clipboard
Copied
I want to create a script that would copy any selected text in a PDF and convert the copied to proper case onto the clipboard.
THIS IS UPPERCASE
1. Select the above phrase
2. Click the custom script button
3. The system copies a Proper Case version of the selected text to the clipboard.
Ideas?
Thanks!
Copy link to clipboard
Copied
The Acrobat JavaScript model does not provide direct access to the selected text or the clipboard. However, an indirect/partial solution would be a script that runs the Copy menu item.
app.execMenuItem("Copy", this);
It's a partial solution because the context of the copy is not guarenteed to be the selected text.
I also think this might require a privileged context.
https://www.pdfscripting.com/public/Trust-and-Privilege-in-Acrobat-Scripts.cfm
Copy link to clipboard
Copied
Copy link to clipboard
Copied
It is what it is. Did I mention that the Acrobat JavaScript model does not provide direct access to the selected text or the clipboard.
That said, the case alway comes through for me.
What happens when you copy and paste text manually? Does the case copy as well? If not then this is an issue with your operating system, not Acrobat. Acrobat is just pushing text data out to the system. The system decides what to paste.
Copy link to clipboard
Copied
Sure, if you can define "proper" case (which would not normally be "Proper Case" for English) then JavaScript can do it. HOWEVER, you can't put it back on the page to copy. Better to process it with an external app once it's on the clipboard.
Copy link to clipboard
Copied
Sorry, I see you use "Proper Case" as a technical term from Visual Basic. Not sure what makes it proper. But at least it's much easier to do than camelCase.
Copy link to clipboard
Copied
You can use this function to convert a string to this "proper" case (I know it as Title Case):
function toTitleCase(s) {
var words = s.split(" ");
for (var i in words)
words[i] = words[i].charAt(0).toUpperCase() + words[i].substr(1).toLowerCase();
return words.join(" ");
}
Note that the above can yield strange results. For example, if you run it on "I'm going to visit the USA.", it will return "I'm Going To Visit The Usa."...
As mentioned, though, copying the text to the clipboard is tricky.
Copy link to clipboard
Copied
You first need to define if you want sentence case or title case. If title case, that can change based on a set of style parameters, such as Chicago Manual of Style or AP Style.
THIS IS ALL CAPS.
This is sentence case.
This Is Tile Case in Chicago.
Title Case Won't Be the Same When Using AP Style in Terms of Which Letters Are Capitalized.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now