PDF In-Depth

IAC - Printing every PDF in a folder

December 16, 1999


This method prints all of the PDFs in the folder c:\acrobatdocstoprint.

This code sample is posted here for the general benefit of the PDF development community. Attribution and usage guidelines are as noted in the code source; please respect the wishes of the author when using this code.

Option Explicit ' Force variable declaration
' Author : Planet PDF
' Date : 08 March 1998
' Description: PrintAllAcrobatDocsInDir
' This vb method uses IAC to print all documents in a
' directory.
' This method / function should be extended to suit the requirements
' of an organisation

Public Const PDF_WILDCARD = "*.pdf"
Public Const PDF_DIRECTORY = "c:\acrobatdocstoprint\"

Sub PrintAllAcrobatDocsInDir()
    Dim AcroExchAVDoc As Object, AcroExchPDDoc As Object, _
        AcroExchApp As Object
        Dim strFileName As String, strPath As String
    Dim iNumberOfPages As Integer
    Set AcroExchApp = CreateObject("AcroExch.App")
    Set AcroExchAVDoc = CreateObject("AcroExch.AVDoc")
    Set AcroExchPDDoc = CreateObject("AcroExch.PDDoc")

' Show the Acrobat Exchange window

' Set the directory / folder to use
    strPath = PDF_DIRECTORY

' Get the first pdf file in the directory
    strFileName = Dir(strPath + PDF_WILDCARD, vbNormal)   

' Start the loop.
    Do While strFileName <> ""

    ' Open the [strFileName] pdf file
        AcroExchAVDoc.Open strPath + strFileName, ""
    ' Get the PDDoc associated with the open AVDoc

 Set AcroExchPDDoc = AcroExchAVDoc.GetPDDoc

    ' Get the number of pages for this pdf [and subtract one as zero based]
        iNumberOfPages = AcroExchPDDoc.GetNumPages - 1

    ' Print all pages in this document
        AcroExchAVDoc.PrintPages 0, iNumberOfPages, POSTSCRIPT_LEVEL, True, False

    ' Close this file
        AcroExchAVDoc.Close True

    ' Get the name of the next file in the directory
        strFileName = Dir
' Close Acrobat Exchange
End Sub
PDF In-Depth Free Product Trials Ubiquitous PDF

Debenu Quick PDF Library

Get products to market faster with this amazing PDF developer SDK. Over 900 functions and an equally...

Download free demo

Five visions of a PDF Day

In the world of PDFs or as we like to say Planet (of) PDF, a year isn't a real PDF year without an intense few days of industry knowledge sharing.

May 15, 2018
Platinum Sponsor

Search Planet PDF
more searching options...
Planet PDF Newsletter
Most Popular Articles
Featured Product

Debenu PDF Aerialist

The ultimate plug-in for Adobe Acrobat. Advanced splitting, merging, stamping, bookmarking, and link control. Take Acrobat to the next level.


Adding a PDF Stamp Comment

OK, so you want to stamp your document. Maybe you need to give reviewers some advice about the document's status or sensitivity. This tip from author Ted Padova demonstrates how to add stamps with the Stamp Tool along with related comments.