These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

font substitution in pdf document through code

gradstudent
Registered: Dec 16 2010
Posts: 1

Hello All,
 
Is it possible to swap fonts in a document through code? I know I can do it using the advanced editing tool but that gets pretty tedious after page 100 or so. I tried creating a batch file with the following code:
 
/* Changes font to Arial */
var ckWord, numWords;
for (var i = 0; i < this.numPages; i++)
{
numWords = this.getPageNumWords(i);
for (var j = 0; j < numWords; j++) {
ckWord = (this.getPageNthWord(i,j))
if (ckWord.textFont != "Arial") {
ckWord.textFont = "Arial";

}
}
}
 
but it doesn't work which is not surprising because I really don't know what I'm doing. If anyone has any thoughts I would appreciate it very much.

My Product Information:
Acrobat Pro 9.0, Windows
UVSAR
Expert
Registered: Oct 29 2008
Posts: 1357
No you can't. Text on a page is read-only to the JS API, and the return value of doc.getPageNthWord() is just a string, not an object.