Printer Object: How to print "portrait" and "landscape" on the same page?

  • Permalink
  • submit to reddit
  • Email
  • Follow


Hi,

hope there's a simple solution to this.
If so, I'd appreciate a short hint.

I'm trying to find out how to change the printing
directions for special lines.

Simple example:
I need to print a line from left to right and
another line from bottom to top on the same page.


It's supposed to look like this page
(imagine the bottom to top letters
to be turned 90=B0 to the left)

#############################
#                           #
#  d                        #
#  l                        #
#  r                        #
#  o                        #
#  w                        #
#                           #
#  o                        #
#  l                        #
#  l                        #
#  e                        #
#  hello world              #
#                           #
#############################

I tried

Printer.NewPage
Printer.CurrentY =3D 1000
Printer.CurrentX =3D 1000
Printer.Font.Name =3D "Arial"
Printer.Orientation =3D 1
Printer.Print "hello world"
Printer.CurrentY =3D 1000
Printer.CurrentX =3D 1000
Printer.Orientation =3D 2
Printer.Print "hello world"
Printer.EndDoc

This fails - I can't change Orientation within the document.

I'm using Visual Basic 4 - but also could use
Visual Basic 6 if necessary.

Any hints?

Regards,
Daniel

0
Reply bbc (3) 1/25/2005 8:45:58 AM

See related articles to this posting


"Daniel Jolt" <bbc@myway.com> wrote in message 
news:1106642758.525938.160330@z14g2000cwz.googlegroups.com...

> I need to print a line from left to right and another line from
> bottom to top on the same page. I'm using Visual Basic 4 -
> but also could use Visual Basic 6 if necessary.

In order to print rotated text to the VB printer object you need to create a 
rotated font. After you have created your rotated font you cannot use any of 
the Printer Object methods or access any of its properties (including its 
hDC property) or it will immediately "forget" the rotated font that you 
created. So, you need to print your text using the TextOut API. You also 
need to get the Printer.hDC and save it to a standard VB variable (Long) 
*before* you create the font and you need to use the "saved" hDC with the 
TextOut API, instead of Printer.hDC.

Try the following code. It will certainly work in VB5 and VB6, but I'm not 
sure about VB4. I think it might work in VB4, but even if it doesn't it 
should be possible for you to modify it slightly so that it does. Note that 
the Printer.CurrentX and Printer.CurrentY properties are not altered to new 
positions after the text has been printed (that is the standard behaviour of 
the TextOut API) so you will need to position each line of text on your 
page. You could always modify the code so that it does automatically do the 
standard "vbCrLf" thing after printing, but I prefer it as it is.

Also note that I have written the RotatedText routine as a simple "one off" 
text printing code just so that you can easily see what is going on. In many 
cases, of course, this is wasteful (in terms of time)because your rotated 
font is created and then destroyed each time you call the routine. So, if 
you wanted to print (say) twelve lines of text one after the other all 
rotated to the same angle then a rotated font would be created and destroyed 
twelve times. A far better way would be to create the rotated font just once 
(before you print the first of the twelve lines) and then destroy it only 
after you have printed the twelfth. I'm sure that you will be able to modify 
it to behave in that way if you wish. It will still work of course exactly 
as I have posted it, and the "wasted" time probably isn't a lot when 
compared to the very slow hardware response of the printer, but I just 
though I'd mention it to you.

Mike

Option Explicit
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 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 DeleteObject Lib "gdi32" _
(ByVal hObject As Long) 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

Private Sub RotatedText(textstring As String, angle As Long)
' Prints rotated text at the current printer x and y
' coordinates at a specified angle (in tenths of a degree
' in an anti clockwise direction (zero is normal text)
Dim MyHdc As Long
Dim oldmode As Long, xpix As Long, ypix As Long
Dim log_font As LOGFONT
Dim new_font As Long, old_font As Long
With Printer
  xpix = .ScaleX(.CurrentX - .ScaleLeft, .ScaleMode, vbPixels)
  ypix = .ScaleY(.CurrentY - .ScaleTop, .ScaleMode, vbPixels)
MyHdc = .hdc ' get the Printer.hDC and save it to a variable
End With
With log_font
 .lfEscapement = angle
 .lfHeight = (Printer.Font.Size * -20) / Printer.TwipsPerPixelY
 .lfFaceName = Printer.Font.Name & vbNullChar
 If Printer.Font.Bold = True Then
  .lfWeight = 700
 Else
  .lfWeight = 400
 End If
  .lfItalic = Printer.Font.Italic
  .lfUnderline = Printer.Font.Underline
 End With
new_font = CreateFontIndirect(log_font)
old_font = SelectObject(MyHdc, new_font)
TextOut MyHdc, xpix, ypix, textstring, Len(textstring)
SelectObject MyHdc, old_font
DeleteObject new_font
End Sub

