PDF In-Depth

IAC - Printing every PDF in a folder

December 16, 1999

Advertisement
Advertisement
 

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 POSTSCRIPT_LEVEL = 2
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
    AcroExchApp.Show

' 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
    Loop
    
' Close Acrobat Exchange
    AcroExchApp.Exit
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

Back to the past, 15 years ago! Open Publish 2002

Looking back to 2002, it's amazing how much of the prediction became a reality. Take a read and see what you think!

September 14, 2017
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.

Features

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.