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

نسخة كاملة : تعديل الكود لطباعة
أنت حالياً تتصفح نسخة خفيفة من المنتدى . مشاهدة نسخة كاملة مع جميع الأشكال الجمالية .
السلام عليكم

استخدمت الكود التالي لطباعة بماكينة الطباعة a4  حجم الورق العادي وكل شيء تمام .
اردت استخدامة للطباعة بمكينة ملصقات الباركود zepra ولا يظهر اي شيء بعد جعل ماكينة الطباعة الافتراضية المخصصة للباركود ويظهر تغير حجم الصفحة بالبرنت برفيو ولاكن لايظهر اي شيء بالصفحة تظهر فارغة تماما.


   Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
       restValues()
       PrintPreviewDialog1 = New PrintPreviewDialog
       PrintPreviewDialog1.Document = PrintDocument1
       PrintPreviewDialog1.Show()
   End Sub
   Private barcodes As New List(Of Object())
   Private index As Integer = 0
   Private counter As Integer = 0
   Private Distance As Integer = 25
   Private Sub restValues()
       index = 0
       counter = 0
       Distance = 25
   End Sub
   Private Sub PrintDocument1_PrintPage(ByVal sender As Object, ByVal e As Printing.PrintPageEventArgs) Handles PrintDocument1.PrintPage

       For i As Integer = index To barcodes.Count - 1

           Dim imagbarcode As Image = DirectCast(barcodes(i)(0), Image)
           Dim barcodeName As String = DirectCast(barcodes(i)(1), String)
           Dim font As Font = New Font("Arial", 12, FontStyle.Bold)
           Dim stringSize As New SizeF(e.Graphics.MeasureString(barcodeName, font))

           Dim imagWidth As Integer = imagbarcode.Width
           Dim imagHeight As Integer = imagbarcode.Height
           Dim pageHeight As Integer = counter + imagHeight + stringSize.Height + Distance

           Dim pageX As Integer = CInt(e.PageBounds.Width / 2) - CInt(imagWidth / 2)

           If pageHeight >= e.MarginBounds.Height Then

               counter = 0
               index = i
               e.HasMorePages = True
               Exit For

           Else

               e.HasMorePages = False
               counter += imagHeight + stringSize.Height + Distance
               e.Graphics.DrawString(barcodeName, font, New SolidBrush(Color.Black), pageX + CInt(imagWidth / 2) - CInt(stringSize.Width / 2), counter - stringSize.Height)
               e.Graphics.DrawImage(imagbarcode, pageX, counter, imagWidth, imagHeight)

           End If

           index = i

       Next

   End Sub