PDA

View Full Version : Solved: Get PDF page size



lynnnow
11-02-2012, 01:12 AM
I'm using a routine to search for all PDFs in a folder and its subfolder and returning the number of pages in each PDF. Is it possible to get the page size of each PDF? I've looked a lot for a VBA solution but haven't found on. I'm using this for getting the page numbers

For Each FileNameWithPath In ListOfFilenamesWithPath 'FileNameWithPath.Files
T_str = UCase(FileNameWithPath)
If Right(T_str, 4) = ".PDF" Then

Set ac_fi = New Acrobat.AcroPDDoc

ac_fi.Open T_str
Cells(i, 1).Value = Mid(FileNameWithPath, 1, InStrRev(FileNameWithPath, "\", -1, vbTextCompare) - 1)
Cells(i, 2).Value = Mid(FileNameWithPath, InStrRev(FileNameWithPath, "\", -1, vbTextCompare) + 1, Len(FileNameWithPath))
Cells(i, 3).Value = ac_fi.GetNumPages
'Cells(i, 4).Value = ac_fi.GetSize
i = i + 1
ac_fi.Close
Set ac_fi = Nothing
'Columns("A:D").AutoFit
End If
Next FileNameWithPath

lynnnow
11-03-2012, 03:50 AM
bump!! :help:

lynnnow
11-06-2012, 01:32 AM
Alright I've solved it...

I replaced the
'Cells(i, 4).Value = ac_fi.GetSize
with
Set PDFPage = Ac_Fi.AcquirePage(0).GetSize()
p1 = PDFPage.y / 72
p2 = PDFPage.x / 72
This gave me the x and y coordinates and I divided it by 72 to convert it to inches.

Blade Hunter
11-06-2012, 03:37 PM
Alright I've solved it...

I replaced the
'Cells(i, 4).Value = ac_fi.GetSize
with
Set PDFPage = Ac_Fi.AcquirePage(0).GetSize()
p1 = PDFPage.y / 72
p2 = PDFPage.x / 72
This gave me the x and y coordinates and I divided it by 72 to convert it to inches.

Ac_Fi

Is that some sort of PDF plugin you have? Been a few months since I looked in to this but I didn't think VBA could reference PDF directly.