Print Page | Close Window

Change / Replace a word at Quads

Printed From: Foxit's Planet PDF Forum
Category: Lets Talk PDF
Forum Name: JavaScript
Forum Description: Discussions relating to the use of JavaScript within PDF.
Printed Date: 18 Nov 2019 at 1:48am
Software Version: Web Wiz Forums 11.10 -

Topic: Change / Replace a word at Quads
Posted By: mhoney
Subject: Change / Replace a word at Quads
Date Posted: 27 May 2014 at 8:59am

For quite a few months now I have been writing scripts for some Accounting projects which have worked extremely well (with some great tips from this forum).

I have been using getPageNthWordQuads and getPageNthWord methods to obtain all words in a pdf / manipulating the data using arrays and then writing out a data object .csv .txt for uploading into an Accounting Information System.   All works great!

What I would like to do now is somewhat work in reverse.  Is it possible to replace or change a word if you know the Quads for a word.  I want to basically loop through all the words / get all quads and then change specific words based on their quards.

If you have some tips I would appreciate it so much.  Java Script is quite addictive and very very useful with Acrobat.Smile




Posted By: BAlheit
Date Posted: 27 May 2014 at 10:16am
With Javascript you can't change words.

Posted By: gkaiseril
Date Posted: 27 May 2014 at 6:46pm
You can only use the redaction to replace the words subject to lots of limitations.

Posted By: try67
Date Posted: 27 May 2014 at 11:53pm
Or you can overlay a field (or an annotation) on top of the old word and place the new one. Of course, if they have different lengths it will look out of place. Plus, you need to know in advance what font was used because you don't have access to that information with JS...

- Acrobat Expert - Contact me personally at
Check out my custom-made scripts website:

Posted By: mhoney
Date Posted: 30 May 2014 at 4:17am
Thanks for your advice I will have a go at this and see if I can get it work work effectively.  

Generally the geometry of the files I will be working with will always be the same.  They are pdf's that are from automated systems etc  which hopefully should make it a bit easier.

You both are very knowledgable.



Posted By: aandi
Date Posted: 30 May 2014 at 10:11pm
Bear in mind that if you cover the words, and someone exports text or copy/pastes they may get both sets of words, or more commonly only the original set. The overlay technique is really only suitable if the only applicable use of the edited file is printing.

Print Page | Close Window

Forum Software by Web Wiz Forums® version 11.10 -
Copyright ©2001-2017 Web Wiz Ltd. -