Skip to main content
Participant
February 17, 2017
Question

How to find and change text in PDF document using QTP UFT automation VBscript

  • February 17, 2017
  • 3 replies
  • 5191 views

Hi Colleagues,

I need some help from you.

I need to write test case in VBscript for QTP / UFT (12.51)

QTP should launch Adobe Acrobat Pro 9, 10, 11 (all available on testing machines) open existing PDF file from testing folder. Find some text in the PDF document. Select this text and replace with another text. Save changes. Close file. Close Acrobat. Everything looks very simple but I spent 2 days without results. And didn’t find any working code solution.
findText() method didn’t find the text and I can’t proceed

Thank you in advance for any help and advice.

This topic has been closed for replies.

3 replies

Legend
February 18, 2017

I have told you clearly. There is no such method for you.

Legend
February 17, 2017

Ah, so you assume that because it is easy in the UI it is easy in JavaScript. These are entirely differently written, with different rules and approaches. Also, the JavaScript API is tiny - perhaps 5% of the API compared to the plug-in API for C programmers. But even in the plug-in API you cannot work with the text editing tool; you have to implement editing painfully using the PDF specification and plug-in abstraction of it.  To work with JavaScript you have to start with a study of what is possible via looking at the whole API.

I have no idea what QTP is, but if it can simulate clicks and keystrokes, you can try it. But remember this can and will change between releases of Acrobat.

Participant
February 18, 2017

Thank you for your answer, but I still need a help.  QTP is a very strong automation tool of HP company for web and desktop automation testing. It uses VBscript. You write about JavaScript. I don't know does it matter or no.

the problem that I stuck on the step to "findText() " method wich should find text in PDF document.

In the next steps I will try to manipulate with it... but it didn't work in my case but should be.

Inspiring
February 19, 2017

You most likely will need to use an external computer language like C and then use the Acrobat SDK API tools to interact with the PDF.

Legend
February 17, 2017

I don't know how you can say this sounds simple... there is no JavaScript method that can change page contents (as opposed to form fields or annotations).

Participant
February 17, 2017

But Adobe Acrobat have "Edit Document Text" function.
You click it, then click on the text you would like to select and can operate with it how you can do it in MS Word.


http://help.adobe.com/livedocs/acrobat_sdk/9/Acrobat9_HTMLHelp/wwhelp/wwhimpl/js/html/wwhelp.htm?href=IAC_API_OLE_Object…

There is a good documentation and description of all  methods.

May be it is possible to find text, select it, and then using QTP tools perform the action of editing.