View Single Post
  #2 (permalink)  
Old 11-28-2009, 4:05 PM
InertiaM InertiaM is offline
VB.NET Forum Idol
.NET Framework: .NET 2.0
 
Join Date: Nov 2007
Location: Kent, UK
Age: 39
Posts: 536
Reputation: 169
InertiaM puts e.f. hutton to shameInertiaM puts e.f. hutton to shameInertiaM puts e.f. hutton to shameInertiaM puts e.f. hutton to shameInertiaM puts e.f. hutton to shameInertiaM puts e.f. hutton to shame
Default

Tip - create a print preview option and check it before it's printed - helps to save the planet

Although you believe it's been sized for A4, you'll probably still have to enlarge it to fit the page. For example:-

Code:
Option Explicit On
Option Strict On

Imports System.Drawing.Printing

Public Class Form1

    Public WithEvents pdPrinter As New PrintDocument

    Private Sub TestPrintPreview(ByVal sender As System.Object, _
    ByVal e As System.EventArgs) Handles Button1.Click

        Using ppvwPrinter As New PrintPreviewDialog
            With ppvwPrinter
                .Document = pdPrinter
                .Width = Screen.PrimaryScreen.Bounds.Width
                .Height = Screen.PrimaryScreen.Bounds.Height
                .PrintPreviewControl.Zoom = 0.66
                .ShowDialog()
            End With
        End Using
    End Sub

    Private Sub Begin_Printing(ByVal sender As System.Object, _
    ByVal e As System.Drawing.Printing.PrintEventArgs) _
     Handles pdPrinter.BeginPrint
        pdPrinter.DocumentName = "Test Document"
        pdPrinter.PrintController = New Printing.StandardPrintController()
    End Sub

    Private Sub Test_PrintPage(ByVal sender As System.Object, _
    ByVal e As PrintPageEventArgs) Handles pdPrinter.PrintPage
        With e.Graphics
            .PageUnit = GraphicsUnit.Millimeter

            .DrawImage(PictureBox1.Image, 0, 0, Convert.ToInt32((e.PageSettings.PaperSize.Width / 100) * 25.4), Convert.ToInt32((e.PageSettings.PaperSize.Height / 100) * 25.4))
        End With
    End Sub

End Class
If you find that the PrintPreview and the actual print are not in the same place, look at this thread
__________________
Always parameterize your queries - read more here
Reply With Quote