0
Windowsフォームに直接書き込むと、印刷プレビューからプリンタに印刷するときれいに見えます。しかし、印刷プレビュー自体は、バーコードフォントでバーコードテキストをレンダリングしません。印刷プレビューでバーコードが表示されない
Public Class frmPrintPreview
Private Const testString1 As String = "*A1C1S1B1*"
Private Const testString2 As String = "*A99C99S7B3*"
Dim _BarcodeFont As System.Drawing.Text.PrivateFontCollection
Dim _BarcodeFont1 As Font
Dim _BarcodeFont2 As Font
Private Sub frmPrintPreview_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
_BarcodeFont = New System.Drawing.Text.PrivateFontCollection()
_BarcodeFont.AddFontFile("FRE3OF9X.TTF")
_BarcodeFont.AddFontFile("FREE3OF9.TTF")
_BarcodeFont1 = New Font(Me._BarcodeFont.Families(0), 20, FontStyle.Regular, GraphicsUnit.Point)
_BarcodeFont2 = New Font(Me._BarcodeFont.Families(1), 20, FontStyle.Regular, GraphicsUnit.Point)
End Sub
Private Sub PrintData(ByVal sender As Object, ByVal e As Printing.PrintPageEventArgs)
DrawingRoutine(e.Graphics)
End Sub
Private Sub DrawingRoutine(ByRef g As Graphics)
Dim PrintFont As Font
PrintFont = New Font(Me.Font.FontFamily, 10.0, FontStyle.Regular) ', GraphicsUnit.Point)
g.TextRenderingHint = Drawing.Text.TextRenderingHint.AntiAlias
Dim y As Int32 = 0
g.DrawString(vbCrLf + Application.ProductName + " Version:" _
+ Application.ProductVersion + vbCrLf _
+ testString1, PrintFont, Brushes.Black, 0, 0)
y += 80
g.DrawString(testString1, Me.Font, Brushes.Black, 50, y)
y += 40
g.DrawString(testString1, _BarcodeFont1, Brushes.Black, 50, y)
y += 40
g.DrawString(testString2, Me.Font, Brushes.Black, 50, y)
y += 40
g.DrawString(testString2, _BarcodeFont2, Brushes.Black, 50, y)
End Sub
Private Sub btnPrint_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint
DrawingRoutine(e.Graphics)
End Sub
Private Sub btnPrint_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPrint.Click
Using printPreview As New PrintPreviewDialog()
Dim x As New Printing.PrintDocument()
AddHandler x.PrintPage, AddressOf PrintData
printPreview.Document = x
Dim result As DialogResult = printPreview.ShowDialog(Me)
' MsgBox(result)
End Using
End Sub
エンドクラス
私の印刷プレビューと間違っている何?