Solved

Rotate Text to Printer?

Posted on 2000-04-09
9
225 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
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 
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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
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…
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…

759 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

19 Experts available now in Live!

Get 1:1 Help Now