Private Sub Command1_Click()
Dim angle As Long, s1 As String
Printer.ScaleMode = vbInches
Printer.Font.Name = "Times New Roman"
Printer.Font.Size = 14
' always start every print job with a simple Print statement
Printer.Print
Printer.CurrentX = 0
Printer.CurrentY = 4
s1 = "Hello World"
angle = 0 ' standard (no rotation)
RotatedText s1, angle
angle = 900 ' 90 degrees anticlockwise rotation
RotatedText s1, angle
Printer.EndDoc
End Sub





0
Reply mike5607 (1952) 1/25/2005 10:25:29 AM

>Try the following code. It will certainly work in VB5 and VB6, but I'm
not
>sure about VB4.

I tried this with VB4 and it works.
Thank's for posting such detailed instructions, Mike.

0
Reply bbc (3) 1/25/2005 11:02:18 AM
comp.lang.basic.visual.misc 10143 articles. 0 followers. Post

2 Replies
229 Views

Similar Articles

[PageSpeed] 29


  • Permalink
  • submit to reddit
  • Email
  • Follow


Reply:

Similar Artilces:

Printer Object: How to print "portrait" and "landscape" on the same page?
Hi, hope there's a simple solution to this. If so, I'd appreciate a short hint. I'm trying to find out how to change the printing directions for special lines. Simple example: I need to print a line from left to right and another line from bottom to top on the same page. It's supposed to look like this page (imagine the bottom to top letters to be turned 90=B0 to the left) ############################# # # # d # # l # # r # # o # # w ...

Splitting 2 pages/page landscape postscript file into two single page portrait pages
Hi, I am a newbie. I have a book.ps file which has all the pages, having two facing pages per portrait page like this: +---------------+--------------+ | | | | | | +---------------+--------------+ I want to split the two pages. I dont want to scan the pages and then make bulky images out of compact pdf file. The file was generated from a dvi and latex that are no longer available. The author has died. The ps was made to save the number of printed pages in an era before pdf. So there are two problems: (1) split the ps into single p...

Landscape Page among Portrait pages in Latex
Hi, How can I include/create a 'landscape' page among standard portrait pages? Suppose I have a big figure which I need to dedicate a 'landscape' page for it... Is there any package that allows us to do that? -- Regards, Edward WIJAYA SINGAPORE "Edward WIJAYA" <ewijaya@singnet.com.sg> writes: >Hi, >How can I include/create a 'landscape' page among standard portrait pages? >Suppose I have a big figure which I need to dedicate a 'landscape' page >for it... >Is there any package that allows us to do that? Have you looked at...

print
Hi we have an intranet site with a print function. We generate a "print friendly" version of a page, and the user can click a "print" button, which causes the javascript "print()" function to be called. Is it possible to allow the user to select whether the printout should be in portrait or landscape? I have seen examples on the web which set landscape - but this appears to be a global setting (so it will always be landscape). We would like to allow the user to check a checkbox or something - so they can decide at runtime if they print in portrait or landscape. ...

InDesign landscape and portrait pages
I want to have one landscape page and one portrait page. I had hoped to do it by having two masters but I can't figure out how to set the page orientation for anything except the whole document. In article <e43ain$qsb$1@sunburst.ccs.yorku.ca>, James <ask@me.com> wrote: > I want to have one landscape page and one portrait page. > I had hoped to do it by having two masters but I can't figure out how to > set the page orientation for anything except the whole document. You can't. Orientation is by document. On 5/12/06 7:51 PM, "James" wrote: >...

printing in landscape and portrait mode
Hi everyone.... &nbsp; In my application i have print option.I have given a combo box to select print orientation. &nbsp; In my code,i have used the vi's property print.orientation and i have set it to different as users choice. &nbsp; But the graph looks similar in all print outs despite of the mode selected by the user. &nbsp; Is there any way to rectify this? &nbsp; &nbsp; Thanks..... &nbsp; &nbsp; Thanks sir,for ur reply. &nbsp; What i was trying to do is just to print the graph differently taking the same parameter(for example,in MS Word we can tak...

Portrait and Landscape page orientation
Hi, I am intersted in having two different page orientations (portrait and landscape) on the same WORD file - landscape for longer tables, portrait for text and smaller tables. How can I do this? So far I am just using two separate WORD files. Page settings from File menu seems to affect the whole document. Thank you See my reply to your question about "Automatic numbering of pages". HTH Robert bobrics wrote: > Hi, > > I am intersted in having two different page orientations (portrait and > landscape) on the same WORD file - landscape for longe...

