السلام عليكم ورحمة اللة وبركاتة
اريد كود لطباعة محتوي نصي بدون كريستال ريبورت فقط printdocument , printpreview
عبارة عن ليبل اريد نقل محتواة او لايناتة الي صفحة الطباعة وعند تخطي محتواة قاعدة الصفحة ب 20 m ينتقل الي الصفحة التالية المحتوي مختلف وليس محدد
ممكن يكون لاين او 20 او 15 حسب العمليات ويكون اليبل باطارة ووضع لوجو اسفلة وينتقل معة الي الصفحة التالية لو تخطي هو ايضا قاعدة الصفحة
انا استخدمت هذا الكود ولكن يقطع قاعدة الصفحة الاولي وينتقل الي قاعدة الصفحة التالية وليس اعلي الصفحة
Static Lines() As String = Label1.Text.Split(vbCrLf)
Static Font As New Font("Arial", 10, FontStyle.Regular, GraphicsUnit.Pixel)
Static I As Integer
Dim bmp As System.Drawing.Bitmap
bmp = PictureBox1.Image
Dim VerticalPos As Integer = 1000
Do
e.Graphics.DrawString(Lines(I), Font, Brushes.Black, 200, VerticalPos)
I += 1
VerticalPos += Font.Height
e.Graphics.DrawImage(bmp, 200, VerticalPos + 100)
If VerticalPos > e.PageBounds.Bottom Then
e.Graphics.DrawImage(bmp, 200, VerticalPos)
e.HasMorePages = True
Return
End If
Loop Until I = Lines.Length
End Sub
(31-10-17, 09:39 PM)a.ahmed كتب : [ -> ]PHP كود :
Public Class Form1
Dim TextLines() As String
Dim TotalPages As Integer = 0
Dim PageNo As Integer = 0
Dim LinesPerPage As Integer = 5
Private Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button1.Click
TextLines = Label1.Text.Trim.Split(vbCrLf)
TotalPages = Math.Ceiling(TextLines.Count / LinesPerPage)
PageNo = 1
PrintPreviewDialog1.ShowDialog()
End Sub
Private Sub PrintDocument1_PrintPage(ByVal sender As Object, ByVal e As Printing.PrintPageEventArgs) Handles PrintDocument1.PrintPage
Dim VerticalPos As Single = 1000
Dim fnt As New Font("Arial", 10)
Dim lineHeight As Single = fnt.Height()
Dim bmp As Bitmap = PictureBox1.Image()
e.Graphics.DrawImage(bmp, New Rectangle(New Point(200, VerticalPos), New Size(500, 100)))
For i = 0 To LinesPerPage - 1
Dim lineIndex As Integer = ((PageNo - 1) * LinesPerPage) + i
If lineIndex = TextLines.Count Then Exit For
Dim y As Single = VerticalPos + (i * lineHeight)
Dim txt As String = TextLines(lineIndex).Trim()
e.Graphics.DrawString(txt, fnt, Brushes.Black, New Point(100, y))
Next
If PageNo < TotalPages Then
PageNo += 1
e.HasMorePages = True
End If
End Sub
End Class
تبقي جزء من المشكلة عند الدخول لصفحة جديدة يطبع يكمل الاين الخاص باليبل بقاعدة الصفحة الثانية والثالثة وليس براس ومقدمة الصفحة