Solved

Rotate Text to Printer?

Posted on 2000-04-09
9
229 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
Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

 

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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
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 utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

813 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

8 Experts available now in Live!

Get 1:1 Help Now