I am trying to script Acrobat from VBA for Word to crop the inside edge of a 2-up layout (where the staple goes) to remove the bleed. I'm close.
I get Type mismatches no matter HOW I call setPageBoxes
Code as follows:
Sub acrobatTest()
Dim ac As New AcroApp
Dim acDoc As New AcroPDDoc
Dim jso As Object
Dim myCrop As Variant
Dim numPages As Variant
Dim cropsize As Integer
cropsize = 27 ' 0.375 inch
Dim i As Variant
ac.Show
ac.Maximize 1
acDoc.Open "C:\1982764.pdf"
Set jso = acDoc.GetJSObject
numPages = jso.numPages
For i = 0 To numPages - 1
myCrop = jso.getPageBox()
jso.setPageBoxes
myCrop = jso.getPageBox("Crop", i)
myTrim = jso.getPageBox("Trim", i)
If i Mod 2 <> 0 Then
myCrop(2) = myCrop(2) - cropsize ' Crop Left pages
Else
myCrop(0) = myCrop(0) + cropsize ' Crop Right pages
End If
jso.setPageBoxes "Crop", i, i, myCrop
Next i
End Sub
However, there is already a crop function in the IAC (AcroExch.PDPage.CropPage). Why not use it instead of going to JavaScript.
Thom Parker
The source for PDF Scripting Info
[url=http://www.pdfScripting.com]pdfscripting.com[/url]
The Acrobat JavaScript Reference, Use it Early and Often
[url=http://www.adobe.com/devnet/acrobat/javascript.php]http://www.adobe.com/devnet/acrobat/javascript.php[/url]
Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script