Automating PDF with QTP just got easier!
There are many ways in which pdfs can be automated , since it's been some time that I automated pdf related stuff; I found some new ways that are easier:
Apart from the older methods like:
For Adobe Reader:
Set rdrObj= createobject("AcroPDF.PDF")
Set rdrObj= Nothing
Note: This approach is good but has few options and can only be used for purposes like printing contents of the pdf file.
For Adobe Acrobat:
Set acrObj = CreateObject( "AcroExch.PDDoc" )
If acrObj .Open( FileName ) Then
PagesinPdf = acrObj .GetNumPages()
Set acrObj = Nothing
PagesinPdf = -1
- Set acrObj = CreateObject("AFormAut.App")--to manipulate from pdf forms
- Set acrObj = CreateObject("AcroExch.App")--creating acrobat application object
- Set acrObj = CreateObject("AcroExch.AVDoc")--one avdoc object per displayed document.
APTT - Adobe Pdf Test Toolkit
Like any other objects that are added in your Object repository, you would wish that there was a plug-in for adobe too. Here is the solution to that
- Download ADOBE APTT plugin.
- If you install ADOBE APTT plugin, QTP starts identifying the objects in PDF like any other object.
- This can be downloaded from: http://labs.adobe.com/technologies/aptt/
If the purpose is just storing all text in a variable simple and dirty solutions is :
You can open the PDF file do (Ctrl + a -> Ctrl + c ) or use getvisibletext
And get the contents from mercury.clipboard and store it in a variable.