WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

OLE with Acrobat Viewer

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

Open Acrobat PDF File and Get the Properties and Page Size and Title Property Update

Keywords: 	  Open Acrobat PDF File 

Finally got the wretched thing to work.

The Acrobat IAC sdk is cryptic at best and non existant at worst.

I had to use a combination of IAC from SDK, SDK VB Samples, Acrobat Javascript examples and VBA and the Acrobat.tlb type library to understand the OLE methods that actually exist and how they work.

The following script gets the properties and page size and has an example of a title property update. It has some superflous code that can be activated if you want to see Acrobat while it is doing it's thing.



pdf_file = "C:\DancerproData\pdf\help5112.pdf"
adobe = objectopen("acroexch.app")      ; create an application object
; adobedoc = objectopen("acroexch.avdoc")      ; create an document object
; adobe.maximize(@true)      ; maximize the application window
;adobe.show()      ; make the application object visible or .hide it
;adobedoc.open(pdf_file, "")      ; open a pdf file, send null string to default to filename for title
;avdoc = adobe.getActiveDoc
;pageview = avdoc.getAVPageview()
;resp = pageview.Goto(0)
pddoc = ObjectOpen("AcroExch.pddoc")
pddoc.open(pdf_file)
p0 = pddoc.GetNumPages()	      ; Page count
InfoValues = "Title!Subject!Author!Keywords!Creator!Created!Modified!Producer! "
debug(@on)
for i = 1 to 8
GiField = ItemExtract(i, InfoValues, "!")
p%i% = pddoc.GetInfo(GiField)
next

 mytit = "This is a new title"
 test = pddoc.SetInfo("Title", mytit)	   ; Set new value in title

debug(@on)
PDPage = pddoc.AcquirePage(0)    ;	      ;PDPage PDDocAcquirePage (PDDoc doc, ASInt32 pageNum);
rect = PDPage.GetSize()
p1 = rect.y	    ; Should be      792	     11 inch at 72 pt per inch
p2 = rect.x	    ; Should be 	  612	8.5 inch
pddoc.save(1, pdf_file)
pddoc.close
;adobedoc.close(@true)      ; close the document,  auto-save
;adobe.minimize(@true)      ; minimize the application window

adobe.exit; exit the application
;objectclose(adobedoc)      ; close the document object
objectclose(adobe)      ; close the application object
message("How", "now??")
exit

Article ID:   W15621
File Created: 2006:02:14:08:37:42
Last Updated: 2006:02:14:08:37:42