Portrait Page as title for landscape document
I typed a simple report in LaTeX using landscape option of geometry package. The entire report turns out just the way I want it to, but I need to create a title page for it. Is it possible to set its orientation (back) to portrait? ...

PDF:Writer pages landscape and portrait
Hi, Im creating a PDF report and throughout the PDF document there will be some pages that need to be landscape and some that need to portrait. I cant seem to find any documentation about inserting pages in the document with a different layout, it looks like the whole document needs to be on or the other when initialising pdf = PDF::Writer.new(:orientation => :landscape) I currently have the seperate parts of the document rendering individually so one option would be to merge them altogether when finished and use the page numbering to tie them together. Can anyone give some advice on th...

rotating to portrait when printing landscape pdf
I want to transform pdf in landscape into Fax TIFF format, rotating pages 90 degrees to fit the fax page . I'm using Ghostscript like this: gswin32c -dNOPAUSE -dBATCH -sDEVICE=tiffg3 -q -c "<< /Policies << /PageSize 5 >> /PageSize [595 842] /InputAttributes << 0 << /PageSize [595 842] >> >> >> setpagedevice" -f yourfile.pdf -sOutputFile=%2 %1 The command is not working with Ghostscript 8.53 With Ghostscript 8.00 everything worked fine. Another fax devices: faxg3, faxg32d and faxg4 are not working at all (Unknown device error). ...

Problem on Printing Text Twice with Portrait and Landscape
Basically my application creates a thread, reads in some text and prints it. It opens up the printDialog and if user selects Portrait and doing nothing else after that, it can print OK. Also, if user just selects Landscape it can print OK too. The problem is if the user selects Portrait and while the application is sending the data to the printer while the printer is printing, if the user does another printing at that time and selects Landscape, the result is ugly. It is possible the second printing misses some text or it is possible the first printing misses some text. Is it weird? If someb...

Report
How to do this? Code or .... ? Any suggestions? BR, Gox On Thu, 28 May 2009 14:35:43 +0200, Gox <goxmail77_MOVE_@gmail.com> wrote: Two reports. -Tom. Microsoft Access MVP >How to do this? >Code or .... ? >Any suggestions? > > >BR, >Gox That I thought. I already have such a solution. Thx Tom van Stiphout wrote: > On Thu, 28 May 2009 14:35:43 +0200, Gox <goxmail77_MOVE_@gmail.com> > wrote: > > Two reports. > > -Tom. > Microsoft Access MVP > > >> How to do this? >> Code or .... ? >> Any suggestions? >&...

Use Ghostscript to print PDFs with both landscape and portrait orientation?
I'm able to use redmon and Ghostscript to create a PDF document, but when I try printing that document (which contains both landscape and portrait pages) the landscape pages print as portrait. The command line syntax I'm using is: gswin32c -q -dSAFER -dNOPAUSE -dBATCH -sDEVICE=mswinpr2 -dNoCancel -sOutputFile="%printer%Snagit" test.pdf As mentioned, the portrait pages all print correctly, but the landscape pages do not. All text is correctly rotated so I can read it, but the page itself is still portrait so the right side of the text is cut off. Any ideas on how to...

gsprint windows pdf with mixed pages (landscape/portrait)
Hi, I am using gsprint to send to a printer a PDF file. Unfortunately, this file contains some pages in portrait orientation, and some others in landscape orientation. So, standard options -landscape or -portraint are irrelevant. Does somebody know a workaround ? Regards -- PhD hardGoose wrote: > I am using gsprint to send to a printer a PDF file. > Unfortunately, this file contains some pages in portrait orientation, > and some others in landscape orientation. > Does somebody know a workaround ? Um, yes, but it takes a bit of doing. Here's where you can look at an example: ...

Joining A5 landscape to make A4 portrait pages
My client has a large number of pdf files resulting from scanning their paper files. For a large bunch of these the scanner setting was wrong, and the A4 pages are scanned as A5 landscape (oops!). I've found that I can fix an individual file by using Acrobate Reader to print to PDF995 with multiple pages per page, plus some other tweaking in the printer options. What I need to be able to do is to now process hundreds of files, semi-automatically, eg by batch file. I've looked at PDFedit995, but it has trouble reading these pdf files apparently. In any case, I can't get any...

header, page number and fooer to appear straight up for portrait and landscape.. how?
In seminar class How to make the header, footer and page number to appear straight up for both portrait and landscape slides. For the land scape slides I get they are 90 degree rotated. My preamble are: \documentclass[fleqn,portrait]{seminar} \usepackage{semcolor} thanks for your experti advice in advance. -marsup ...

