Printer Fonts in VB.Net


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: Printer Fonts in VB.Net

  1. #1
    Join Date
    Dec 2003
    Location
    UK
    Posts
    13

    Unhappy Printer Fonts in VB.Net



    I am struggling a great deal with something which was so simple in VB6. I am using an EPSON POS Printer and I need to send the character "A" in the printer font "control" to the printer which opens the till draw.

    I have searched and searched and tried and failed to find a way to do this on the internet. I have tried:

    - Using a RTF document & a report with the character A but it doesn't accept the printer font

    - Using the "Send Raw data directly to printer" help from MSDN but I cant seem to format the data to change the font

    - Everything else around on the internet which relates to printer fonts!!

    I have received the following code from EPSON to make it work although I don't know how to implement this. What is "UsingGDI"? PrintInfo seems to be a Web control rather than VB.net....

    Any help would make me the happiest person alive today!

    Thanks
    Jeff

    Private Sub PrintControlCharacter(ByVal e As System.Drawing.Printing.PrintPageEventArgs, ByVal sControlChar As String)

    Dim hdc As IntPtr = New IntPtr()
    Dim font As IntPtr = New IntPtr()

    Dim pInfo As FontInfo
    pInfo = New FontInfo("control", 10, 1)

    hdc = e.Graphics.GetHdc()

    Dim nHeight As Integer
    nHeight = -pInfo.nFontSize * UsingGDI.GetDeviceCaps(hdc, 90) / 72

    font = UsingGDI.CreateFont(nHeight, 0, 0, 0, 400, 0, 0, 0, _
    pInfo.nCharSet, 0, 0, 0, 0,
    pInfo.sFontName)

    UsingGDI.SelectObject(hdc, font)

    UsingGDI.TextOut(hdc, 0, 0, sControlChar, sControlChar.Length)

    e.Graphics.ReleaseHdc(hdc)
    End Sub

  2. #2
    Join Date
    Nov 2003
    Location
    Portland, OR
    Posts
    8,387
    Hi, Jeff: I suspect "UsingGDI" is simply a VB.NET class that declares the API functions used in the code sample. Try searching the Web for "VB.NET" plus the name of each of the API functions used in Epson's code sample; you should be able to find the necessary declare statements.
    Phil Weber
    http://www.philweber.com

    Please post questions to the forums, where others may benefit.
    I do not offer free assistance by e-mail. Thank you!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center