borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2007 Andrea Tincaniborder

AndreaVB | Forum | News | Downloads | Register | Help | Member List | Statistics | Search | PM | Profile

Print This Topic
Previous Topic (printing text boxes,etc)Next Topic (Thanks) New Topic New Poll Post Reply
AndreaVB Forum : Printing : batch printing pdf's
Poster Message
zurich
Level: Guest


icon batch printing pdf's

Has anyone ever had a need to batch print PDF's without user interaction via VB?  The issue is primarily one of speed and flexibility.  Ideally, I need to be able to add a Doc Id to each PDF before printing.  We are looking at processing 4000+ PDF's daily, or about a million per year.

More needs:

need the ability to batch print ALL (not just one) the pdf's that reside in a particular directory using Visual Basic

approximately 4,000 pdf's per day

must be in a batch mode.  No user interaction

ability to print a header or one line at the top of each printed pdf

Windows 2000 operating system

Must be able to route this to several printers

Is this possible?  Can you provide sample vb code?  The batch part is the key piece to this, as well as speed and flexibility.

I have not had much luck with ActivePDF and am hesitant to buy full version of Acrobat if it won't meet our needs.

Any advice or suggestions?

20-11-2002 at 05:35 PM
| Quote Reply
JLRodgers
Level: Moderator

Registered: 04-04-2002
Posts: 1616
icon Re: batch printing pdf's

Never tried to do what you're wanting, but here's some general info on what is in Adobe Acrobat (no specifics, since I don't do what you are wanting):

The full version of Adobe Acrobat has the acrobat distiller that can "watch folders" and creating PDF files. It watches folders for postscript files (And others). I've never used it.

Adobe itself has a batch processing option where you can use the prdefined, or create a new. One of the options that can be used is "print". Again, I've never used, but you might find details on Adobe's site.


Offhand though, if you have the funds for it, I'd buy the full version anyway. Nothing else, it can save paper (documents saved as a PDF file are printed to it, so you save via printing [it's a PDF printer]). Which is helpful, especially if you set the default printer to Adobe's.

20-11-2002 at 07:53 PM
View Profile Send Email to User Show All Posts Visit Homepage | Quote Reply
Harristonian
Level: Guest

icon Re: batch printing pdf's

Good question.

I am having similar problems in that I am trying to batch print 10 bespoke reports packs of upto 50 reports.

The problem is that larger reports take longer to hit the print queue than shorter ones, meaning they are executed in sequence but not printed as such. Does anyone know a cheeky function for:

Check the active window,

Do
If the WindowName is not "Acrobat Reader"
  Then Sleep (3000)
else
  .MoveNext
Loop
I have tried several variants of this with no success...


Code too long to post, but will be happy to if you think you can help...

10-12-2002 at 01:12 PM
| Quote Reply
JLRodgers
Level: Moderator

Registered: 04-04-2002
Posts: 1616
icon Re: batch printing pdf's

Do a search for checking print jobs (the code is somewhere, can't remember offhand, may be on www.andreavb.com actually)

Enumerate the print jobs, then send the reports one after another, AFTER the prior has completed, or hit a "printing" status.


IE: 'Not actual code, just an example
Private Sub Print()
    SendFirstReport
    Do
        Do
            DoEvents
        Loop Until PrintJob("Name of report")="Printing" ' OR "Completed", or Doesn't exist
        SendNextReport
    Loop Until AllReportsSent
End Sub


[Edited by JLRodgers on 10-12-2002 at 01:42 PM GMT]

10-12-2002 at 07:42 PM
View Profile Send Email to User Show All Posts Visit Homepage | Quote Reply
Harristonian
Level: Guest

icon Re: batch printing pdf's

I hear ya JL, but there are too many gaps for my newbie head. I can enumerate the outstanding jobs (from AndreaVB.com,   )

But how do I get into the array that contains all the good stuff. Once I can get that, I'll have no trouble searching for a passed string.

P.S. Your pseudo code is exactly what I'm trying to do, but can't fathom how to write the PrintJob("Document") = exists part.

Thanks in advance.

11-12-2002 at 03:46 PM
| Quote Reply
JLRodgers
Level: Moderator

Registered: 04-04-2002
Posts: 1616
icon Re: batch printing pdf's

What's below wouldn't be optimized, but would give you an idea


' the JobDesc() array is public, so you have access to it here
Private Enum ePrintStatus
    PS_PRINTING
    PS_WAITING
    PS_NOTEXIST
End Enum

Private CurrentPrintDocument As String

' With the code that is at andreavb
Private Function PrintStatus(ByVal JobName As String) As ePrintStatus
    Dim i As Integer
    
' Default
    PrintStatus = PS_NOTEXIST
    
    If GetPrinterQueue("PrinterName") > 0 Then 'Jobs exist
        For i = LBound(JobsDesc()) To UBound(JobsDesc())
            If JobsDesc(i).pDocument = JobName Then
            ' Below isn't actual code for the line, not sure what the status
            ' return will look like for which
                If JobsDesc(i).Status = Print_Status_Code Then
                    PrintStatus = PS_PRINTING
                Else
                    PrintStatus = PS_WAITING
                End If
            End If
        Next
    End If
End Function

' Not actual code, but to show how to use
Private Sub PrintDocument()
    CodeTo_SendFirstReport ' store document name in CurrentPrintDocument
    Do
        Do
            DoEvents
        Loop Until PrintStatus(CurrentPrintDocument) = PS_NOTEXIST
        CodeTo_SendNextReport ' store document name in CurrentPrintDocument
    Loop Until AllReportsSent
End Sub

11-12-2002 at 06:12 PM
View Profile Send Email to User Show All Posts Visit Homepage | Quote Reply
Harristonian
Level: Guest

icon Re: batch printing pdf's



Never mind answering the above.

Q. What is a moustache
A. Somthing that's right under your nose

Lesson 1: Never try to code under the influence of Benylin Expectorant.......

Thanks JL -

11-12-2002 at 06:12 PM
| Quote Reply
Harristonian
Level: Guest

icon Re: batch printing pdf's

Sorry you got your post in before my reply.

Just read through your post - A 'bit' more robust/agile/scalable than my effort.

Thanks a million.

11-12-2002 at 06:43 PM
| Quote Reply
AndreaVB Forum : Printing : batch printing pdf's
Previous Topic (printing text boxes,etc)Next Topic (Thanks) New Topic New Poll Post Reply
Surf To:


Not Logged In? Username: Password: Lost your password?
Partners: Download Actual Software | Free Software Download
borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2007 Andrea Tincaniborder