Printing Landscape/Portrait from OUTPUT window in UNIX (version 9.1.n)
I am trying to setup the a printer definition for our group of 80+ users. In our previous SAS version (6.12) I was able to setup two printers, one for landscape and for portrait by using the pipe destination and setting the UNIX command appropriatly (i.e. lp -dquename -o landscape). In version 9.1.n, however, the orientation parameter on the lp command is ignored and instead SAS uses the system option ORIENTATION only. This is a problem since I would like to print my code or the log in portrait and my ouput usually in landscape, but I have to first set OPTION ORIENTATION=..... to the proper s...

Portrait/Landscape
Does anyone know how to control portrait/landscape when you move a database to a new computer. It seems that these page setup settings are not saved. Would that be the same if one changed printers, or is it computer-based---could someone please explain this to me? Thanks David Averbach UC Bekeley The page setup script steps must be resaved every time the printer type changes. If you use your solution at several different locations, it is a definite advantage to use the same printer type at each location. If you have no control over this, you can get around endless tweaking by allowing t...

landscape and portrait in pdf
hello i have such problem: i want create a few landscape page in the midle of document. I use a package PORTLAND.STY. In dvi file i have a landscape and portrait page, but when i want convert dvi to pdf i have all pages in portrait mode. I try to employ also lscape.sty, but in this package footer and header are not turned. please help On 06-09-2005 7:57, zbiszko wrote: > i want create a few landscape page in the midle of document. I use a > package PORTLAND.STY. In dvi file i have a landscape and portrait page, > but when i want convert dvi to pdf i have all pages in portrait mode...

Portrait/Landscape problem
Hi, I'm calling Ghostscript 8.60 with commandline -dCompatibilityLevel#1.4 -sstdout=%stderr -q -dSAFER -dNOPAUSE -dBATCH -sDEVICE#pdfwrite -sOutputFile#"x.pdf" -c .setpdfwrite -f <some PS files> <some PDF files> to combine PS and PDF files to a single PDF. The portrait/landsacpe setting of the PS files is reproduced in the resulting PDF file. However, PDF input files with landscape format pages seem always to be inserted into the result PDF in portrait format, which cuts off a part of the pages. Is this a bug? Is there a commandline option to control the page forma...

Landscape vs. Portrait.
I'm working on an existing system printing postscript. I'm working on a Linux system. With my changes, I got things to work EXCEPT it is printing in Portrait mode, and it should be printing in Landscape mode. Is there a simple command in postscript that sets the mode to Landscape? In article <1192033005.772173.56680@57g2000hsv.googlegroups.com>, kmullin@amazon.com wrote: > I got things to work EXCEPT it is printing in Portrait mode, > and it should be printing in Landscape mode. Is there a simple > command in postscript that sets the mode to Landscape? 1) You can...

Landscape switching to portrait
I have a strange situation where one or more landscape reports that I created in A2000 sometimes come up in portrait mode when opened on an A2002 machine. This phenomenon is intermittent, and most of the time they come up in landscape. But every once in a while they come up in portrait, and the person opening them (as well as myself) doesn't have any idea why. Any ideas regarding this? Thanks, Neil Unless the change is due to a difference in printers/printer drivers between the machines, it is probably one of the Name AutoCorrect bugs. See: Lost Printer Settings When Name ...

Table
Hey :) I have a table on landscape paper (wide table), i would like to split it up, to fit on two portrait papers instead (so I can increase the text size) An alternative that I do not like, is to use A3 paper size instead of A4 (A3 is as large as two sheets of A4) Any suggestions ?? Best regards Per Per H P <nospam@nospam.dk> writes: >I have a table on landscape paper (wide table), i would like to split it >up, to fit on two portrait papers instead (so I can increase the text size) > >An alternative that I do not like, is to use A3 paper size instead of A4 >...

C6180 alternates between portrait and landscape
When printing legal-sized documents, the pages alternate between portrait and landscape. If I print 1 page at a time, then it prints portrait as it should. But if I print multiple pages, ever other page prints landscape using a font that is flattened and elongated (i.e. unreadable). This happens whether I am printing a PDF or Word document. I have Windows XP. I don't have the entire suite of C6180 utilities loaded because they were so buggy and I couldn't get my printer to work. I just have the basics loaded. Thanks Joe ...

Apple Patents Portrait-Landscape Flipping
<http://apple.slashdot.org/story/11/07/14/2330230/Apple-Patents-Portrait-Landscape-Flipping> <quote> "On Tuesday, the USPTO granted a patent to Apple for Portrait- landscape rotation heuristics for a portable multifunction device (USPTO), which covers 'displaying information on the touch screen display in a portrait view or a landscape view based on an analysis of data received from the one or more accelerometers.' Perhaps the USPTO Examiners didn't get a chance to review the circa-1991 Computer Chronicles video of the Radius Pivot monitor before deeming Apple...