Solved

Rotate Text to Printer?

Posted on 2000-04-09
9
226 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
  • 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
 

Author Comment

by:Falk2
ID: 2716393
AzraSound's answer was the first and best one, but i can't give him the points...
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

910 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now