IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

VB.NET Discussion :

Impression - page x sur y (nombre de pages total)


Sujet :

VB.NET

Mode arborescent

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre averti
    Profil pro
    Inscrit en
    Mai 2009
    Messages
    31
    Détails du profil
    Informations personnelles :
    Âge : 41
    Localisation : France

    Informations forums :
    Inscription : Mai 2009
    Messages : 31
    Par défaut Impression - page x sur y (nombre de pages total)
    Bonjour

    j'ai rédigé ce code (voir ci-dessous) permettant l'impression d'un document (voir en pièce jointe).

    j'ai deux question relative à ce code :
    1) Lorsque j'imprime en PDF, certains morceaux de texte sont sélectionnable et pas d'autres (ils sont écrit sous forme d'images et donc moches sous pdf), ça semble aléatoire, selon si je relance l'impression, ils peuvent sortir correctement ou pas... un bug de pdfcréator ? sortie sur une imprimante normale, ça sort nickel.

    2) je voudrait en haut de chaque page indiquer "page x sur y", en ce qui concerne x, c'est facile mais pour y (nombre de page que comporte le document) je ne voit pas comment faire car je ne connait pas le nombre de pages total au moment ou j'écrit sur la feuille, avez-vous une idée ?

    code en question :
    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
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    275
    276
    277
    278
    279
    280
    281
    282
    283
    284
    285
    286
    287
    288
    289
    290
    291
    292
    293
    294
    295
    296
    297
    298
    299
    300
    301
    302
    303
    304
    305
    306
    307
    308
    309
    310
    311
    312
    313
    314
    315
    316
    317
    318
    319
    320
    321
    322
    323
    324
    325
    326
    327
    328
    329
    330
    331
    332
    333
    334
    335
    336
    337
    338
    339
    340
    341
    342
    343
    344
    345
    346
    347
    348
    349
    350
    351
    352
    353
    354
    355
    356
    357
    358
    359
    360
    361
    362
    363
    364
    365
    366
    367
    368
    369
    370
    371
    372
    373
    374
    375
    376
    377
    378
    379
    380
    381
    382
    383
    384
    385
    386
    387
    388
    389
    390
    391
    392
    393
    394
    395
    396
    397
    398
    399
    400
    401
    402
    403
    404
    405
    406
    407
    408
    409
    410
    411
    412
    413
    414
    415
    416
    417
    418
    419
    420
    421
    422
    423
    424
    425
    426
    427
    428
    429
    430
    431
    432
    433
    434
    435
    436
    437
    438
    439
    440
    441
    442
    443
    444
    445
    446
    447
    448
    449
    450
    451
    452
    453
    454
    455
    456
    457
    458
    459
    460
    461
    462
    463
    464
    465
    466
    467
    468
    469
    470
    471
    472
    473
    474
    475
    476
    477
    478
    479
    480
    481
    482
    483
    484
    485
    486
    487
    488
    489
    490
    491
    492
    493
    494
    495
    496
    497
    498
    499
    500
    501
    502
    503
    504
    505
    506
    507
    508
    509
    510
    511
    512
    513
    514
    Imports System.Drawing.Printing
     
    Public Class Impression
     
        Public Class Marge
            Public Property Devis As Devis
            Public Property Marges As List(Of MargeSalleInfos)
            Public Property MargeTotal As MargeSalleInfos
     
            Public Sub New(Devis As Devis, Marges As List(Of MargeSalleInfos), MargeTotal As MargeSalleInfos)
                MyBase.New()
                _Devis = Devis
                _Marges = Marges
                _MargeTotal = MargeTotal
            End Sub
        End Class
     
        Public Class RetourPage
            Public Property Rectangle As Rectangle
            Public Property Texte As String
            Public Property Writted As Boolean
            Public Sub New(Rectangle As Rectangle, Writted As Boolean)
                MyBase.New()
                _Rectangle = Rectangle
                _Texte = ""
                _Writted = Writted
            End Sub
            Public Sub New(Rectangle As Rectangle, Writted As Boolean, Texte As String)
                MyBase.New()
                _Rectangle = Rectangle
                _Texte = Texte
                _Writted = Writted
            End Sub
        End Class
     
        Dim WithEvents PDialg As PrintDialog
        Dim WithEvents PDoct As PrintDocument
     
        Dim Border As Rectangle
        Dim Taille As Point
     
        Dim M As Marge
        Dim BorderEpaisseur As Integer = 1
     
        Dim ColorBorderSalle As Brush = New SolidBrush(ColorTranslator.FromHtml("#b1a0c7"))
        Dim ColorBackSalleHeader As Brush = New SolidBrush(ColorTranslator.FromHtml("#60497a"))
        Dim ColorBackSalleTitle As Brush = New SolidBrush(ColorTranslator.FromHtml("#ccc0da"))
        Dim ColorBackSalle As Brush = New SolidBrush(ColorTranslator.FromHtml("#ebe7f1"))
     
        Dim ColorTextSalleHeader As Brush = New SolidBrush(Color.White)
        Dim ColorTextSalleTitle As Brush = ColorBackSalleHeader
        Dim ColorTextSalle As Brush = Brushes.Black
     
        Dim Police As String = "Arial"
     
     
        Public Sub New(Marge As Marge)
            MyBase.New()
     
            M = Marge
     
            PDialg = New PrintDialog
            PDoct = New PrintDocument
     
            ' Allow the user to choose the page range he or she would
            ' like to print.
            PDialg.AllowSomePages = False
            PDialg.AllowSelection = False
            PDialg.AllowSomePages = False
            PDialg.AllowCurrentPage = False
     
            ' Show the help button.
            PDialg.ShowHelp = True
     
            ' Set the Document property to the PrintDocument for 
            ' which the PrintPage Event has been handled. To display the
            ' dialog, either this property or the PrinterSettings property 
            ' must be set 
            PDialg.Document = _PDoct
     
            Dim result As DialogResult = PDialg.ShowDialog()
     
            ' If the result is OK then print the document.
            If (result = DialogResult.OK) Then
                PDoct.Print()
            End If
        End Sub
     
     
        Private Sub PDoct_PrintPage(sender As Object, e As System.Drawing.Printing.PrintPageEventArgs) Handles PDoct.PrintPage
            Dim hdc As System.IntPtr = e.Graphics.GetHdc
            e.Graphics.ReleaseHdc(hdc)
            e.Graphics.Clear(Color.White)
     
            Border = New Rectangle(CInt(e.PageSettings.HardMarginX) + 10, CInt(e.PageSettings.HardMarginY) + 10, CInt(e.PageSettings.HardMarginX) + 10, CInt(e.PageSettings.HardMarginY) + 10)
            Taille = New Point(CInt(e.Graphics.VisibleClipBounds.Width - Border.Right), CInt(e.Graphics.VisibleClipBounds.Height - Border.Bottom))
     
     
            If Not Print_Marge(e.Graphics, Border) Then
                e.HasMorePages = True
            End If
     
     
            Border = Nothing
            Taille = Nothing
        End Sub
     
        Private Function Print_Marge(G As Graphics, Depart As Rectangle) As Boolean
            Static NumeroPage As Integer = 0
            NumeroPage += 1
            Print_Header(G, Depart, NumeroPage)
     
            Static MEnCour As String = ""
            Static LEnCour As String = ""
     
            Dim WCol1 As Integer = CInt(Taille.X * 0.5)
            Dim WCol2 As Integer = CInt(Taille.X * 0.25) + BorderEpaisseur
            Dim WCol3 As Integer = Taille.X - WCol1 - WCol2 + (BorderEpaisseur * 2)
     
            Dim P As New Point(Depart.X, Depart.Y)
            Dim NP As RetourPage
            Dim Texte As String
            For Each T As MargeSalleInfos In M.Marges
                If Not MEnCour = "" And Not T.Nom = MEnCour Then Continue For
     
                Texte = T.Nom
                If LEnCour = "" Or LEnCour = Texte Then
                    NP = Print_Cell(G, New Point(P.X, P.Y), Taille.X, Texte, New Font(Police, 16, FontStyle.Bold), StringAlignment.Center, ColorBorderSalle, ColorBackSalleHeader, ColorTextSalleHeader, 50, True)
                    If Not NP.Writted Then
                        MEnCour = T.Nom
                        LEnCour = Texte
                        Return False
                    End If
                    P.Y = (NP.Rectangle.Y + NP.Rectangle.Height) - BorderEpaisseur
                    LEnCour = ""
                End If
     
                Texte = "Matériel"
                If LEnCour = "" Or LEnCour = Texte Then
                    NP = Print_Cell(G, New Point(P.X, P.Y), Taille.X, Texte, New Font(Police, 16, FontStyle.Bold), StringAlignment.Center, ColorBorderSalle, ColorBackSalleTitle, ColorTextSalleTitle)
                    If Not NP.Writted Then
                        MEnCour = T.Nom
                        LEnCour = Texte
                        Return False
                    End If
                    P.Y = (NP.Rectangle.Y + NP.Rectangle.Height) - BorderEpaisseur
                    LEnCour = ""
                End If
     
     
                Texte = "Prix de revient du matériel"
                If LEnCour = "" Or LEnCour = Texte Then
                    NP = Print_Cell(G, New Point(P.X, P.Y), WCol1, Texte, New Font(Police, 11), StringAlignment.Near, ColorBorderSalle, ColorBackSalle, ColorTextSalle, 25)
                    If Not NP.Writted Then
                        MEnCour = T.Nom
                        LEnCour = Texte
                        Return False
                    End If
                    P.X = (NP.Rectangle.X + NP.Rectangle.Width) - BorderEpaisseur
                    LEnCour = ""
     
                    NP = Print_Cell(G, New Point(P.X, P.Y), WCol2, "", New Font(Police, 11), StringAlignment.Near, ColorBorderSalle, ColorBackSalle, ColorTextSalle, 25)
                    P.X = (NP.Rectangle.X + NP.Rectangle.Width) - BorderEpaisseur
                    NP = Print_Cell(G, New Point(P.X, P.Y), WCol3, T.PrixRevient.ToString("C2"), New Font(Police, 11), StringAlignment.Far, ColorBorderSalle, ColorBackSalle, ColorTextSalle, 25)
                    P.X = Depart.X
                    P.Y = (NP.Rectangle.Y + NP.Rectangle.Height) - BorderEpaisseur
                End If
     
     
     
                Texte = "Marge"
                If LEnCour = "" Or LEnCour = Texte Then
                    NP = Print_Cell(G, New Point(P.X, P.Y), WCol1, Texte, New Font(Police, 11), StringAlignment.Near, ColorBorderSalle, ColorBackSalle, ColorTextSalle, 25)
                    If Not NP.Writted Then
                        MEnCour = T.Nom
                        LEnCour = Texte
                        Return False
                    End If
                    P.X = (NP.Rectangle.X + NP.Rectangle.Width) - BorderEpaisseur
                    LEnCour = ""
     
                    NP = Print_Cell(G, New Point(P.X, P.Y), WCol2, T.TxMarge.ToString("P2"), New Font(Police, 11), StringAlignment.Far, ColorBorderSalle, ColorBackSalle, ColorTextSalle, 25)
                    P.X = (NP.Rectangle.X + NP.Rectangle.Width) - BorderEpaisseur
                    NP = Print_Cell(G, New Point(P.X, P.Y), WCol3, (T.PrixCession - T.PrixRevient).ToString("C2"), New Font(Police, 11), StringAlignment.Far, ColorBorderSalle, ColorBackSalle, ColorTextSalle, 25)
                    P.X = Depart.X
                    P.Y = (NP.Rectangle.Y + NP.Rectangle.Height) - BorderEpaisseur
                End If
     
     
     
                Texte = "Prix de cession du matériel"
                If LEnCour = "" Or LEnCour = Texte Then
                    NP = Print_Cell(G, New Point(P.X, P.Y), WCol1, Texte, New Font(Police, 11, FontStyle.Bold), StringAlignment.Near, ColorBorderSalle, ColorBackSalle, ColorTextSalle, 25)
                    If Not NP.Writted Then
                        MEnCour = T.Nom
                        LEnCour = Texte
                        Return False
                    End If
                    P.X = (NP.Rectangle.X + NP.Rectangle.Width) - BorderEpaisseur
                    LEnCour = ""
     
                    NP = Print_Cell(G, New Point(P.X, P.Y), WCol2, "", New Font(Police, 11, FontStyle.Bold), StringAlignment.Far, ColorBorderSalle, ColorBackSalle, ColorTextSalle, 25)
                    P.X = (NP.Rectangle.X + NP.Rectangle.Width) - BorderEpaisseur
                    NP = Print_Cell(G, New Point(P.X, P.Y), WCol3, T.PrixCession.ToString("C2"), New Font(Police, 11, FontStyle.Bold), StringAlignment.Far, ColorBorderSalle, ColorBackSalle, ColorTextSalle, 25)
                    P.X = Depart.X
                    P.Y = (NP.Rectangle.Y + NP.Rectangle.Height) - BorderEpaisseur
                End If
     
     
     
     
     
                Texte = "Port et divers"
                If LEnCour = "" Or LEnCour = Texte Then
                    NP = Print_Cell(G, New Point(P.X, P.Y), Taille.X, Texte, New Font(Police, 16, FontStyle.Bold), StringAlignment.Center, ColorBorderSalle, ColorBackSalleTitle, ColorTextSalleTitle)
                    If Not NP.Writted Then
                        MEnCour = T.Nom
                        LEnCour = Texte
                        Return False
                    End If
                    P.Y = (NP.Rectangle.Y + NP.Rectangle.Height) - BorderEpaisseur
                    LEnCour = ""
                End If
     
     
                Texte = "PP"
                If LEnCour = "" Or LEnCour = Texte Then
                    NP = Print_Cell(G, New Point(P.X, P.Y), WCol1, Texte, New Font(Police, 11), StringAlignment.Near, ColorBorderSalle, ColorBackSalle, ColorTextSalle, 25)
                    If Not NP.Writted Then
                        MEnCour = T.Nom
                        LEnCour = Texte
                        Return False
                    End If
                    P.X = (NP.Rectangle.X + NP.Rectangle.Width) - BorderEpaisseur
                    LEnCour = ""
     
                    NP = Print_Cell(G, New Point(P.X, P.Y), WCol2, T.TxPP.ToString("P2"), New Font(Police, 11), StringAlignment.Far, ColorBorderSalle, ColorBackSalle, ColorTextSalle, 25)
                    P.X = (NP.Rectangle.X + NP.Rectangle.Width) - BorderEpaisseur
                    NP = Print_Cell(G, New Point(P.X, P.Y), WCol3, (T.PP).ToString("C2"), New Font(Police, 11), StringAlignment.Far, ColorBorderSalle, ColorBackSalle, ColorTextSalle, 25)
                    P.X = Depart.X
                    P.Y = (NP.Rectangle.Y + NP.Rectangle.Height) - BorderEpaisseur
                End If
     
     
                Texte = "Port achat"
                If LEnCour = "" Or LEnCour = Texte Then
                    NP = Print_Cell(G, New Point(P.X, P.Y), WCol1, "Port achat", New Font(Police, 11), StringAlignment.Near, ColorBorderSalle, ColorBackSalle, ColorTextSalle, 25)
                    If Not NP.Writted Then
                        MEnCour = T.Nom
                        LEnCour = Texte
                        Return False
                    End If
                    P.X = (NP.Rectangle.X + NP.Rectangle.Width) - BorderEpaisseur
                    LEnCour = ""
     
                    NP = Print_Cell(G, New Point(P.X, P.Y), WCol2, "", New Font(Police, 11), StringAlignment.Near, ColorBorderSalle, ColorBackSalle, ColorTextSalle, 25)
                    P.X = (NP.Rectangle.X + NP.Rectangle.Width) - BorderEpaisseur
                    NP = Print_Cell(G, New Point(P.X, P.Y), WCol3, T.PortAchat.ToString("C2"), New Font(Police, 11), StringAlignment.Far, ColorBorderSalle, ColorBackSalle, ColorTextSalle, 25)
                    P.X = Depart.X
                    P.Y = (NP.Rectangle.Y + NP.Rectangle.Height) - BorderEpaisseur
                End If
     
     
                Texte = "Port vente"
                If LEnCour = "" Or LEnCour = Texte Then
                    NP = Print_Cell(G, New Point(P.X, P.Y), WCol1, "Port vente", New Font(Police, 11), StringAlignment.Near, ColorBorderSalle, ColorBackSalle, ColorTextSalle, 25)
                    If Not NP.Writted Then
                        MEnCour = T.Nom
                        LEnCour = Texte
                        Return False
                    End If
                    P.X = (NP.Rectangle.X + NP.Rectangle.Width) - BorderEpaisseur
                    LEnCour = ""
     
                    NP = Print_Cell(G, New Point(P.X, P.Y), WCol2, "", New Font(Police, 11), StringAlignment.Near, ColorBorderSalle, ColorBackSalle, ColorTextSalle, 25)
                    P.X = (NP.Rectangle.X + NP.Rectangle.Width) - BorderEpaisseur
                    NP = Print_Cell(G, New Point(P.X, P.Y), WCol3, T.PortVente.ToString("C2"), New Font(Police, 11), StringAlignment.Far, ColorBorderSalle, ColorBackSalle, ColorTextSalle, 25)
                    P.X = Depart.X
                    P.Y = (NP.Rectangle.Y + NP.Rectangle.Height) - BorderEpaisseur
                End If
     
     
                Texte = "Divers"
                If LEnCour = "" Or LEnCour = Texte Then
                    NP = Print_Cell(G, New Point(P.X, P.Y), WCol1, Texte, New Font(Police, 11), StringAlignment.Near, ColorBorderSalle, ColorBackSalle, ColorTextSalle, 25)
                    If Not NP.Writted Then
                        MEnCour = T.Nom
                        LEnCour = Texte
                        Return False
                    End If
                    P.X = (NP.Rectangle.X + NP.Rectangle.Width) - BorderEpaisseur
                    LEnCour = ""
     
                    NP = Print_Cell(G, New Point(P.X, P.Y), WCol2, "", New Font(Police, 11), StringAlignment.Near, ColorBorderSalle, ColorBackSalle, ColorTextSalle, 25)
                    P.X = (NP.Rectangle.X + NP.Rectangle.Width) - BorderEpaisseur
                    NP = Print_Cell(G, New Point(P.X, P.Y), WCol3, T.Divers.ToString("C2"), New Font(Police, 11), StringAlignment.Far, ColorBorderSalle, ColorBackSalle, ColorTextSalle, 25)
                    P.X = Depart.X
                    P.Y = (NP.Rectangle.Y + NP.Rectangle.Height) - BorderEpaisseur
                End If
     
     
                Texte = "Total net HT livré, non monté"
                If LEnCour = "" Or LEnCour = Texte Then
                    NP = Print_Cell(G, New Point(P.X, P.Y), WCol1, Texte, New Font(Police, 11, FontStyle.Bold), StringAlignment.Near, ColorBorderSalle, ColorBackSalle, ColorTextSalle, 25)
                    If Not NP.Writted Then
                        MEnCour = T.Nom
                        LEnCour = Texte
                        Return False
                    End If
                    P.X = (NP.Rectangle.X + NP.Rectangle.Width) - BorderEpaisseur
                    LEnCour = ""
     
                    NP = Print_Cell(G, New Point(P.X, P.Y), WCol2, "", New Font(Police, 11, FontStyle.Bold), StringAlignment.Near, ColorBorderSalle, ColorBackSalle, ColorTextSalle, 25)
                    P.X = (NP.Rectangle.X + NP.Rectangle.Width) - BorderEpaisseur
                    NP = Print_Cell(G, New Point(P.X, P.Y), WCol3, T.TotalNet1.ToString("C2"), New Font(Police, 11, FontStyle.Bold), StringAlignment.Far, ColorBorderSalle, ColorBackSalle, ColorTextSalle, 25)
                    P.X = Depart.X
                    P.Y = (NP.Rectangle.Y + NP.Rectangle.Height) - BorderEpaisseur
                End If
     
     
     
     
     
                Texte = "Montage et location engin"
                If LEnCour = "" Or LEnCour = Texte Then
                    NP = Print_Cell(G, New Point(P.X, P.Y), Taille.X, Texte, New Font(Police, 16, FontStyle.Bold), StringAlignment.Center, ColorBorderSalle, ColorBackSalleTitle, ColorTextSalleTitle)
                    If Not NP.Writted Then
                        MEnCour = T.Nom
                        LEnCour = Texte
                        Return False
                    End If
                    P.Y = (NP.Rectangle.Y + NP.Rectangle.Height) - BorderEpaisseur
                    LEnCour = ""
                End If
     
     
     
     
                Texte = "Montage"
                If LEnCour = "" Or LEnCour = Texte Then
                    NP = Print_Cell(G, New Point(P.X, P.Y), WCol1, Texte, New Font(Police, 11), StringAlignment.Near, ColorBorderSalle, ColorBackSalle, ColorTextSalle, 25)
                    If Not NP.Writted Then
                        MEnCour = T.Nom
                        LEnCour = Texte
                        Return False
                    End If
                    P.X = (NP.Rectangle.X + NP.Rectangle.Width) - BorderEpaisseur
                    LEnCour = ""
     
                    NP = Print_Cell(G, New Point(P.X, P.Y), WCol2, IIf(T.OptMontage, "En option", "").ToString, New Font(Police, 11), StringAlignment.Near, ColorBorderSalle, ColorBackSalle, ColorTextSalle, 25)
                    P.X = (NP.Rectangle.X + NP.Rectangle.Width) - BorderEpaisseur
                    NP = Print_Cell(G, New Point(P.X, P.Y), WCol3, T.Montage.ToString("C2"), New Font(Police, 11), StringAlignment.Far, ColorBorderSalle, ColorBackSalle, ColorTextSalle, 25)
                    P.X = Depart.X
                    P.Y = (NP.Rectangle.Y + NP.Rectangle.Height) - BorderEpaisseur
                End If
     
     
                Texte = "Location d'engins de manutention"
                If LEnCour = "" Or LEnCour = Texte Then
                    NP = Print_Cell(G, New Point(P.X, P.Y), WCol1, Texte, New Font(Police, 11), StringAlignment.Near, ColorBorderSalle, ColorBackSalle, ColorTextSalle, 25)
                    If Not NP.Writted Then
                        MEnCour = T.Nom
                        LEnCour = Texte
                        Return False
                    End If
                    P.X = (NP.Rectangle.X + NP.Rectangle.Width) - BorderEpaisseur
                    LEnCour = ""
     
                    NP = Print_Cell(G, New Point(P.X, P.Y), WCol2, IIf(T.OptEngin, "En option", "").ToString, New Font(Police, 11), StringAlignment.Near, ColorBorderSalle, ColorBackSalle, ColorTextSalle, 25)
                    P.X = (NP.Rectangle.X + NP.Rectangle.Width) - BorderEpaisseur
                    NP = Print_Cell(G, New Point(P.X, P.Y), WCol3, T.Montage.ToString("C2"), New Font(Police, 11), StringAlignment.Far, ColorBorderSalle, ColorBackSalle, ColorTextSalle, 25)
                    P.X = Depart.X
                    P.Y = (NP.Rectangle.Y + NP.Rectangle.Height) - BorderEpaisseur
                End If
     
     
                Texte = "Total net HT livré, monté"
                If LEnCour = "" Or LEnCour = Texte Then
                    NP = Print_Cell(G, New Point(P.X, P.Y), WCol1, Texte, New Font(Police, 11, FontStyle.Bold), StringAlignment.Near, ColorBorderSalle, ColorBackSalle, ColorTextSalle, 25)
                    If Not NP.Writted Then
                        MEnCour = T.Nom
                        LEnCour = Texte
                        Return False
                    End If
                    P.X = (NP.Rectangle.X + NP.Rectangle.Width) - BorderEpaisseur
                    LEnCour = ""
     
                    NP = Print_Cell(G, New Point(P.X, P.Y), WCol2, "", New Font(Police, 11, FontStyle.Bold), StringAlignment.Near, ColorBorderSalle, ColorBackSalle, ColorTextSalle, 25)
                    P.X = (NP.Rectangle.X + NP.Rectangle.Width) - BorderEpaisseur
                    NP = Print_Cell(G, New Point(P.X, P.Y), WCol3, T.TotalNet2.ToString("C2"), New Font(Police, 11, FontStyle.Bold), StringAlignment.Far, ColorBorderSalle, ColorBackSalle, ColorTextSalle, 25)
                    P.X = Depart.X
                    P.Y = (NP.Rectangle.Y + NP.Rectangle.Height) - BorderEpaisseur
                End If
     
     
     
                P.X = Depart.X
                P.Y += 50
     
                MEnCour = ""
                LEnCour = ""
                NumeroPage = 0
            Next
     
            Return True
        End Function
     
     
     
     
        Private Function Print_Cell(G As Graphics, Position As Point, Width As Integer, Texte As String, Font As Font, Alignement As StringAlignment, BorderColor As Brush, BackColor As Brush, ForeColor As Brush, Optional Heigth As Integer = 0, Optional Multiligne As Boolean = True) As RetourPage
            Dim ST1 As SizeF = G.MeasureString(Texte, Font)
            Dim ST2 As SizeF = G.MeasureString(Texte, Font, Width)
     
            Dim H As Integer = Heigth
            If H = 0 Then
                H = CInt(ST1.Height)
                If Multiligne AndAlso ST2.Height > ST1.Height Then
                    H = CInt(ST2.Height)
                End If
            End If
     
            If Position.Y + H > Taille.Y Then
                Return (New RetourPage(Nothing, False))
            End If
     
            Dim Rectangle As New Rectangle(Position.X, Position.Y, Width, H)
            Dim Interieur As Rectangle
            If BorderColor Is Nothing Then
                Interieur = Rectangle
            Else
                G.FillRectangle(BorderColor, Rectangle)
                Interieur = New Rectangle(Rectangle.X + BorderEpaisseur, Rectangle.Y + BorderEpaisseur, Rectangle.Width - BorderEpaisseur * 2, Rectangle.Height - BorderEpaisseur * 2)
            End If
            G.FillRectangle(BackColor, Interieur)
     
            Dim F As New StringFormat
            F.Alignment = Alignement
            F.LineAlignment = StringAlignment.Center
            If Multiligne Then
                G.DrawString(Texte, Font, ForeColor, Interieur, F)
            Else
                G.DrawString(Texte, Font, ForeColor, Interieur.X, Interieur.Y, F)
            End If
     
            Return New RetourPage(Rectangle, True, Texte)
        End Function
     
     
        Private Function Print_Texte(G As Graphics, Position As Point, Width As Integer, Texte As String, Font As Font, Alignement As StringAlignment, ForeColor As Brush, Optional Heigth As Integer = 0, Optional Multiligne As Boolean = True) As RetourPage
            Dim ST1 As SizeF = G.MeasureString(Texte, Font)
            Dim ST2 As SizeF = G.MeasureString(Texte, Font, Width)
     
            Dim H As Integer = Heigth
            If H = 0 Then
                H = CInt(ST1.Height)
                If Multiligne AndAlso ST2.Height > ST1.Height Then
                    H = CInt(ST2.Height)
                End If
            End If
     
            If Position.Y + H > Taille.Y Then
                Return (New RetourPage(Nothing, False))
            End If
     
            Dim Rectangle As New Rectangle(Position.X, Position.Y, Width, H)
            Dim F As New StringFormat
            F.Alignment = Alignement
            F.LineAlignment = StringAlignment.Center
            If Multiligne Then
                G.DrawString(Texte, Font, ForeColor, Rectangle, F)
            Else
                G.DrawString(Texte, Font, ForeColor, Rectangle.X, Rectangle.Y, F)
            End If
     
            Return New RetourPage(Rectangle, True, Texte)
        End Function
     
     
        Private Function Print_Header(G As Graphics, ByRef Position As Rectangle, NumeroPage As Integer) As Rectangle
            Dim I As Bitmap = My.Resources.logo_ettax
            Dim R As New Rectangle(Position.X, Position.Y, CInt(I.Width * 0.2), CInt(I.Height * 0.2))
            G.DrawImage(My.Resources.logo_ettax, R)
     
     
            Dim P As Rectangle = Position
            P.X = 450
            P.Y += 25
     
            Dim NP As RetourPage
     
            NP = Print_Texte(G, New Point(P.X, P.Y), Taille.X - P.X, "N° devis : " + M.Devis.Numero_Devis, New Font(Police, 11, FontStyle.Bold), StringAlignment.Near, ColorTextSalle, 25, True)
            P.Y = NP.Rectangle.Y + NP.Rectangle.Height
            NP = Print_Texte(G, New Point(P.X, P.Y), Taille.X - P.X, "Client : " + M.Devis.Client.Raison_Sociale, New Font(Police, 11, FontStyle.Bold), StringAlignment.Near, ColorTextSalle, 25, True)
            P.Y = NP.Rectangle.Y + NP.Rectangle.Height
            NP = Print_Texte(G, New Point(P.X, P.Y), Taille.X - P.X, "Commercial : " + M.Devis.Commercial.Nom + " " + M.Devis.Commercial.Prenom, New Font(Police, 11, FontStyle.Bold), StringAlignment.Near, ColorTextSalle, 25, True)
            P.Y = NP.Rectangle.Y + NP.Rectangle.Height
            NP = Print_Texte(G, New Point(P.X, P.Y), Taille.X - P.X, "Page " + NumeroPage.ToString + " sur ", New Font(Police, 11, FontStyle.Bold), StringAlignment.Near, ColorTextSalle, 25, True)
     
            Position.Y = R.Y + R.Height + 50
     
            P = Position
            NP = Print_Texte(G, New Point(P.X, P.Y), Taille.X - P.X, "RECAPITULATIF - FEUILLE DE MARGE", New Font(Police, 20, FontStyle.Bold Or FontStyle.Underline), StringAlignment.Center, ColorTextSalle, 25, True)
     
            Position.Y = NP.Rectangle.Y + NP.Rectangle.Height + 20
        End Function
     
     
     
     
     
     
     
    End Class
    Images attachées Images attachées

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. Réponses: 2
    Dernier message: 13/09/2011, 11h35
  2. Réponses: 2
    Dernier message: 14/10/2010, 23h17
  3. Réponses: 4
    Dernier message: 24/04/2009, 20h08
  4. avoir la page actuelle et le nombre de page total ?
    Par ikbybaka dans le forum iReport
    Réponses: 1
    Dernier message: 17/04/2009, 10h43
  5. [JASPER] Condition sur le nombre de page
    Par Piolet dans le forum Jasper
    Réponses: 0
    Dernier message: 26/02/2009, 17h29

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo