منتدى فيجوال بيسك لكل العرب | منتدى المبرمجين العرب

نسخة كاملة : مشكله عند طباعه الباركود الكتابة تظهر بهتة في خيال والنقاط قريبه من بعض غيرت الفونت
أنت حالياً تتصفح نسخة خفيفة من المنتدى . مشاهدة نسخة كاملة مع جميع الأشكال الجمالية .
الصفحات : 1 2
مشكله عند طباعه الباركود الكتابة تظهر بهتة في خيال والنقاط قريبه من بعض غيرت الفونت

هذا هو الخط المستخد للكتابه فوق الباركود جربت اكثر من نوع خط والكتابه غير وضحه كان جودة الصورة قليله

كود :
     Dim drawFont As New Font("Arial", 8)
       Dim drawBrush As New SolidBrush(Color.Black)

       ' Create rectangle for drawing.
       Dim x As Single = 0.0F
       Dim y As Single = 0.0F
       Dim width As Single = 75.0F
       Dim height As Single = 25.0F
       Dim drawRect As New RectangleF(x, y, width, height)

       ' Draw rectangle to screen.
       'Dim blackPen As New Pen(Color.Black)
       'GraphZ.DrawRectangle(blackPen, x, y, width, height)

       ' Set format of string.
       Dim drawFormat As New StringFormat
       drawFormat.Alignment = StringAlignment.Far

       ' Draw string to screen.
       GraphZ.DrawString(Kind, drawFont, drawBrush,
   drawRect, drawFormat)


وهذه الاكواد المستدخمه كامله للباركود
كود :
Public Class barcode2
   Dim PrintDoc As Printing.PrintDocument = New Printing.PrintDocument()
   Dim pd_PrintDialog As New PrintDialog

   Private Sub PrintDocHandler(ByVal sender As Object, ByVal ev As Printing.PrintPageEventArgs)
       ev.Graphics.DrawImage(PicBarCode.BackgroundImage, nud_MarginH.Value, nud_MarginW.Value, nud_MarginWBrcode.Value, nud_MarginHBrcode.Value)

   End Sub

   Function Code128(ByVal TheText As String, ByVal CodeLetter As String, Optional Font As Font = Nothing, Optional Price As String = Nothing, Optional ByVal Kind As String = Nothing, Optional ByVal Company As String = Nothing) As Image

       ' TheText متغير خاص بالنص المراد تشفيره
       ' CodeLetter متغير خاص بالفئة المراد استخدامها

       Dim Binaryz As String = "" 'متغير سيحمل النص بعد تحويله إلى باينرى
       Dim I As Integer
       Dim NumCode As Integer 'متغير سيحمل  قيمة حساب النص التكميلى
       If CodeLetter = "A" Or CodeLetter = "a" Then
           NumCode = 103
           Binaryz = "00101111011"
       End If
       If CodeLetter = "B" Or CodeLetter = "b" Then
           NumCode = 104
           Binaryz = "00101101111"
       End If
       If CodeLetter = "C" Or CodeLetter = "c" Then
           NumCode = 105
           Binaryz = "00101100011"
       End If
       ' الكود التالى سيقوم باسناد قيمة الحرف بالباينرى حسب الجدول الخاص بالكود 128
       For I = 1 To Len(TheText)
           NumCode = NumCode + ((Asc(Mid(TheText, I, 1)) - 32) * I)
           Select Case Asc(Mid(TheText, I, 1))
               Case 32
                   Binaryz = Binaryz & "00100110011"
               Case 33
                   Binaryz = Binaryz & "00110010011"
               Case 34
                   Binaryz = Binaryz & "00110011001"
               Case 35
                   Binaryz = Binaryz & "01101100111"
               Case 36
                   Binaryz = Binaryz & "01101110011"
               Case 37
                   Binaryz = Binaryz & "01110110011"
               Case 38
                   Binaryz = Binaryz & "01100110111"
               Case 39
                   Binaryz = Binaryz & "01100111011"
               Case 40
                   Binaryz = Binaryz & "01110011011"
               Case 41
                   Binaryz = Binaryz & "00110110111"
               Case 42
                   Binaryz = Binaryz & "00110111011"
               Case 43
                   Binaryz = Binaryz & "00111011011"
               Case 44
                   Binaryz = Binaryz & "01001100011"
               Case 45
                   Binaryz = Binaryz & "01100100011"
               Case 46
                   Binaryz = Binaryz & "01100110001"
               Case 47
                   Binaryz = Binaryz & "01000110011"
               Case 48
                   Binaryz = Binaryz & "01100010011"
               Case 49
                   Binaryz = Binaryz & "01100011001"
               Case 50
                   Binaryz = Binaryz & "00110001101"
               Case 51
                   Binaryz = Binaryz & "00110100011"
               Case 52
                   Binaryz = Binaryz & "00110110001"
               Case 53
                   Binaryz = Binaryz & "00100011011"
               Case 54
                   Binaryz = Binaryz & "00110001011"
               Case 55
                   Binaryz = Binaryz & "00010010001"
               Case 56
                   Binaryz = Binaryz & "00010110011"
               Case 57
                   Binaryz = Binaryz & "00011010011"
               Case 58
                   Binaryz = Binaryz & "00011011001"
               Case 59
                   Binaryz = Binaryz & "00010011011"
               Case 60
                   Binaryz = Binaryz & "00011001011"
               Case 61
                   Binaryz = Binaryz & "00011001101"
               Case 62
                   Binaryz = Binaryz & "00100100111"
               Case 63
                   Binaryz = Binaryz & "00100111001"
               Case 64
                   Binaryz = Binaryz & "00111001001"
               Case 65
                   Binaryz = Binaryz & "01011100111"
               Case 66
                   Binaryz = Binaryz & "01110100111"
               Case 67
                   Binaryz = Binaryz & "01110111001"
               Case 68
                   Binaryz = Binaryz & "01001110111"
               Case 69
                   Binaryz = Binaryz & "01110010111"
               Case 70
                   Binaryz = Binaryz & "01110011101"
               Case 71
                   Binaryz = Binaryz & "00101110111"
               Case 72
                   Binaryz = Binaryz & "00111010111"
               Case 73
                   Binaryz = Binaryz & "00111011101"
               Case 74
                   Binaryz = Binaryz & "01001000111"
               Case 75
                   Binaryz = Binaryz & "01001110001"
               Case 76
                   Binaryz = Binaryz & "01110010001"
               Case 77
                   Binaryz = Binaryz & "01000100111"
               Case 78
                   Binaryz = Binaryz & "01000111001"
               Case 79
                   Binaryz = Binaryz & "01110001001"
               Case 80
                   Binaryz = Binaryz & "00010001001"
               Case 81
                   Binaryz = Binaryz & "00101110001"
               Case 82
                   Binaryz = Binaryz & "00111010001"
               Case 83
                   Binaryz = Binaryz & "00100010111"
               Case 84
                   Binaryz = Binaryz & "00100011101"
               Case 85
                   Binaryz = Binaryz & "00100010001"
               Case 86
                   Binaryz = Binaryz & "00010100111"
               Case 87
                   Binaryz = Binaryz & "00010111001"
               Case 88
                   Binaryz = Binaryz & "00011101001"
               Case 89
                   Binaryz = Binaryz & "00010010111"
               Case 90
                   Binaryz = Binaryz & "00010011101"
               Case 91
                   Binaryz = Binaryz & "00011100101"
               Case 92
                   Binaryz = Binaryz & "00010000101"
               Case 93
                   Binaryz = Binaryz & "00110111101"
               Case 94
                   Binaryz = Binaryz & "00001110101"
               Case 95
                   Binaryz = Binaryz & "01011001111"
               Case 96
                   Binaryz = Binaryz & "01011110011"
               Case 97
                   Binaryz = Binaryz & "01101001111"
               Case 98
                   Binaryz = Binaryz & "01101111001"
               Case 99
                   Binaryz = Binaryz & "01111010011"
               Case 100
                   Binaryz = Binaryz & "01111011001"
               Case 101
                   Binaryz = Binaryz & "01001101111"
               Case 102
                   Binaryz = Binaryz & "01001111011"
               Case 103
                   Binaryz = Binaryz & "01100101111"
               Case 104
                   Binaryz = Binaryz & "01100111101"
               Case 105
                   Binaryz = Binaryz & "01111001011"
               Case 106
                   Binaryz = Binaryz & "01111001101"
               Case 107
                   Binaryz = Binaryz & "00111101101"
               Case 108
                   Binaryz = Binaryz & "00110101111"
               Case 109
                   Binaryz = Binaryz & "00001000101"
               Case 110
                   Binaryz = Binaryz & "00111101011"
               Case 111
                   Binaryz = Binaryz & "01110000101"
               Case 112
                   Binaryz = Binaryz & "01011000011"
               Case 113
                   Binaryz = Binaryz & "01101000011"
               Case 114
                   Binaryz = Binaryz & "01101100001"
               Case 115
                   Binaryz = Binaryz & "01000011011"
               Case 116
                   Binaryz = Binaryz & "01100001011"
               Case 117
                   Binaryz = Binaryz & "01100001101"
               Case 118
                   Binaryz = Binaryz & "00001011011"
               Case 119
                   Binaryz = Binaryz & "00001101011"
               Case 120
                   Binaryz = Binaryz & "00001101101"
               Case 121
                   Binaryz = Binaryz & "00100100001"
               Case 122
                   Binaryz = Binaryz & "00100001001"
               Case 123
                   Binaryz = Binaryz & "00001001001"
               Case 124
                   Binaryz = Binaryz & "01010000111"
               Case 125
                   Binaryz = Binaryz & "01011100001"
               Case 126
                   Binaryz = Binaryz & "01110100001"
               Case 127
                   Binaryz = Binaryz & "01000010111"
               Case 128
                   Binaryz = Binaryz & "01000011101"
               Case 129
                   Binaryz = Binaryz & "00001010111"
               Case 130
                   Binaryz = Binaryz & "00001011101"
               Case 131
                   Binaryz = Binaryz & "01000100001"
               Case 132
                   Binaryz = Binaryz & "01000010001"
               Case 133
                   Binaryz = Binaryz & "00010100001"
               Case 134
                   Binaryz = Binaryz & "00001010001"
               Case 135
                   Binaryz = Binaryz & "00101111011"
               Case 136
                   Binaryz = Binaryz & "00101101111"
               Case 137
                   Binaryz = Binaryz & "00101100011"
               Case 138
                   Binaryz = Binaryz & "0011100010100"
           End Select
       Next
       NumCode = NumCode Mod 103
       ' الكود التالى لمعرفة الحرف المراد اضافتة لاستكمال النص
       Select Case NumCode
           Case 0
               Binaryz = Binaryz & "00100110011"
           Case 1
               Binaryz = Binaryz & "00110010011"
           Case 2
               Binaryz = Binaryz & "00110011001"
           Case 3
               Binaryz = Binaryz & "01101100111"
           Case 4
               Binaryz = Binaryz & "01101110011"
           Case 5
               Binaryz = Binaryz & "01110110011"
           Case 6
               Binaryz = Binaryz & "01100110111"
           Case 7
               Binaryz = Binaryz & "01100111011"
           Case 8
               Binaryz = Binaryz & "01110011011"
           Case 9
               Binaryz = Binaryz & "00110110111"
           Case 10
               Binaryz = Binaryz & "00110111011"
           Case 11
               Binaryz = Binaryz & "00111011011"
           Case 12
               Binaryz = Binaryz & "01001100011"
           Case 13
               Binaryz = Binaryz & "01100100011"
           Case 14
               Binaryz = Binaryz & "01100110001"
           Case 15
               Binaryz = Binaryz & "01000110011"
           Case 16
               Binaryz = Binaryz & "01100010011"
           Case 17
               Binaryz = Binaryz & "01100011001"
           Case 18
               Binaryz = Binaryz & "00110001101"
           Case 19
               Binaryz = Binaryz & "00110100011"
           Case 20
               Binaryz = Binaryz & "00110110001"
           Case 21
               Binaryz = Binaryz & "00100011011"
           Case 22
               Binaryz = Binaryz & "00110001011"
           Case 23
               Binaryz = Binaryz & "00010010001"
           Case 24
               Binaryz = Binaryz & "00010110011"
           Case 25
               Binaryz = Binaryz & "00011010011"
           Case 26
               Binaryz = Binaryz & "00011011001"
           Case 27
               Binaryz = Binaryz & "00010011011"
           Case 28
               Binaryz = Binaryz & "00011001011"
           Case 29
               Binaryz = Binaryz & "00011001101"
           Case 30
               Binaryz = Binaryz & "00100100111"
           Case 31
               Binaryz = Binaryz & "00100111001"
           Case 32
               Binaryz = Binaryz & "00111001001"
           Case 33
               Binaryz = Binaryz & "01011100111"
           Case 34
               Binaryz = Binaryz & "01110100111"
           Case 35
               Binaryz = Binaryz & "01110111001"
           Case 36
               Binaryz = Binaryz & "01001110111"
           Case 37
               Binaryz = Binaryz & "01110010111"
           Case 38
               Binaryz = Binaryz & "01110011101"
           Case 39
               Binaryz = Binaryz & "00101110111"
           Case 40
               Binaryz = Binaryz & "00111010111"
           Case 41
               Binaryz = Binaryz & "00111011101"
           Case 42
               Binaryz = Binaryz & "01001000111"
           Case 43
               Binaryz = Binaryz & "01001110001"
           Case 44
               Binaryz = Binaryz & "01110010001"
           Case 45
               Binaryz = Binaryz & "01000100111"
           Case 46
               Binaryz = Binaryz & "01000111001"
           Case 47
               Binaryz = Binaryz & "01110001001"
           Case 48
               Binaryz = Binaryz & "00010001001"
           Case 49
               Binaryz = Binaryz & "00101110001"
           Case 50
               Binaryz = Binaryz & "00111010001"
           Case 51
               Binaryz = Binaryz & "00100010111"
           Case 52
               Binaryz = Binaryz & "00100011101"
           Case 53
               Binaryz = Binaryz & "00100010001"
           Case 54
               Binaryz = Binaryz & "00010100111"
           Case 55
               Binaryz = Binaryz & "00010111001"
           Case 56
               Binaryz = Binaryz & "00011101001"
           Case 57
               Binaryz = Binaryz & "00010010111"
           Case 58
               Binaryz = Binaryz & "00010011101"
           Case 59
               Binaryz = Binaryz & "00011100101"
           Case 60
               Binaryz = Binaryz & "00010000101"
           Case 61
               Binaryz = Binaryz & "00110111101"
           Case 62
               Binaryz = Binaryz & "00001110101"
           Case 63
               Binaryz = Binaryz & "01011001111"
           Case 64
               Binaryz = Binaryz & "01011110011"
           Case 65
               Binaryz = Binaryz & "01101001111"
           Case 66
               Binaryz = Binaryz & "01101111001"
           Case 67
               Binaryz = Binaryz & "01111010011"
           Case 68
               Binaryz = Binaryz & "01111011001"
           Case 69
               Binaryz = Binaryz & "01001101111"
           Case 70
               Binaryz = Binaryz & "01001111011"
           Case 71
               Binaryz = Binaryz & "01100101111"
           Case 72
               Binaryz = Binaryz & "01100111101"
           Case 73
               Binaryz = Binaryz & "01111001011"
           Case 74
               Binaryz = Binaryz & "01111001101"
           Case 75
               Binaryz = Binaryz & "00111101101"
           Case 76
               Binaryz = Binaryz & "00110101111"
           Case 77
               Binaryz = Binaryz & "00001000101"
           Case 78
               Binaryz = Binaryz & "00111101011"
           Case 79
               Binaryz = Binaryz & "01110000101"
           Case 80
               Binaryz = Binaryz & "01011000011"
           Case 81
               Binaryz = Binaryz & "01101000011"
           Case 82
               Binaryz = Binaryz & "01101100001"
           Case 83
               Binaryz = Binaryz & "01000011011"
           Case 84
               Binaryz = Binaryz & "01100001011"
           Case 85
               Binaryz = Binaryz & "01100001101"
           Case 86
               Binaryz = Binaryz & "00001011011"
           Case 87
               Binaryz = Binaryz & "00001101011"
           Case 88
               Binaryz = Binaryz & "00001101101"
           Case 89
               Binaryz = Binaryz & "00100100001"
           Case 90
               Binaryz = Binaryz & "00100001001"
           Case 91
               Binaryz = Binaryz & "00001001001"
           Case 92
               Binaryz = Binaryz & "01010000111"
           Case 93
               Binaryz = Binaryz & "01011100001"
           Case 94
               Binaryz = Binaryz & "01110100001"
           Case 95
               Binaryz = Binaryz & "01000010111"
           Case 96
               Binaryz = Binaryz & "01000011101"
           Case 97
               Binaryz = Binaryz & "00001010111"
           Case 98
               Binaryz = Binaryz & "00001011101"
           Case 99
               Binaryz = Binaryz & "01000100001"
           Case 100
               Binaryz = Binaryz & "01000010001"
           Case 101
               Binaryz = Binaryz & "00010100001"
           Case 102
               Binaryz = Binaryz & "00001010001"
       End Select
       Binaryz = Binaryz & "0011100010100" ' انهاء الكود باضافة الباينرى الخاص بايقاف جميع الاكواد

       ' انشاء صورة عرضها عدد حروف الباينرى المستخدم
       Dim bmp As Bitmap = New Bitmap(Len(Binaryz), 80, System.Drawing.Imaging.PixelFormat.Format24bppRgb)
       Dim z As String ' متغير لمعرفة لون الخط
       Dim GraphZ As Graphics = Graphics.FromImage(bmp)
       Dim RectZ As Rectangle = New Rectangle(0, 0, bmp.Width, bmp.Height) ' مستطيل بحجم الصورة لاعطاء الخلفية باللون الابيض
       ' فرشاه لدهان المستطيل السابق باللون الابيض
       Dim myBrush As Brush = New Drawing.Drawing2D.LinearGradientBrush(RectZ, Color.White, Color.White, Drawing.Drawing2D.LinearGradientMode.ForwardDiagonal)
       ' دهان المستطيل السابق باللون الابيض
       GraphZ.FillRectangle(myBrush, RectZ)
       '  رسم خطوط الباركود
       Dim PenZ As Pen
       Dim point1 As Point ' نقطة بداية الخط
       Dim point2 As Point ' نقطة نهاية الخط
       For I = 1 To Len(Binaryz)
           z = Mid(Binaryz, I, 1)
           If z = "0" Then
               PenZ = New Pen(Color.Black, 1)
               point1 = New Point(I, 26)
               point2 = New Point(I, 39)
               GraphZ.DrawLine(PenZ, point1, point2)
           Else
               PenZ = New Pen(Color.White, 1)
               point1 = New Point(I, 0)
               point2 = New Point(I, 0)
               GraphZ.DrawLine(PenZ, point1, point2)
           End If
       Next
       ' رسم النص المراد ترميزه اسفل الكود
       'Dim Font3 = New Font(Font.FontFamily, Font.Size + 3, FontStyle.Bold)
       'GraphZ.DrawString(TheText, Font3, New SolidBrush(Color.Black), 0, 70)

       'GraphZ.DrawString(TheText, New Font("times new roman", 9, FontStyle.Bold), New SolidBrush(Color.Black), 50, 40)
       '  Dim format1 As New StringFormat(StringFormatFlags.NoClip)
       '  format1.Alignment = StringAlignment.Center
       '  GraphZ.DrawString(Kind, New Font("times new roman", 12, FontStyle.Bold), New SolidBrush(Color.Black), 0, 3)
       GraphZ.DrawString(Price, New Font("times new roman", 8, FontStyle.Bold), New SolidBrush(Color.Black), 0, 40)
       ' GraphZ.DrawString(Company, New Font("times new roman", 12, FontStyle.Bold), New SolidBrush(Color.Black), 0, 50)

       '  GraphZ.DrawString(TheText, New Font(Form1.ComboBox1.Text, 12, FontStyle.Bold), New SolidBrush(Color.Black), 0, 50)



       ' Create string to draw.
       Dim drawString As [String] = "Sample Text"

       ' Create font and brush.
       Dim drawFont As New Font("Arial", 8)
       Dim drawBrush As New SolidBrush(Color.Black)

       ' Create rectangle for drawing.
       Dim x As Single = 0.0F
       Dim y As Single = 0.0F
       Dim width As Single = 75.0F
       Dim height As Single = 25.0F
       Dim drawRect As New RectangleF(x, y, width, height)

       ' Draw rectangle to screen.
       'Dim blackPen As New Pen(Color.Black)
       'GraphZ.DrawRectangle(blackPen, x, y, width, height)

       ' Set format of string.
       Dim drawFormat As New StringFormat
       drawFormat.Alignment = StringAlignment.Far

       ' Draw string to screen.
       GraphZ.DrawString(Kind, drawFont, drawBrush,
   drawRect, drawFormat)


       ' رسم النص المراد ترميزه اسفل الكود
       If Font Is Nothing Then
           Font = New Font("times new roman", 9, FontStyle.Bold)
       End If
       'Dim Font2 = New Font(Font.FontFamily, Font.Size + 1, FontStyle.Italic)
       'Dim Font2 = New Font(Font.FontFamily, Font.Size - 1, FontStyle.Regular)
       'Dim Font2 = New Font(Font.FontFamily, Font.Size - 1, FontStyle.Regular)
       'Dim Font2 = New Font(New FontFamily("Arial"), 7, FontStyle.Regular)
       Dim style As FontStyle = FontStyle.Bold

       style = FontStyle.Regular
       Dim Font2 As Font = New Font(New FontFamily("Arial"), 7, style)

       'Dim Font2 As Font = New Font("Times New Roman", 12, style)
       'Dim Font2 As Font = New Font("Courier New", 9, style)
       'Dim Font2 As Font = New Font("Tahoma", 7, style)
       '  GraphZ.DrawString(TheText, Font, New SolidBrush(Color.Black), 70, 40)
       Dim format1 As New StringFormat(StringFormatFlags.NoClip)
       format1.Alignment = StringAlignment.Center
       'GraphZ.DrawString(Kind, Font2, New SolidBrush(Color.Black), 5, 4)
       '  GraphZ.DrawString(Price, Font, New SolidBrush(Color.Black), 0, 40)
       GraphZ.DrawString(Company, Font2, New SolidBrush(Color.Black), 10, 52)




       Code128 = bmp
   End Function
   Function Toc(ByVal Text2CStr As String) As String
       ' دالة لتعويض النص المطلوب تشفيره بالارقام للفئة
       ' (C)
       Dim X As Integer = 1
       Dim NewText As String = ""
       Dim Z As String = ""
       Do
           Z = Mid(Text2CStr, X, 2)
           ' اضافة رقم32 لقيمة الاسكى واستعادة الحرف الناتج بعد الاضافة
           NewText = NewText & Chr(Val(Z) + 32)
           X += 2
           Z = Mid(Text2CStr, X, 1)
           If X >= Len(Text2CStr) Then Exit Do
           If Z = "" Then Exit Do
       Loop
       Toc = NewText
   End Function
   Private Sub barcode2_Load(sender As Object, e As EventArgs) Handles MyBase.Load
       '      TextBox2.Text = "55"

   End Sub

   Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click

       PicBarCode.BackgroundImage = Code128(TextBox1.Text, "A", New Font(ComboBox1.Text.ToString, 7, FontStyle.Italic), TextBox3.Text & "" & "", TextBox2.Text, TextBox4.Text)
       'PicBarCode.BackgroundImage = Code128(TextBox1.Text, "A", New Font(ComboBox1.Text.ToString, 7, FontStyle.Italic), TextBox1.Text & " " & "L.E", TextBox2.Text, TextBox4.Text)
   End Sub

   Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click

       'Dim Prntd As New PrintDialog()
       'Prntd.Document = PrintDocument1
       'If Prntd.ShowDialog() = DialogResult.OK Then
       '    PrintDocument1.Print()
       'End If

       'طباعة الباركود
       If TextBox1.Text = "" Then 'الباركود فارغ
           MsgBox("من فضلك تأكد من كتابة النص المراد تحويله الى باركود")
           Exit Sub
       Else

           pd_PrintDialog.UseEXDialog = True
           pd_PrintDialog.AllowPrintToFile = False
           'تحديد عدد النسخ المراد طباعتها.
           pd_PrintDialog.PrinterSettings.Copies = nud_Count.Value
           If pd_PrintDialog.ShowDialog = Windows.Forms.DialogResult.OK Then

               PrintDoc.PrinterSettings = pd_PrintDialog.PrinterSettings


               AddHandler PrintDoc.PrintPage, AddressOf PrintDocHandler
               'امر الطباعة
               PrintDoc.Print()

           ElseIf pd_PrintDialog.ShowDialog = Windows.Forms.DialogResult.Cancel Then
               Exit Sub

           End If
       End If
   End Sub

   Private Sub PrintDocument1_PrintPage(sender As Object, e As Printing.PrintPageEventArgs) Handles PrintDocument1.PrintPage
       '  Dim x As Integer = Me.Width + 20 ' عرض البانل
       ' Dim y As Integer = Me.Height + 60 'ارتفاع البانل
       'Dim rec As New Rectangle(1, 1, x, y) ' انشاء مستطيل بعرض وارتفاع البانل
       'Dim Bmp As New Bitmap(x, y) ' انشاء نسخة من بتماب

       e.Graphics.DrawImage(PicBarCode.BackgroundImage, nud_MarginH.Value, nud_MarginW.Value, nud_MarginWBrcode.Value, nud_MarginHBrcode.Value)

       '        Me.PictureBox1.DrawToBitmap(Bmp, rec) ' رسم صورة من البتماب بقياس المستطيل المعرفين
       '       e.Graphics.DrawImage(Bmp, rec) ' انشاء غرافيك من الصورة
   End Sub

   Private Sub PictureBox1_Click(sender As Object, e As EventArgs)

   End Sub

   Private Sub nud_MarginW_ValueChanged(sender As Object, e As EventArgs) Handles nud_MarginW.ValueChanged

   End Sub

   Private Sub nud_MarginH_ValueChanged(sender As Object, e As EventArgs) Handles nud_MarginH.ValueChanged

   End Sub

   Private Sub Button10_Click(sender As Object, e As EventArgs) Handles Button10.Click

   End Sub

   Private Sub nud_MarginWBrcode_ValueChanged(sender As Object, e As EventArgs) Handles nud_MarginWBrcode.ValueChanged

   End Sub

   Private Sub Button7_Click(sender As Object, e As EventArgs) Handles Button7.Click

   End Sub

   Private Sub nud_MarginHBrcode_ValueChanged(sender As Object, e As EventArgs) Handles nud_MarginHBrcode.ValueChanged

   End Sub

   Private Sub Button9_Click(sender As Object, e As EventArgs) Handles Button9.Click

   End Sub

   Private Sub Button8_Click(sender As Object, e As EventArgs) Handles Button8.Click

   End Sub

   Private Sub ComboBox1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ComboBox1.SelectedIndexChanged

   End Sub

   Private Sub TextBox3_TextChanged(sender As Object, e As EventArgs) Handles TextBox3.TextChanged

   End Sub

   Private Sub TextBox2_TextChanged(sender As Object, e As EventArgs) Handles TextBox2.TextChanged

   End Sub

   Private Sub TextBox4_TextChanged(sender As Object, e As EventArgs) Handles TextBox4.TextChanged

   End Sub

   Private Sub Button13_Click(sender As Object, e As EventArgs) Handles Button13.Click
       'حفظ صورة الباركود
       If TextBox1.Text = "" Then 'الباركود فارغ
           MsgBox("من فضلك تأكد من كتابة النص المراد تحويله الى باركود")
           Exit Sub
       Else
           Dim SaveFileDialog1 As New SaveFileDialog()
           SaveFileDialog1.InitialDirectory = System.Environment.GetFolderPath(Environment.SpecialFolder.MyPictures) ' "c:\"
           SaveFileDialog1.Filter = "All files (*.*)|*.*|Bitmap files (*.bmp)|*.bmp"
           SaveFileDialog1.FilterIndex = 2
           SaveFileDialog1.RestoreDirectory = True
           SaveFileDialog1.ShowDialog()
           If SaveFileDialog1.FileName <> "" Then
               'PicBarCode.BackgroundImage.Save(SaveFileDialog1.FileName, System.Drawing.Imaging.ImageFormat.Bmp)
               PicBarCode.Image.Save(SaveFileDialog1.FileName, System.Drawing.Imaging.ImageFormat.Bmp)
           End If
       End If
   End Sub

   Private Sub Button5_Click(sender As Object, e As EventArgs) Handles Button5.Click
       'PictureBox1.BackgroundImage = Code128(TextBox3.Text, "A")
       'معاينة قبل الطباعة
       If TextBox1.Text = "" Then 'الباركود فارغ
           MsgBox("من فضلك تأكد من كتابة النص المراد تحويله الى باركود")
           Exit Sub
       Else
           AddHandler PrintDoc.PrintPage, AddressOf PrintDocHandler
           'تحديد عدد النسخ المراد طباعتها
           pd_PrintDialog.PrinterSettings.Copies = nud_Count.Value

           PrintPreviewDialog1.Document = PrintDoc
           PrintPreviewDialog1.ShowDialog()

       End If
       'PictureBox1.BackgroundImage = Code128(TextBox1.Text, "A", New Font(ComboBox1.Text.ToString, 7, FontStyle.Italic), TextBox3.Text & " " & "L.E", TextBox2.Text, TextBox4.Text)
   End Sub

   Private Sub Button11_Click(sender As Object, e As EventArgs) Handles Button11.Click

   End Sub
End Class
السلام عليكم...
يرجى عرض صورة من التقرير والطباعة الحية
في انتظار الرد
(01-09-23, 04:36 AM)ahmedhhh2 كتب : [ -> ]مشكله عند طباعه الباركود الكتابة تظهر بهتة في خيال والنقاط قريبه من بعض غيرت الفونت

هذا هو الخط المستخد للكتابه فوق الباركود جربت اكثر من نوع خط والكتابه غير وضحه كان جودة الصورة قليله

كود :
     Dim drawFont As New Font("Arial", 8)
       Dim drawBrush As New SolidBrush(Color.Black)

       ' Create rectangle for drawing.
       Dim x As Single = 0.0F
       Dim y As Single = 0.0F
       Dim width As Single = 75.0F
       Dim height As Single = 25.0F
       Dim drawRect As New RectangleF(x, y, width, height)

       ' Draw rectangle to screen.
       'Dim blackPen As New Pen(Color.Black)
       'GraphZ.DrawRectangle(blackPen, x, y, width, height)

       ' Set format of string.
       Dim drawFormat As New StringFormat
       drawFormat.Alignment = StringAlignment.Far

       ' Draw string to screen.
       GraphZ.DrawString(Kind, drawFont, drawBrush,
   drawRect, drawFormat)


