无法使用已加载的文件打印文本 [英] Unable to print text using loaded file

查看:169
本文介绍了无法使用已加载的文件打印文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以,我不久前写了一个程序来打印条形码标签.旧版本需要将字体安装在fonts文件夹中,但是这使第一次使用该程序的人感到痛苦,因为该程序将使用默认字体打印条形码标签.如果我直接加载字体文件并尝试打印,它将以默认字体显示,显然不是条形码.以下似乎无效:

So, I''ve wrote a program awhile ago that prints barcode labels. The old version needed the font to be installed in the fonts folder, but that made it a pain for people using the program for the first time, as the program would print the barcode label with a default font. If I load the font file directly and try and print, it just shows up with the default font, obviously not a barcode. The following doesn''t seem to work:

Private Sub Print_PrintPage(ByVal sender As Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs)

        Dim pointF As New PointF(0, 0)

        Dim drawFormat As New StringFormat
        drawFormat.FormatFlags = StringFormatFlags.DirectionVertical

        Dim drawBrush As New SolidBrush(Color.Black)

        '' Install and size the font
        Dim barcodeFont As Font
        Dim barcodeFontSize = 36
        Dim pfc As New PrivateFontCollection
        pfc.AddFontFile("FRE3OF9X.TTF")
        barcodeFont = New Font(pfc.Families(0), barcodeFontSize)
        e.Graphics.DrawString(serial, barcodeFont, drawBrush, pointF, drawFormat)

        '' There are no more pages.
        e.HasMorePages = False
    End Sub



这是旧的方法,确实有效:



This is the old way, and it does work:

Private Sub Print_PrintPage(ByVal sender As Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs)

        Dim pointF As New PointF(0, 0)

        Dim drawFormat As New StringFormat
        drawFormat.FormatFlags = StringFormatFlags.DirectionVertical

        Dim drawBrush As New SolidBrush(Color.Black)

        '' Install and size the font
        Dim barcodeFont As Font
        Dim barcodeFontSize = 36
        barcodeFont = New Font("Free 3 of 9 Extended", barcodeFontSize)
        e.Graphics.DrawString(serial, barcodeFont, drawBrush, pointF, drawFormat)

        '' There are no more pages.
        e.HasMorePages = False
    End Sub



我真的很想把它安装在不需要在系统上安装字体的位置,因此,如果有人有任何见识,我将不胜感激.

〜Brandon



I''d really like to have it where I don''t have to install the font on the system, so if anyone has any insight, I''d greatly appreciate it.

~Brandon

推荐答案

我猜"FRE3OF9X.TTF"不是有效的字体系列.请看下面的msdn示例.

http://msdn.microsoft.com/en-us/library/y505zzfw.aspx [ ^ ]

祝你好运!
I guess "FRE3OF9X.TTF" isn''t a valid font family. Look at the msdn example below.

http://msdn.microsoft.com/en-us/library/y505zzfw.aspx[^]

Good luck!


这篇关于无法使用已加载的文件打印文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