Solved

Rotate Text to Printer?

Posted on 2000-04-09
9
234 Views
Last Modified: 2010-05-02
Hi!

I want to print a text to a printer, with 90°. Does somebody know, how i can do this?

Thanks in advanced

Pierre
0
Comment
Question by:Falk2
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
  • +2
9 Comments
 
LVL 28

Expert Comment

by:AzraSound
ID: 2699188
0
 
LVL 32

Expert Comment

by:Erick37
ID: 2700134
"Printing Rotated Text with Visual Basic"
http://support.microsoft.com/support/kb/articles/Q175/5/35.ASP
0
 

Expert Comment

by:mbah022100
ID: 2703031
I use this code to print by 90°:

Private Const FW_DONTCARE = 0
Private Const FW_THIN = 100
Private Const FW_EXTRALIGHT = 200
Private Const FW_ULTRALIGHT = 200
Private Const FW_LIGHT = 300
Private Const FW_NORMAL = 400
Private Const FW_REGULAR = 400
Private Const FW_MEDIUM = 500
Private Const FW_SEMIBOLD = 600
Private Const FW_DEMIBOLD = 600
Private Const FW_BOLD = 700
Private Const FW_EXTRABOLD = 800
Private Const FW_ULTRABOLD = 800
Private Const FW_HEAVY = 900
Private Const FW_BLACK = 900

Private Const LF_FACESIZE = 32

Private Type LOGFONT
    lfHeight As Long
    lfWidth As Long
    lfEscapement As Long
    lfOrientation As Long
    lfWeight As Long
    lfItalic As Byte
    lfUnderline As Byte
    lfStrikeOut As Byte
    lfCharSet As Byte
    lfOutPrecision As Byte
    lfClipPrecision As Byte
    lfQuality As Byte
    lfPitchAndFamily As Byte
    lfFaceName As String * LF_FACESIZE
End Type

Private Type SIZE
  cx As Long
  cy As Long
End Type
                               
Private Declare Function CreateFontIndirect Lib "gdi32" Alias "CreateFontIndirectA" (lpLogFont As LOGFONT) As Long
Private Declare Function SelectObject Lib "gdi32" (ByVal hdc As Long, ByVal hObject As Long) As Long
Private Declare Function GetTextExtentPoint32 Lib "gdi32" Alias "GetTextExtentPoint32A" (ByVal hdc As Long, ByVal lpsz As String, ByVal cbString As Long, lpSize As SIZE) As Long
Private Declare Function TextOut Lib "gdi32" Alias "TextOutA" (ByVal hdc As Long, ByVal X As Long, ByVal Y As Long, ByVal lpString As String, ByVal nCount As Long) As Long ' or Boolean
Private Declare Function DeleteObject Lib "gdi32" (ByVal hObject As Long) As Long
                               
Public Sub pPrint(sText As String, lHeight As Long)
  Dim log_font As LOGFONT
  Dim log_size As SIZE
  Dim new_font As Long
  Dim old_font As Long
  Dim lRc As Long
 
  ' Create the rotated font.
  pCreatePrinterFont log_font, 90, 10 , "Arial"
  new_font = CreateFontIndirect(log_font)

  ' Select the font.
  old_font = SelectObject(Printer.hdc, new_font)

  ' Draw the text.
  lRc = GetTextExtentPoint32(Printer.hdc, sText, Len(sText), log_size)
 
  lRc = TextOut(Printer.hdc, your Y position, your X position, sText, Len(sText))
 
  ' Restore the original font.
  SelectObject hdc, old_font
  DeleteObject new_font

End Sub

Private Sub pCreatePrinterFont(log_fnt As LOGFONT, iAngle As Integer, fFontSize as Single, sFontName as String)
  With log_fnt
    .lfEscapement = iAngle * 10
    If m_bFontBold = True Then
      .lfWeight = FW_BOLD
    End If
    .lfItalic = False
    .lfUnderline = False
    .lfStrikeOut = False
    .lfHeight = (fFontSize * -(Printer.TwipsPerPixelX * 8.33)) / Printer.TwipsPerPixelX
    .lfFaceName = sFontName & vbNullChar
  End With
End Sub

If you check this code carfully you can see that it is possible to print by any angle.
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:Falk2
ID: 2716393
AzraSound's answer was the first and best one, but i can't give him the points...
0
 
LVL 28

Expert Comment

by:AzraSound
ID: 2716886
because?
0
 
LVL 28

Accepted Solution

by:
AzraSound earned 100 total points
ID: 2731149
submitting comment as answer
0
 

Author Comment

by:Falk2
ID: 2742912
It works fantastics

Only no word has been said about Printer-Resolution and it's relationship with the x and y coordinate.
0
 
LVL 3

Expert Comment

by:darinw
ID: 2744720
Falk2: If the answer was 'fantastic', why did you assign a B grade?

Just curious. There is no way to undo a grade once it is done though, but I am sure the Expert would like to know as well.

darinw
Customer Service
0
 
LVL 3

Expert Comment

by:darinw
ID: 2744724
>Only no word has been said about Printer-Resolution and it's relationship
with the x and y coordinate.

If I am not mistaken, that was not the question.

darinw
Customer Service
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

695 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question