وهذه الاكواد المستدخمه كامله للباركود
كود :
Public Class barcode2
   Dim PrintDoc As Printing.PrintDocument = New Printing.PrintDocument()
   Dim pd_PrintDialog As New PrintDialog

   Private Sub PrintDocHandler(ByVal sender As Object, ByVal ev As Printing.PrintPageEventArgs)
       ev.Graphics.DrawImage(PicBarCode.BackgroundImage, nud_MarginH.Value, nud_MarginW.Value, nud_MarginWBrcode.Value, nud_MarginHBrcode.Value)

   End Sub

   Function Code128(ByVal TheText As String, ByVal CodeLetter As String, Optional Font As Font = Nothing, Optional Price As String = Nothing, Optional ByVal Kind As String = Nothing, Optional ByVal Company As String = Nothing) As Image

       ' TheText متغير خاص بالنص المراد تشفيره
       ' CodeLetter متغير خاص بالفئة المراد استخدامها

       Dim Binaryz As String = "" 'متغير سيحمل النص بعد تحويله إلى باينرى
       Dim I As Integer
       Dim NumCode As Integer 'متغير سيحمل  قيمة حساب النص التكميلى
       If CodeLetter = "A" Or CodeLetter = "a" Then
           NumCode = 103
           Binaryz = "00101111011"
       End If
       If CodeLetter = "B" Or CodeLetter = "b" Then
           NumCode = 104
           Binaryz = "00101101111"
       End If
       If CodeLetter = "C" Or CodeLetter = "c" Then
           NumCode = 105
           Binaryz = "00101100011"
       End If
       ' الكود التالى سيقوم باسناد قيمة الحرف بالباينرى حسب الجدول الخاص بالكود 128
       For I = 1 To Len(TheText)
           NumCode = NumCode + ((Asc(Mid(TheText, I, 1)) - 32) * I)
           Select Case Asc(Mid(TheText, I, 1))
               Case 32
                   Binaryz = Binaryz & "00100110011"
               Case 33
                   Binaryz = Binaryz & "00110010011"
               Case 34
                   Binaryz = Binaryz & "00110011001"
               Case 35
                   Binaryz = Binaryz & "01101100111"
               Case 36
                   Binaryz = Binaryz & "01101110011"
               Case 37
                   Binaryz = Binaryz & "01110110011"
               Case 38
                   Binaryz = Binaryz & "01100110111"
               Case 39
                   Binaryz = Binaryz & "01100111011"
               Case 40
                   Binaryz = Binaryz & "01110011011"
               Case 41
                   Binaryz = Binaryz & "00110110111"
               Case 42
                   Binaryz = Binaryz & "00110111011"
               Case 43
                   Binaryz = Binaryz & "00111011011"
               Case 44
                   Binaryz = Binaryz & "01001100011"
               Case 45
                   Binaryz = Binaryz & "01100100011"
               Case 46
                   Binaryz = Binaryz & "01100110001"
               Case 47
                   Binaryz = Binaryz & "01000110011"
               Case 48
                   Binaryz = Binaryz & "01100010011"
               Case 49
                   Binaryz = Binaryz & "01100011001"
               Case 50
                   Binaryz = Binaryz & "00110001101"
               Case 51
                   Binaryz = Binaryz & "00110100011"
               Case 52
                   Binaryz = Binaryz & "00110110001"
               Case 53
                   Binaryz = Binaryz & "00100011011"
               Case 54
                   Binaryz = Binaryz & "00110001011"
               Case 55
                   Binaryz = Binaryz & "00010010001"
               Case 56
                   Binaryz = Binaryz & "00010110011"
               Case 57
                   Binaryz = Binaryz & "00011010011"
               Case 58
                   Binaryz = Binaryz & "00011011001"
               Case 59
                   Binaryz = Binaryz & "00010011011"
               Case 60
                   Binaryz = Binaryz & "00011001011"
               Case 61
                   Binaryz = Binaryz & "00011001101"
               Case 62
                   Binaryz = Binaryz & "00100100111"
               Case 63
                   Binaryz = Binaryz & "00100111001"
               Case 64
                   Binaryz = Binaryz & "00111001001"
               Case 65
                   Binaryz = Binaryz & "01011100111"
               Case 66
                   Binaryz = Binaryz & "01110100111"
               Case 67
                   Binaryz = Binaryz & "01110111001"
               Case 68
                   Binaryz = Binaryz & "01001110111"
               Case 69
                   Binaryz = Binaryz & "01110010111"
               Case 70
                   Binaryz = Binaryz & "01110011101"
               Case 71
                   Binaryz = Binaryz & "00101110111"
               Case 72
                   Binaryz = Binaryz & "00111010111"
               Case 73
                   Binaryz = Binaryz & "00111011101"
               Case 74
                   Binaryz = Binaryz & "01001000111"
               Case 75
                   Binaryz = Binaryz & "01001110001"
               Case 76
                   Binaryz = Binaryz & "01110010001"
               Case 77
                   Binaryz = Binaryz & "01000100111"
               Case 78
                   Binaryz = Binaryz & "01000111001"
               Case 79
                   Binaryz = Binaryz & "01110001001"
               Case 80
                   Binaryz = Binaryz & "00010001001"
               Case 81
                   Binaryz = Binaryz & "00101110001"
               Case 82
                   Binaryz = Binaryz & "00111010001"
               Case 83
                   Binaryz = Binaryz & "00100010111"
               Case 84
                   Binaryz = Binaryz & "00100011101"
               Case 85
                   Binaryz = Binaryz & "00100010001"
               Case 86
                   Binaryz = Binaryz & "00010100111"
               Case 87
                   Binaryz = Binaryz & "00010111001"
               Case 88
                   Binaryz = Binaryz & "00011101001"
               Case 89
                   Binaryz = Binaryz & "00010010111"
               Case 90
                   Binaryz = Binaryz & "00010011101"
               Case 91
                   Binaryz = Binaryz & "00011100101"
               Case 92
                   Binaryz = Binaryz & "00010000101"
               Case 93
                   Binaryz = Binaryz & "00110111101"
               Case 94
                   Binaryz = Binaryz & "00001110101"
               Case 95
                   Binaryz = Binaryz & "01011001111"
               Case 96
                   Binaryz = Binaryz & "01011110011"
               Case 97
                   Binaryz = Binaryz & "01101001111"
               Case 98
                   Binaryz = Binaryz & "01101111001"
               Case 99
                   Binaryz = Binaryz & "01111010011"
               Case 100
                   Binaryz = Binaryz & "01111011001"
               Case 101
                   Binaryz = Binaryz & "01001101111"
               Case 102
                   Binaryz = Binaryz & "01001111011"
               Case 103
                   Binaryz = Binaryz & "01100101111"
               Case 104
                   Binaryz = Binaryz & "01100111101"
               Case 105
                   Binaryz = Binaryz & "01111001011"
               Case 106
                   Binaryz = Binaryz & "01111001101"
               Case 107
                   Binaryz = Binaryz & "00111101101"
               Case 108
                   Binaryz = Binaryz & "00110101111"
               Case 109
                   Binaryz = Binaryz & "00001000101"
               Case 110
                   Binaryz = Binaryz & "00111101011"
               Case 111
                   Binaryz = Binaryz & "01110000101"
               Case 112
                   Binaryz = Binaryz & "01011000011"
               Case 113
                   Binaryz = Binaryz & "01101000011"
               Case 114
                   Binaryz = Binaryz & "01101100001"
               Case 115
                   Binaryz = Binaryz & "01000011011"
               Case 116
                   Binaryz = Binaryz & "01100001011"
               Case 117
                   Binaryz = Binaryz & "01100001101"
               Case 118
                   Binaryz = Binaryz & "00001011011"
               Case 119
                   Binaryz = Binaryz & "00001101011"
               Case 120
                   Binaryz = Binaryz & "00001101101"
               Case 121
                   Binaryz = Binaryz & "00100100001"
               Case 122
                   Binaryz = Binaryz & "00100001001"
               Case 123
                   Binaryz = Binaryz & "00001001001"
               Case 124
                   Binaryz = Binaryz & "01010000111"
               Case 125
                   Binaryz = Binaryz & "01011100001"
               Case 126
                   Binaryz = Binaryz & "01110100001"
               Case 127
                   Binaryz = Binaryz & "01000010111"
               Case 128
                   Binaryz = Binaryz & "01000011101"
               Case 129
                   Binaryz = Binaryz & "00001010111"
               Case 130
                   Binaryz = Binaryz & "00001011101"
               Case 131
                   Binaryz = Binaryz & "01000100001"
               Case 132
                   Binaryz = Binaryz & "01000010001"
               Case 133
                   Binaryz = Binaryz & "00010100001"
               Case 134
                   Binaryz = Binaryz & "00001010001"
               Case 135
                   Binaryz = Binaryz & "00101111011"
               Case 136
                   Binaryz = Binaryz & "00101101111"
               Case 137
                   Binaryz = Binaryz & "00101100011"
               Case 138
                   Binaryz = Binaryz & "0011100010100"
           End Select
       Next
       NumCode = NumCode Mod 103
       ' الكود التالى لمعرفة الحرف المراد اضافتة لاستكمال النص
       Select Case NumCode
           Case 0
               Binaryz = Binaryz & "00100110011"
           Case 1
               Binaryz = Binaryz & "00110010011"
           Case 2
               Binaryz = Binaryz & "00110011001"
           Case 3
               Binaryz = Binaryz & "01101100111"
           Case 4
               Binaryz = Binaryz & "01101110011"
           Case 5
               Binaryz = Binaryz & "01110110011"
           Case 6
               Binaryz = Binaryz & "01100110111"
           Case 7
               Binaryz = Binaryz & "01100111011"
           Case 8
               Binaryz = Binaryz & "01110011011"
           Case 9
               Binaryz = Binaryz & "00110110111"
           Case 10
               Binaryz = Binaryz & "00110111011"
           Case 11
               Binaryz = Binaryz & "00111011011"
           Case 12
               Binaryz = Binaryz & "01001100011"
           Case 13
               Binaryz = Binaryz & "01100100011"
           Case 14
               Binaryz = Binaryz & "01100110001"
           Case 15
               Binaryz = Binaryz & "01000110011"
           Case 16
               Binaryz = Binaryz & "01100010011"
           Case 17
               Binaryz = Binaryz & "01100011001"
           Case 18
               Binaryz = Binaryz & "00110001101"
           Case 19
               Binaryz = Binaryz & "00110100011"
           Case 20
               Binaryz = Binaryz & "00110110001"
           Case 21
               Binaryz = Binaryz & "00100011011"
           Case 22
               Binaryz = Binaryz & "00110001011"
           Case 23
               Binaryz = Binaryz & "00010010001"
           Case 24
               Binaryz = Binaryz & "00010110011"
           Case 25
               Binaryz = Binaryz & "00011010011"
           Case 26
               Binaryz = Binaryz & "00011011001"
           Case 27
               Binaryz = Binaryz & "00010011011"
           Case 28
               Binaryz = Binaryz & "00011001011"
           Case 29
               Binaryz = Binaryz & "00011001101"
           Case 30
               Binaryz = Binaryz & "00100100111"
           Case 31
               Binaryz = Binaryz & "00100111001"
           Case 32
               Binaryz = Binaryz & "00111001001"
           Case 33
               Binaryz = Binaryz & "01011100111"
           Case 34
               Binaryz = Binaryz & "01110100111"
           Case 35
               Binaryz = Binaryz & "01110111001"
           Case 36
               Binaryz = Binaryz & "01001110111"
           Case 37
               Binaryz = Binaryz & "01110010111"
           Case 38
               Binaryz = Binaryz & "01110011101"
           Case 39
               Binaryz = Binaryz & "00101110111"
           Case 40
               Binaryz = Binaryz & "00111010111"
           Case 41
               Binaryz = Binaryz & "00111011101"
           Case 42
               Binaryz = Binaryz & "01001000111"
           Case 43
               Binaryz = Binaryz & "01001110001"
           Case 44
               Binaryz = Binaryz & "01110010001"
           Case 45
               Binaryz = Binaryz & "01000100111"
           Case 46
               Binaryz = Binaryz & "01000111001"
           Case 47
               Binaryz = Binaryz & "01110001001"
           Case 48
               Binaryz = Binaryz & "00010001001"
           Case 49
               Binaryz = Binaryz & "00101110001"
           Case 50
               Binaryz = Binaryz & "00111010001"
           Case 51
               Binaryz = Binaryz & "00100010111"
           Case 52
               Binaryz = Binaryz & "00100011101"
           Case 53
               Binaryz = Binaryz & "00100010001"
           Case 54
               Binaryz = Binaryz & "00010100111"
           Case 55
               Binaryz = Binaryz & "00010111001"
           Case 56
               Binaryz = Binaryz & "00011101001"
           Case 57
               Binaryz = Binaryz & "00010010111"
           Case 58
               Binaryz = Binaryz & "00010011101"
           Case 59
               Binaryz = Binaryz & "00011100101"
           Case 60
               Binaryz = Binaryz & "00010000101"
           Case 61
               Binaryz = Binaryz & "00110111101"
           Case 62
               Binaryz = Binaryz & "00001110101"
           Case 63
               Binaryz = Binaryz & "01011001111"
           Case 64
               Binaryz = Binaryz & "01011110011"
           Case 65
               Binaryz = Binaryz & "01101001111"
           Case 66
               Binaryz = Binaryz & "01101111001"
           Case 67
               Binaryz = Binaryz & "01111010011"
           Case 68
               Binaryz = Binaryz & "01111011001"
           Case 69
               Binaryz = Binaryz & "01001101111"
           Case 70
               Binaryz = Binaryz & "01001111011"
           Case 71
               Binaryz = Binaryz & "01100101111"
           Case 72
               Binaryz = Binaryz & "01100111101"
           Case 73
               Binaryz = Binaryz & "01111001011"
           Case 74
               Binaryz = Binaryz & "01111001101"
           Case 75
               Binaryz = Binaryz & "00111101101"
           Case 76
               Binaryz = Binaryz & "00110101111"
           Case 77
               Binaryz = Binaryz & "00001000101"
           Case 78
               Binaryz = Binaryz & "00111101011"
           Case 79
               Binaryz = Binaryz & "01110000101"
           Case 80
               Binaryz = Binaryz & "01011000011"
           Case 81
               Binaryz = Binaryz & "01101000011"
           Case 82
               Binaryz = Binaryz & "01101100001"
           Case 83
               Binaryz = Binaryz & "01000011011"
           Case 84
               Binaryz = Binaryz & "01100001011"
           Case 85
               Binaryz = Binaryz & "01100001101"
           Case 86
               Binaryz = Binaryz & "00001011011"
           Case 87
               Binaryz = Binaryz & "00001101011"
           Case 88
               Binaryz = Binaryz & "00001101101"
           Case 89
               Binaryz = Binaryz & "00100100001"
           Case 90
               Binaryz = Binaryz & "00100001001"
           Case 91
               Binaryz = Binaryz & "00001001001"
           Case 92
               Binaryz = Binaryz & "01010000111"
           Case 93
               Binaryz = Binaryz & "01011100001"
           Case 94
               Binaryz = Binaryz & "01110100001"
           Case 95
               Binaryz = Binaryz & "01000010111"
           Case 96
               Binaryz = Binaryz & "01000011101"
           Case 97
               Binaryz = Binaryz & "00001010111"
           Case 98
               Binaryz = Binaryz & "00001011101"
           Case 99
               Binaryz = Binaryz & "01000100001"
           Case 100
               Binaryz = Binaryz & "01000010001"
           Case 101
               Binaryz = Binaryz & "00010100001"
           Case 102
               Binaryz = Binaryz & "00001010001"
       End Select
       Binaryz = Binaryz & "0011100010100" ' انهاء الكود باضافة الباينرى الخاص بايقاف جميع الاكواد

       ' انشاء صورة عرضها عدد حروف الباينرى المستخدم
       Dim bmp As Bitmap = New Bitmap(Len(Binaryz), 80, System.Drawing.Imaging.PixelFormat.Format24bppRgb)
       Dim z As String ' متغير لمعرفة لون الخط
       Dim GraphZ As Graphics = Graphics.FromImage(bmp)
       Dim RectZ As Rectangle = New Rectangle(0, 0, bmp.Width, bmp.Height) ' مستطيل بحجم الصورة لاعطاء الخلفية باللون الابيض
       ' فرشاه لدهان المستطيل السابق باللون الابيض
       Dim myBrush As Brush = New Drawing.Drawing2D.LinearGradientBrush(RectZ, Color.White, Color.White, Drawing.Drawing2D.LinearGradientMode.ForwardDiagonal)
       ' دهان المستطيل السابق باللون الابيض
       GraphZ.FillRectangle(myBrush, RectZ)
       '  رسم خطوط الباركود
       Dim PenZ As Pen
       Dim point1 As Point ' نقطة بداية الخط
       Dim point2 As Point ' نقطة نهاية الخط
       For I = 1 To Len(Binaryz)
           z = Mid(Binaryz, I, 1)
           If z = "0" Then
               PenZ = New Pen(Color.Black, 1)
               point1 = New Point(I, 26)
               point2 = New Point(I, 39)
               GraphZ.DrawLine(PenZ, point1, point2)
           Else
               PenZ = New Pen(Color.White, 1)
               point1 = New Point(I, 0)
               point2 = New Point(I, 0)
               GraphZ.DrawLine(PenZ, point1, point2)
           End If
       Next
       ' رسم النص المراد ترميزه اسفل الكود
       'Dim Font3 = New Font(Font.FontFamily, Font.Size + 3, FontStyle.Bold)
       'GraphZ.DrawString(TheText, Font3, New SolidBrush(Color.Black), 0, 70)

       'GraphZ.DrawString(TheText, New Font("times new roman", 9, FontStyle.Bold), New SolidBrush(Color.Black), 50, 40)
       '  Dim format1 As New StringFormat(StringFormatFlags.NoClip)
       '  format1.Alignment = StringAlignment.Center
       '  GraphZ.DrawString(Kind, New Font("times new roman", 12, FontStyle.Bold), New SolidBrush(Color.Black), 0, 3)
       GraphZ.DrawString(Price, New Font("times new roman", 8, FontStyle.Bold), New SolidBrush(Color.Black), 0, 40)
       ' GraphZ.DrawString(Company, New Font("times new roman", 12, FontStyle.Bold), New SolidBrush(Color.Black), 0, 50)

       '  GraphZ.DrawString(TheText, New Font(Form1.ComboBox1.Text, 12, FontStyle.Bold), New SolidBrush(Color.Black), 0, 50)



       ' Create string to draw.
       Dim drawString As [String] = "Sample Text"

       ' Create font and brush.
       Dim drawFont As New Font("Arial", 8)
       Dim drawBrush As New SolidBrush(Color.Black)

       ' Create rectangle for drawing.
       Dim x As Single = 0.0F
       Dim y As Single = 0.0F
       Dim width As Single = 75.0F
       Dim height As Single = 25.0F
       Dim drawRect As New RectangleF(x, y, width, height)

       ' Draw rectangle to screen.
       'Dim blackPen As New Pen(Color.Black)
       'GraphZ.DrawRectangle(blackPen, x, y, width, height)

       ' Set format of string.
       Dim drawFormat As New StringFormat
       drawFormat.Alignment = StringAlignment.Far

       ' Draw string to screen.
       GraphZ.DrawString(Kind, drawFont, drawBrush,
   drawRect, drawFormat)


       ' رسم النص المراد ترميزه اسفل الكود
       If Font Is Nothing Then
           Font = New Font("times new roman", 9, FontStyle.Bold)
       End If
       'Dim Font2 = New Font(Font.FontFamily, Font.Size + 1, FontStyle.Italic)
       'Dim Font2 = New Font(Font.FontFamily, Font.Size - 1, FontStyle.Regular)
       'Dim Font2 = New Font(Font.FontFamily, Font.Size - 1, FontStyle.Regular)
       'Dim Font2 = New Font(New FontFamily("Arial"), 7, FontStyle.Regular)
       Dim style As FontStyle = FontStyle.Bold

       style = FontStyle.Regular
       Dim Font2 As Font = New Font(New FontFamily("Arial"), 7, style)

       'Dim Font2 As Font = New Font("Times New Roman", 12, style)
       'Dim Font2 As Font = New Font("Courier New", 9, style)
       'Dim Font2 As Font = New Font("Tahoma", 7, style)
       '  GraphZ.DrawString(TheText, Font, New SolidBrush(Color.Black), 70, 40)
       Dim format1 As New StringFormat(StringFormatFlags.NoClip)
       format1.Alignment = StringAlignment.Center
       'GraphZ.DrawString(Kind, Font2, New SolidBrush(Color.Black), 5, 4)
       '  GraphZ.DrawString(Price, Font, New SolidBrush(Color.Black), 0, 40)
       GraphZ.DrawString(Company, Font2, New SolidBrush(Color.Black), 10, 52)




       Code128 = bmp
   End Function
   Function Toc(ByVal Text2CStr As String) As String
       ' دالة لتعويض النص المطلوب تشفيره بالارقام للفئة
       ' (C)
       Dim X As Integer = 1
       Dim NewText As String = ""
       Dim Z As String = ""
       Do
           Z = Mid(Text2CStr, X, 2)
           ' اضافة رقم32 لقيمة الاسكى واستعادة الحرف الناتج بعد الاضافة
           NewText = NewText & Chr(Val(Z) + 32)
           X += 2
           Z = Mid(Text2CStr, X, 1)
           If X >= Len(Text2CStr) Then Exit Do
           If Z = "" Then Exit Do
       Loop
       Toc = NewText
   End Function
   Private Sub barcode2_Load(sender As Object, e As EventArgs) Handles MyBase.Load
       '      TextBox2.Text = "55"

   End Sub

   Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click

       PicBarCode.BackgroundImage = Code128(TextBox1.Text, "A", New Font(ComboBox1.Text.ToString, 7, FontStyle.Italic), TextBox3.Text & "" & "", TextBox2.Text, TextBox4.Text)
       'PicBarCode.BackgroundImage = Code128(TextBox1.Text, "A", New Font(ComboBox1.Text.ToString, 7, FontStyle.Italic), TextBox1.Text & " " & "L.E", TextBox2.Text, TextBox4.Text)
   End Sub

   Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click

       'Dim Prntd As New PrintDialog()
       'Prntd.Document = PrintDocument1
       'If Prntd.ShowDialog() = DialogResult.OK Then
       '    PrintDocument1.Print()
       'End If

       'طباعة الباركود
       If TextBox1.Text = "" Then 'الباركود فارغ
           MsgBox("من فضلك تأكد من كتابة النص المراد تحويله الى باركود")
           Exit Sub
       Else

           pd_PrintDialog.UseEXDialog = True
           pd_PrintDialog.AllowPrintToFile = False
           'تحديد عدد النسخ المراد طباعتها.
           pd_PrintDialog.PrinterSettings.Copies = nud_Count.Value
           If pd_PrintDialog.ShowDialog = Windows.Forms.DialogResult.OK Then

               PrintDoc.PrinterSettings = pd_PrintDialog.PrinterSettings


               AddHandler PrintDoc.PrintPage, AddressOf PrintDocHandler
               'امر الطباعة
               PrintDoc.Print()

           ElseIf pd_PrintDialog.ShowDialog = Windows.Forms.DialogResult.Cancel Then
               Exit Sub

           End If
       End If
   End Sub

   Private Sub PrintDocument1_PrintPage(sender As Object, e As Printing.PrintPageEventArgs) Handles PrintDocument1.PrintPage
       '  Dim x As Integer = Me.Width + 20 ' عرض البانل
       ' Dim y As Integer = Me.Height + 60 'ارتفاع البانل
       'Dim rec As New Rectangle(1, 1, x, y) ' انشاء مستطيل بعرض وارتفاع البانل
       'Dim Bmp As New Bitmap(x, y) ' انشاء نسخة من بتماب

       e.Graphics.DrawImage(PicBarCode.BackgroundImage, nud_MarginH.Value, nud_MarginW.Value, nud_MarginWBrcode.Value, nud_MarginHBrcode.Value)

       '        Me.PictureBox1.DrawToBitmap(Bmp, rec) ' رسم صورة من البتماب بقياس المستطيل المعرفين
       '       e.Graphics.DrawImage(Bmp, rec) ' انشاء غرافيك من الصورة
   End Sub

   Private Sub PictureBox1_Click(sender As Object, e As EventArgs)

   End Sub

   Private Sub nud_MarginW_ValueChanged(sender As Object, e As EventArgs) Handles nud_MarginW.ValueChanged

   End Sub

   Private Sub nud_MarginH_ValueChanged(sender As Object, e As EventArgs) Handles nud_MarginH.ValueChanged

   End Sub

   Private Sub Button10_Click(sender As Object, e As EventArgs) Handles Button10.Click

   End Sub

   Private Sub nud_MarginWBrcode_ValueChanged(sender As Object, e As EventArgs) Handles nud_MarginWBrcode.ValueChanged

   End Sub

   Private Sub Button7_Click(sender As Object, e As EventArgs) Handles Button7.Click

   End Sub

   Private Sub nud_MarginHBrcode_ValueChanged(sender As Object, e As EventArgs) Handles nud_MarginHBrcode.ValueChanged

   End Sub

   Private Sub Button9_Click(sender As Object, e As EventArgs) Handles Button9.Click

   End Sub

   Private Sub Button8_Click(sender As Object, e As EventArgs) Handles Button8.Click

   End Sub

   Private Sub ComboBox1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ComboBox1.SelectedIndexChanged

   End Sub

   Private Sub TextBox3_TextChanged(sender As Object, e As EventArgs) Handles TextBox3.TextChanged

   End Sub

   Private Sub TextBox2_TextChanged(sender As Object, e As EventArgs) Handles TextBox2.TextChanged

   End Sub

   Private Sub TextBox4_TextChanged(sender As Object, e As EventArgs) Handles TextBox4.TextChanged

   End Sub

   Private Sub Button13_Click(sender As Object, e As EventArgs) Handles Button13.Click
       'حفظ صورة الباركود
       If TextBox1.Text = "" Then 'الباركود فارغ
           MsgBox("من فضلك تأكد من كتابة النص المراد تحويله الى باركود")
           Exit Sub
       Else
           Dim SaveFileDialog1 As New SaveFileDialog()
           SaveFileDialog1.InitialDirectory = System.Environment.GetFolderPath(Environment.SpecialFolder.MyPictures) ' "c:\"
           SaveFileDialog1.Filter = "All files (*.*)|*.*|Bitmap files (*.bmp)|*.bmp"
           SaveFileDialog1.FilterIndex = 2
           SaveFileDialog1.RestoreDirectory = True
           SaveFileDialog1.ShowDialog()
           If SaveFileDialog1.FileName <> "" Then
               'PicBarCode.BackgroundImage.Save(SaveFileDialog1.FileName, System.Drawing.Imaging.ImageFormat.Bmp)
               PicBarCode.Image.Save(SaveFileDialog1.FileName, System.Drawing.Imaging.ImageFormat.Bmp)
           End If
       End If
   End Sub

   Private Sub Button5_Click(sender As Object, e As EventArgs) Handles Button5.Click
       'PictureBox1.BackgroundImage = Code128(TextBox3.Text, "A")
       'معاينة قبل الطباعة
       If TextBox1.Text = "" Then 'الباركود فارغ
           MsgBox("من فضلك تأكد من كتابة النص المراد تحويله الى باركود")
           Exit Sub
       Else
           AddHandler PrintDoc.PrintPage, AddressOf PrintDocHandler
           'تحديد عدد النسخ المراد طباعتها
           pd_PrintDialog.PrinterSettings.Copies = nud_Count.Value

           PrintPreviewDialog1.Document = PrintDoc
           PrintPreviewDialog1.ShowDialog()

       End If
       'PictureBox1.BackgroundImage = Code128(TextBox1.Text, "A", New Font(ComboBox1.Text.ToString, 7, FontStyle.Italic), TextBox3.Text & " " & "L.E", TextBox2.Text, TextBox4.Text)
   End Sub

   Private Sub Button11_Click(sender As Object, e As EventArgs) Handles Button11.Click

   End Sub
