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
| Try
Dim g As Graphics = e.Graphics
'On récupère la page courante comme page à imprimer
Dim PageNumber As Integer = Form1.panel_scrollNavigator.Controls.GetChildIndex(pagesToPrint(nbSheets))
'On récupère le control
Dim ctrl As Page = Form1.panel_scroll.GetPage(PageNumber + 1)
'Niveau de détail du texte
g.TextRenderingHint = Drawing.Text.TextRenderingHint.AntiAlias
'On charge l'image en cours
Dim img As System.Drawing.Bitmap = = DirectCast(Image.FromFile(Form1.TempPath + "\" + ctrl.Name + ".png"), Bitmap)
'On défini les bordures de la page
Dim pageBorder As New Rectangle(e.PageBounds.Left, e.PageBounds.Top, e.PageBounds.Width, e.PageBounds.Height)
'On défini le nouveau ratio de la page pour l'impression des textes
Form1.Ratio = CSng(System.Math.Sqrt(System.Math.Pow(pageBorder.Height, 2) + System.Math.Pow(pageBorder.Width, 2)) / _
System.Math.Sqrt(System.Math.Pow(ctrl.Height, 2) + System.Math.Pow(ctrl.Width, 2)))
'Et on dessine notre image et nos textes sur le graphic actuel
g.InterpolationMode = Drawing2D.InterpolationMode.HighQualityBicubic
g.DrawImage(img, 0, 0, pageBorder.Width, pageBorder.Height)
ctrl.PaintMe(g, Form1.PreviewMode.Preview) ' , ratio)
img.Dispose()
GC.Collect()
If nbSheets = pdi.PrinterSettings.ToPage - 1 Then
hasMorePages = False
e.HasMorePages = False
Else
nbSheets += 1
hasMorePages = True
e.HasMorePages = True
End If
Catch ex As Exception
MsgBox(ex.Message)
hasMorePages = False
End Try |
Partager