locked
Number of copies of the print page RRS feed

  • Question

  • I am printing a barcode label and I want to add more than one copy considering that it is one page

    code not work

      PrintDialog1.AllowSomePages = True
            With PrintDialog1.PrinterSettings
                .Copies = 2
                .FromPage = 1
                .ToPage = 1
            End With

    Saturday, November 4, 2017 2:00 AM

Answers

  • When I go to the print preview to see before printing, the number of copies does not increase

    ahmed,

    Sorry, I cant understand what you are telling us.

    My example works to print copies. It is just an example. Modify it how you like.

    Go read what I wrote again. I said, the copies do not appear in the preview> You must print it on the printer.

    Do you understand what copy means in this case? Say you have a printout that is two pages page A and page B. That is a document with pages a and b. Then, you can make multiple copies of the document. So if you set copies = 2 your will get

    Page A
    Page B
    Page A
    Page B


    That is what the copies function does. If it is not what you want then you have to do something else.

    Are you sure your printer supports the copies function?

    • Marked as answer by ahmeddc Saturday, November 4, 2017 4:43 PM
    Saturday, November 4, 2017 4:21 PM

All replies

  • I am printing a barcode label and I want to add more than one copy considering that it is one page

    code not work

    What exactly do you mean by 'not work'?  Is it printing only one page instead of two ages, or is nothing printing at all, or something else?

    Have you confirmed that the printer is capable of printing multiple copies - not all printers can?  You need to check  the MaximumCopies property to determine the maximum number of copies the printer supports.

    Saturday, November 4, 2017 2:18 AM
  • No matter how you change the numbers, print pages do not increase

    PrintDialog1.AllowSomePages = True
            With PrintDialog1.PrinterSettings
                .Copies = 2
                .FromPage = 1
                .ToPage = 2
            End With

    I used the following code and did not work either

      Private Sub PrintDocument1_BeginPrint(ByVal sender As Object, ByVal e As System.Drawing.Printing.PrintEventArgs) Handles PrintDocument1.BeginPrint
            PrintDocument1.PrinterSettings.Copies = nudPages.Value
            PrintDialog1.AllowSomePages = True
        End Sub


    Saturday, November 4, 2017 12:55 PM
  • No matter how you change the numbers, print pages do not increase

    PrintDialog1.AllowSomePages = True
            With PrintDialog1.PrinterSettings
                .Copies = 2
                .FromPage = 1
                .ToPage = 2
            End With

    I used the following code and did not work either

      Private Sub PrintDocument1_BeginPrint(ByVal sender As Object, ByVal e As System.Drawing.Printing.PrintEventArgs) Handles PrintDocument1.BeginPrint
            PrintDocument1.PrinterSettings.Copies = nudPages.Value
            PrintDialog1.AllowSomePages = True
        End Sub


    Ahmed,

    This gives me two copies of 3 pages on my HP3050 which has that feature. Its the example from the last thread.

    It does not show the copies in print preview. You have to print it.

    Acamar is correct, if the printer does not support multiple copies then nothing will happen there.

    'printing multiline text with image at end
    Imports System.Drawing.Printing
    Public Class PrintMuliTextWithImage
        Private WithEvents pd As New PrintDocument
        Private Lines As New List(Of String)
        Private bmp As New Bitmap("c:\bitmaps\rusty.jpg")
    
        Private Sub Form10_Load(sender As Object, e As EventArgs) Handles MyBase.Load
            For i As Integer = 0 To 130
                Lines.Add("line " & i.ToString)
            Next
            pd.PrinterSettings.Copies = 2
            Dim preview As New PrintPreviewDialog
            preview.Document = pd
            preview.ShowDialog()
        End Sub
    
        Private Sub PrintPage(ByVal sender As Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles pd.PrintPage
            Static I As Integer
            Dim VerticalPos As Single = e.MarginBounds.Top
            Dim thisFontHeight As Single = CSng(e.Graphics.MeasureString("X", Font).Height)
    
            Do
                If I > Lines.Count - 1 Then
                    'text is done
                    If VerticalPos < e.MarginBounds.Bottom - 220 Then
                        'text is done and room for image add to this page
                        e.Graphics.DrawImage(bmp, 200, VerticalPos + 20)
                        I = 0
                        e.HasMorePages = False
                        Exit Do
                    Else
                        'text is done but not room for image on this page
                        e.HasMorePages = True
                        Exit Do
                    End If
    
                Else
                    e.Graphics.DrawString(Lines(I), New Font("Arial", 10, FontStyle.Regular, GraphicsUnit.Pixel), Brushes.Black, 200, VerticalPos)
    
                    VerticalPos += thisFontHeight
    
                    If VerticalPos > e.MarginBounds.Bottom Then
                        'if more text beyond bottom without image
                        e.HasMorePages = True
                        Exit Do
                    End If
                End If
    
                I += 1
            Loop
        End Sub
    End Class
    

    Saturday, November 4, 2017 1:12 PM
  • No matter how you change the numbers, print pages do not increase

    PrintDialog1.AllowSomePages = True
            With PrintDialog1.PrinterSettings
                .Copies = 2
                .FromPage = 1
                .ToPage = 2
            End With

    I used the following code and did not work either

      Private Sub PrintDocument1_BeginPrint(ByVal sender As Object, ByVal e As System.Drawing.Printing.PrintEventArgs) Handles PrintDocument1.BeginPrint
            PrintDocument1.PrinterSettings.Copies = nudPages.Value
            PrintDialog1.AllowSomePages = True
        End Sub


    Ahmed,

    This gives me two copies of 3 pages on my HP3050 which has that feature. Its the example from the last thread.

    It does not show the copies in print preview. You have to print it.

    Acamar is correct, if the printer does not support multiple copies then nothing will happen there.

    'printing multiline text with image at end
    Imports System.Drawing.Printing
    Public Class PrintMuliTextWithImage
        Private WithEvents pd As New PrintDocument
        Private Lines As New List(Of String)
        Private bmp As New Bitmap("c:\bitmaps\rusty.jpg")
    
        Private Sub Form10_Load(sender As Object, e As EventArgs) Handles MyBase.Load
            For i As Integer = 0 To 130
                Lines.Add("line " & i.ToString)
            Next
            pd.PrinterSettings.Copies = 2
            Dim preview As New PrintPreviewDialog
            preview.Document = pd
            preview.ShowDialog()
        End Sub
    
        Private Sub PrintPage(ByVal sender As Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles pd.PrintPage
            Static I As Integer
            Dim VerticalPos As Single = e.MarginBounds.Top
            Dim thisFontHeight As Single = CSng(e.Graphics.MeasureString("X", Font).Height)
    
            Do
                If I > Lines.Count - 1 Then
                    'text is done
                    If VerticalPos < e.MarginBounds.Bottom - 220 Then
                        'text is done and room for image add to this page
                        e.Graphics.DrawImage(bmp, 200, VerticalPos + 20)
                        I = 0
                        e.HasMorePages = False
                        Exit Do
                    Else
                        'text is done but not room for image on this page
                        e.HasMorePages = True
                        Exit Do
                    End If
    
                Else
                    e.Graphics.DrawString(Lines(I), New Font("Arial", 10, FontStyle.Regular, GraphicsUnit.Pixel), Brushes.Black, 200, VerticalPos)
    
                    VerticalPos += thisFontHeight
    
                    If VerticalPos > e.MarginBounds.Bottom Then
                        'if more text beyond bottom without image
                        e.HasMorePages = True
                        Exit Do
                    End If
                End If
    
                I += 1
            Loop
        End Sub
    End Class

    The code you used to skip the first page goes to a new page
    I know how the situation and biography

    But my code is to print a barcode sticker, which basically does not go beyond part of the page

    What Is A Copy Is More Than A Page To Paste A Barcode Component Into One Page To Multiple Copy Or Pages

    Saturday, November 4, 2017 3:40 PM
  • When I go to the print preview to see before printing, the number of copies does not increase

    • Edited by ahmeddc Saturday, November 4, 2017 3:42 PM
    Saturday, November 4, 2017 3:42 PM
  • When I go to the print preview to see before printing, the number of copies does not increase

    ahmed,

    Sorry, I cant understand what you are telling us.

    My example works to print copies. It is just an example. Modify it how you like.

    Go read what I wrote again. I said, the copies do not appear in the preview> You must print it on the printer.

    Do you understand what copy means in this case? Say you have a printout that is two pages page A and page B. That is a document with pages a and b. Then, you can make multiple copies of the document. So if you set copies = 2 your will get

    Page A
    Page B
    Page A
    Page B


    That is what the copies function does. If it is not what you want then you have to do something else.

    Are you sure your printer supports the copies function?

    • Marked as answer by ahmeddc Saturday, November 4, 2017 4:43 PM
    Saturday, November 4, 2017 4:21 PM
  •   I understand this method is intended for printing directly and not for printprevie
    Saturday, November 4, 2017 4:45 PM
  • No matter how you change the numbers, print pages do not increase

    Have you confirmed that the printer supports multiple copies?   It doesn't matter what you set the value to, if the printer doesn't support multiple copies then you will only get one.    If that's what is happening then you can repeat the print operation to get another copy.

    Saturday, November 4, 2017 8:50 PM