Consulting

Results 1 to 4 of 4

Thread: Solved: Get PDF page size

  1. #1
    VBAX Tutor lynnnow's Avatar
    Joined
    Jan 2005
    Location
    Mumbai, Maharashtra, India
    Posts
    299
    Location

    Solved: Get PDF page size

    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

    [vba] 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").AutoFit
    End If
    Next FileNameWithPath
    [/vba]

  2. #2
    VBAX Tutor lynnnow's Avatar
    Joined
    Jan 2005
    Location
    Mumbai, Maharashtra, India
    Posts
    299
    Location
    bump!! :

  3. #3
    VBAX Tutor lynnnow's Avatar
    Joined
    Jan 2005
    Location
    Mumbai, Maharashtra, India
    Posts
    299
    Location
    Alright I've solved it...

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

  4. #4
    VBAX Contributor
    Joined
    May 2010
    Location
    Sydney, NSW, Australia
    Posts
    170
    Location
    Quote Originally Posted by lynnnow
    Alright I've solved it...

    I replaced the
    [vba]'Cells(i, 4).Value = ac_fi.GetSize[/vba]
    with
    [vba]Set PDFPage = Ac_Fi.AcquirePage(0).GetSize()
    p1 = PDFPage.y / 72
    p2 = PDFPage.x / 72[/vba]
    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •