Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to print LANDSCAPE? (without Report Form) 2

Status
Not open for further replies.

dbMark

Programmer
Apr 10, 2003
1,515
US
I've just tried running a custom landscape report in dBase 5 for DOS which I created with lots of custom loops, ifs, dos, etc. So this time I did not use CREATE REPORT, MODIFY REPORT, or REPORT FORM. All the printer codes worked except landscape! Even if the only printer code command I give is the one shown below without any other printer codes, it still fails to print landscape. When I went back to my code library, I noticed that all of my prior reports ran landscape successfully but I had always used REPORT FORM. Since I can't use a report form in this case, is there something I'm missing? Why will REPORT FORM do it but not my hand-written custom code using simple "?" and "??" commands (no "@ SAY")? Here's what I've researched so far and I'll post more when and if I determine a successful landscape fix.

??? CHR(27) + "&l#O" && traditional landscape command

(I also tried using ?? instead of ???. No differnece.)

Page Orientation Code # where:
0 = Portrait
1 = Landscape
2 = Reverse Portrait
3 = Reverse Landscape

Additional references I found:
thread290-247779
thread290-2358
thread697-676105 must put different families of printer codes in separate Esc sequences
thread697-677170 HP doc: can fail in mixed OS environment
 
Is the text wrapping or just truncating in your output? If the _wrap system variable = .T. and _rmargin = 80 (the default) then I think your output would wrap at column 80. I'm looking at dBaseIV, not 5 ,but suspect the system variables are still applicable.

Maybe I'm being too simplistic.

hth. Dennis
 
When I print (using HP LaserJet printers) the text does not wrap. I can set the other printer codes and I see them modify the text appropriately. I'm not talking about size, wrapping or fonts, just page orientation. It's just that LANDSCAPE doesn't do a thing, even by itself. I'm mystified why it will work for REPORT FORM on the same printers but not in other code.

??? CHR(27) + "&l#O" && traditional landscape command

I already know not to concatenate this printer code with other types of printer codes. They have "families" and so I usually precede each family with its own Esc code. So when I tested it, I commented out all other printer codes and it still failed.

Is this Microsoft telling me to hurry up already and convert it to OOP? The language is "only" 9 years old!
 
I noticed another unexpected issue, and it's with the same "family group" of printer codes (Esc+&l...) where I'm trying to control the line spacing. It prints about 6.5 LPI but I'm trying for 8 LPI. I'm going home and maybe tommorow I can think straight.

??? CHR(27) + "&l8D" && traditional landscape command

dbMark
 
After a good night's sleep, I concluded that the real issue was that the "REPORT FORM myReport TO PRINT" command was handling and sending the text output to the printer differently than my manual method.

A quick test proved successful. I had been mixing in the use of ? and ?? but actually in order for landscape and line spacing to remain set to my custom settings, I must use ??? in all printing. So now I'll remember that in order for all of the printer codes to remain in effect, I cannot use ? or ?? but instead must consistently use ??? when sending output to the printer.

Why did some printer settings (the ones in the "&l" PCL group) reset back to default when others didn't? Yet another of life's unknowns.

dbMark
 
dbMark - been there, done that, and drank a lot figuring it all out!!! Assuming an HP Laser Printer, the proper code for landscape printing is:

Esc + "&l1O"

an explanation:

Esc - the necessary escape code
& - signifies start of control sequence
l - lower case L
1 - signifies landscape orientation
O - Upper case O - signifies end of escape code

Personally, I use the following:

chr(027)+chr(038)+chr(108)+chr(049)+chr(079)

Also, it's best to set up your page codes in a logical manner. I start by sending a reset command followed by page orientation, anything to do with font type, size, color, and orientation, and then line spacing. I also use @,say commands to issue the codes. Why? Don't know really - I guess it's because that's the way I've always done it.

If you don't already have a copy of HP's PCL codes, you can download a PDF from their site.

Hope this helps....

There's always a better way. The fun is trying to find it!
 
I also determined that I could not set both landscape and line spacing in the same sequence and have both work on my HP LaserJets. This group or family of PCL codes is very finicky. I had to separate them so each had their own Esc code.

??? CHR(27)+"&l1O"+CHR(27)+"&l8D" && landscape and 8 LPI
 
I am also having the same problem printing to landscape using DB III Plus. I am not to familiar with dBASE, but have picked a lot up in the last week. I am able to print at least one report in Landscape, but if I exit the application and come back later to print the report again, it defaults back to printing in Portrait.
I've set dBASE up on WINXP using an HP Laserjet 5.
I used the codes posted by tviman.
Main question being, how do I get dbase to keep the landscape as the default.
 
I don't know if your printer has a setting to make landscape its default orientation. Either check your printer manual or search/ask on a printers forum such as forum697

I'd recommend resetting the printer before every print job.

??? CHR(27)+"E"

Then set the page orientation.

??? CHR(27)+"&l1O"

You can also set other printer codes but be forewarned that some settings may void the landscape setting if not sent to the printer exactly right.
 
Thank you for the quick response. I apologize for not considering mentioning that I have the default for the printer set to Landscape.
I was hoping to avoid having to retype the code in prior to every report, due to the fact that I am just setting this up for the Primary user (Data Entry) and I am trying to ensure that the menu.prg is extremely friendly. (I do not have any of the source code)
All the Posts for this thread have been extremely helpful and have allowed me to get further than I thought, thank once again.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top