End Class

(05-09-23, 04:32 AM)ahmedhhh2 كتب : [ -> ]في انتظار الرد

ضع المشروع وساحاول تعديله
انا شايف الافضل يضع فورمة
وحضرتك تعدل عليها
او تتكرم وتعمل الفورمة وانت ادجري بها
ويكون لك جزيل الشكر
والجميع يشكروك علي هذا المشروع البسيط الممتاز
تم حل المشكله والحمد لله تم وضع الكلام بعيد عن Function Code128

تم نقله داخل Private Sub PrintDocHandler
واستبدال
GraphZ.DrawString
ب
ev.Graphics.DrawString
زميلي الفاضل ارفع المشروع بعد تعديله ولك الشكر
(06-09-23, 01:35 AM)ahmedhhh2 كتب : [ -> ]تم حل المشكله والحمد لله تم وضع الكلام بعيد عن Function Code128

تم نقله داخل Private Sub PrintDocHandler
واستبدال
GraphZ.DrawString
ب
ev.Graphics.DrawString

ارفع الكود بعد التعديل لتعم الفائدة
عندي مشكله في المنتدي مش عارف اضيف رد او اعمل اقتباس
تظهر هذه الرساله بس الكود سهل التنفيذ وتم توضيح التعديل عليه
يتعذّر على هذه الصفحة العمل يتعذر على vb4arb.com معالجة هذا الطلب حاليًا.
HTTP ERROR 500
الصفحات : 1 2