Question : print pdf files from a watch folder, of print commandline.

I need a way to automate printing of pdf files, being placed in a specific folder.  
Another option is te create a program that can be used commandline e.g. printfile [filename.pdf] [which printer]

I downloaded the acrobat 5.0 SDK, installed it but don't really know how to use it.


ardi

Answer : print pdf files from a watch folder, of print commandline.

Hi ardixiv,

You will need the "Acrobat PDFWriter" as a printer on your PC.

Then here is some code that I use to print PDF's........

 Imports Acrobat         '<------ acrobat.tlb   from Acrobat 5.0


   '****** AcroBat Objects ********
    Public bOK As Boolean
    Public PDFAVfile As Acrobat.CAcroAVDoc
    Public sPDFPath As String                    'Pdf Main File Path

   Public Function InitializePrinter(ByVal sPrinterName As String) As Boolean
        ' Set the specified printer to the default printer for this program. Return
        ' true if the printer was found.
        Dim iprinter As Integer
        Dim printer As New Printing.PrinterSettings

        For iprinter = 0 To printer.InstalledPrinters.Count - 1
            If InStr(printer.InstalledPrinters.Item(iprinter), sPrinterName) > 0 Then
                printer.PrinterName = sPrinterName
                InitializePrinter = True
                Exit Function
            End If
        Next iprinter

        MsgBox("The '" & sPrinterName & "' printer could not be found.", vbExclamation)
        InitializePrinter = False
    End Function

    Public Sub PrintReports()
        Cursor.Current = Cursors.WaitCursor
        Try
            Dim di As New DirectoryInfo(sAppPath & "Acrobat\")    '<--- use your directory
            Dim fi As FileInfo() = di.GetFiles()
            Dim fiTemp As FileInfo

            For Each fiTemp In fi
                'Open file and Get the document pages
                PDFAVfile = CreateObject("AcroExch.AVDoc")
                bOK = FirstPDFAVfile.Open(fiTemp.FullName, "")
                PDFPDfile = PDFAVfile.GetPDDoc
                If InitializePrinter("Acrobat PDFWriter") = True Then
                    'The pages numbers have to be 0 for start and totals pages -1 for the last page
                    'Acrobat uses the pages like an array 0 to last page - 1.
                    bOK = PDFAVfile.PrintPages(0, PDFAVfile.GetNumPages - 1, 1, False, True)
                End If
                PDFAVfile.Close(True)
             Next fiTemp
        Catch Exp As Exception
            MsgBox(Exp.Message & "   in Print Report Procedure", MsgBoxStyle.Critical, "General Error")
        End Try
        Cursor.Current = Cursors.Default
    End Sub
Random Solutions  
 
programming4us programming4us