Bonjour

J'arrive à imprimer une image, mais celle ci n'est pas centrée, ni étirée. Je voudrais qu'elle le soit mais ne trouve pas d'info permettant de ce faire... c'est probablement tout bête mais bon.

Mon code:

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
    Private Sub CmdPrint_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CmdPrint.Click
        'Dim pd As Printing.PrintDocument = New Printing.PrintDocument
        'Dim print1 As PrintDialog = New PrintDialog
        'print1.Document = pd
        'If (print1.ShowDialog() = Windows.Forms.DialogResult.OK) Then
        '    pd.Print()
        'End If
        Dim MyPrintDialog As New PrintDialog()
        MyPrintDialog.AllowCurrentPage = False
        MyPrintDialog.AllowPrintToFile = False
        MyPrintDialog.AllowSelection = False
        MyPrintDialog.AllowSomePages = False
        MyPrintDialog.PrintToFile = False
        MyPrintDialog.ShowHelp = False
        MyPrintDialog.ShowNetwork = False
        If MyPrintDialog.ShowDialog() <> Windows.Forms.DialogResult.OK Then Exit Sub
        PrintDocument1.DocumentName = "Test"
        PrintDocument1.PrinterSettings = MyPrintDialog.PrinterSettings
        PrintDocument1.DefaultPageSettings = MyPrintDialog.PrinterSettings.DefaultPageSettings
        PrintDocument1.DefaultPageSettings.Margins = New Printing.Margins(40, 40, 40, 40)
        PrintDocument1.Print()
    End Sub
 
    Private Sub PrintDocument1_PrintPage(ByVal sender As System.Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles PrintDocument1.PrintPage
        e.Graphics.DrawImage(Me.pb1.Image, 10, 10)
    End Sub