+ Reply to Thread
Results 1 to 9 of 9

Thread: help with print routine -multiple pages - multiple printers

  1. #1
    otonomi is offline VB.NET Forum Newbie otonomi is on a distinguished programming path ahead
    .NET Framework
    .NET 3.5
    Join Date
    Mar 2010
    Age
    28
    Posts
    5
    Reputation
    0

    Default help with print routine -multiple pages - multiple printers

    Hi all,

    i need help with my print routine:

    I have a routine, with the printDoc_PrintPage() function where i loop my pages and print them on the default printer.

    What i need to do is print page 1 on a special printer and the other pages on the default printer.
    Does anyone has any ideas how to do this?

    I tried with printDoc_QueryPageSettings because this gets triggered before every Printpage() event but i can't get it working.

    Help would be appreciated!!

    thx

  2. #2
    InertiaM is offline VB.NET Forum Idol InertiaM puts e.f. hutton to shame InertiaM puts e.f. hutton to shame InertiaM puts e.f. hutton to shame InertiaM puts e.f. hutton to shame InertiaM puts e.f. hutton to shame InertiaM puts e.f. hutton to shame
    .NET Framework
    .NET 2.0
    Join Date
    Nov 2007
    Location
    Kent, UK
    Age
    39
    Posts
    563
    Reputation
    175

    Default

    1. Split the printDoc into two different documents eg PrintDoc1 and PrintDoc2. Allocate PrintDoc1 and PrintDoc2 to different printers.

    2. Define a variable to be set depending on which PrintDoc1/PrintDoc2 is being printed.

    3. Change the PrintDoc_PrintPage event to be "handles PrintDoc1.PrintPage, PrintDoc2.PrintPage". Within the PrintPage event, based on the variable value, only do page 1 for PrintDoc1 and do not do page 1 for PrintDoc2.
    Always parameterize your queries - read more here

  3. #3
    otonomi is offline VB.NET Forum Newbie otonomi is on a distinguished programming path ahead
    .NET Framework
    .NET 3.5
    Join Date
    Mar 2010
    Age
    28
    Posts
    5
    Reputation
    0

    Default

    hi, thx for your answer.

    i don't quit understand step 3. How can i set PrintDoc1 for page 1 and PrintDoc2 for the other pages?

    thx

  4. #4
    InertiaM is offline VB.NET Forum Idol InertiaM puts e.f. hutton to shame InertiaM puts e.f. hutton to shame InertiaM puts e.f. hutton to shame InertiaM puts e.f. hutton to shame InertiaM puts e.f. hutton to shame InertiaM puts e.f. hutton to shame
    .NET Framework
    .NET 2.0
    Join Date
    Nov 2007
    Location
    Kent, UK
    Age
    39
    Posts
    563
    Reputation
    175

    Default

    Hand written psuedo code :-

    Code:
    Private WhatPagesToPrint as string = ""
    
    Private Sub PrintDoc1_BeginPrint(ByVal sender As Object, ByVal e As System.Drawing.Printing.PrintEventArgs) Handles PrintDoc1.BeginPrint
        WhatPagesToPrint = "Page 1"
    End Sub
    
    Private Sub PrintDoc2_BeginPrint(ByVal sender As Object, ByVal e As System.Drawing.Printing.PrintEventArgs) Handles PrintDoc2.BeginPrint
        WhatPagesToPrint = "All other pages"
    End Sub
    
    
    Private Sub Combined_PrintPage(ByVal sender As Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles PrintDoc1.PrintPage, PrintDoc2.PrintPage
        With e.Graphics
            Select Case WhatPagesToPrint
                Case "Page 1"
                    'only do page 1
                Case "All other pages"
                    'do NOT do page 1, but do all other pages
            End Select
        End With
    End Sub
    Always parameterize your queries - read more here

  5. #5
    otonomi is offline VB.NET Forum Newbie otonomi is on a distinguished programming path ahead
    .NET Framework
    .NET 3.5
    Join Date
    Mar 2010
    Age
    28
    Posts
    5
    Reputation
    0

    Default

    Thx for the code above...

    But i can't get it running.

    When i call the print routine: Combined.Print(), i need to add Combined.printPage like this:
    Private Sub Combined_PrintPage(ByVal sender As Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles PrintDoc1.PrintPage, PrintDoc2.PrintPage, Combined.PrintPage

    but then, when i go to the select case WhatPagesToPrint, the value is empty when i debug it...
    how is this possible? this is killing me!

  6. #6
    InertiaM is offline VB.NET Forum Idol InertiaM puts e.f. hutton to shame InertiaM puts e.f. hutton to shame InertiaM puts e.f. hutton to shame InertiaM puts e.f. hutton to shame InertiaM puts e.f. hutton to shame InertiaM puts e.f. hutton to shame
    .NET Framework
    .NET 2.0
    Join Date
    Nov 2007
    Location
    Kent, UK
    Age
    39
    Posts
    563
    Reputation
    175

    Default

    Without seeing all the code, we can only guess
    Always parameterize your queries - read more here

  7. #7
    otonomi is offline VB.NET Forum Newbie otonomi is on a distinguished programming path ahead
    .NET Framework
    .NET 3.5
    Join Date
    Mar 2010
    Age
    28
    Posts
    5
    Reputation
    0

    Default

    this is my code for the functions...
    basically in the print routine i loop the pages

    if pagenumber is 1 it prints contents, for page 2, it prints other contents and print page 3 or more prints the rest.
    Attached Files
    Last edited by JohnH; 03-18-2010 at 3:44 AM. Reason: excessive code to attachment

  8. #8
    InertiaM is offline VB.NET Forum Idol InertiaM puts e.f. hutton to shame InertiaM puts e.f. hutton to shame InertiaM puts e.f. hutton to shame InertiaM puts e.f. hutton to shame InertiaM puts e.f. hutton to shame InertiaM puts e.f. hutton to shame
    .NET Framework
    .NET 2.0
    Join Date
    Nov 2007
    Location
    Kent, UK
    Age
    39
    Posts
    563
    Reputation
    175

    Default

    Normally, I would say - please use CODE tags, as it makes your code easier to read. Unfortunately, in this case, I'm not sure it's going to help much

    The vast majority of your PrintPage code should be put into the BeginPrint subroutine (or earlier). All your queries should be parameterised. Most of your queries are pulling all the fields from the table, yet you are only using a single value - why havent you used ExecuteScalar instead?

    To answer your question, when you call Combined.Print(), you havent set the value of sWhatPagesToPrint.

    I also think you missed my main point. PrintDoc1 would print page 1, PrintDoc2 would print all other pages. You can then target PrintDoc1 to printer A, and PrintDoc2 to printer B. If you want to print a 'combined' document, send PrintDoc1 and PrintDoc2 to the same printer.
    Always parameterize your queries - read more here

  9. #9
    otonomi is offline VB.NET Forum Newbie otonomi is on a distinguished programming path ahead
    .NET Framework
    .NET 3.5
    Join Date
    Mar 2010
    Age
    28
    Posts
    5
    Reputation
    0

    Default

    ok, now i'm trying to printdoc1 and printdoc2 using the combined document, and it works!
    i guess for my printpreview, i need to work with 2 previews since i'm printing on 2 different printers?

    thx for your help so far!!! you are the man

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

     

Tags for this Thread

Bookmarks

Posting Permissions

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