CompuServe Thread

#Printer Positioning

34 messages in this thread
#2861From: Bryon ScottOct 13, 1991 1:54 PM
O.K people, here's the routine: Sub PrintHeader (Header As String) Dim PageNo As String Printer.CurrentX = 0 Printer.Print Date$; Printer.CurrentX = (Printer.Width – Printer.TextWidth(Header)) Printer.CurrentX = Printer.CurrentX / 2 Printer.Print Header; PageNo = "Page: " + Format$(Printer.Page, "###") Printer.CurrentX = Printer.Width – Printer.TextWidth(PageNo) Printer.Print PageNo Printer.Print " " End Sub As I see it, this should print the date on the left edge of the page, the string Header should print in the center, and the string PageNo should print on the right edge. BUT, Header prints just off center, and only "Pa" prints on the right edge. Any geniuses out there that can figure this one out? Bryon Scott There are 2 Replies.
#2877From: Keith Funk/Vanc.BC,CAN.Oct 13, 1991 8:10 PM
Hi Bryon, I think the problem you are having is that Printer.Width returns the actual width of the paper in your printer without taking into account the unprintable boarder that Win3 imposes. On my dotmatrix printer, Printer.Width tells me that the paper is 12,240 twips wide (8.5 inches) which is correct. But the API GetDeviceCaps function tells me that the paper is only 203mm wide (8 inches) which is in fact the *printable* width. Win3 will just not print more than 8 inches wide on my printer. You are only getting 'Pa' printed on the right of your header because Win3 is truncating the text because it has reached the edge of the printable area as far as Win3 is concerned. Rather than using Printer.Width, try this. Declare GetDeviceCaps as follows: Declare Function GetDeviceCaps Lib "GDI" (ByVal hDC As Integer, ByVal nIndex As Integer) As Integer Compute the printable width in twips as follows. PWidth# = 1440# * GetDeviceCaps(Printer.hDC, 4) / 25.4 Use PWidth# in your computations rather than Printer.Width. Hope this helps. KeithF There are 2 Replies.
#2917From: john keslerOct 14, 1991 8:21 AM
Keith, Wouldn't it just be easier to assume that the .25" unprintable zone is there and work around/within it? john k There are 2 Replies.
#2969From: Dennis L. HarringtonOct 14, 1991 10:46 AM
John, If the unprintable border was .25" on all printers, then making that assumption would be fine. Unfortunately, that's definitely not the case. Each printer seems to be a little different. A user was having a printing problem with my app that I couldn't figure out. Finally in frustration, I installed all of the printer drivers on the windows install diskettes and ran GetDeviceCaps on all of them. Even within laser printers, there was as much as an 1/8" difference in printable dimensions. The quarter inch unprintable border is definitely not universal. What I found in my case was interesting (and frustrating). The user had an HP LJIIP with a PacificPage PS cartridge. Instead of tracking down the proper .WPD file for his printer, he just installed it as a LasereWriter IINTX as suggested by PacificPage. Unfortunately, the HP IIP has an 1/8" less verticle printable area than a LaserWriter, so the last line of each page was printing on a seperate page. So sometimes, even checking with GetDeviceCaps isn't enough, especially when the user lies to you. <g> –dennis There are 2 Replies.
#2985From: Keith PleasOct 14, 1991 12:29 PM
Dennis: Quick update on our earlier discussion: I just saw a message that version 2.4 of PrintCache was available in the UW MicroComputer Lab, and that LaserTools has a new product out called (I think) "Fonts on the Fly". They also listed a product called "Printer Control Panel". There is 1 Reply.
#3044From: Dennis L. HarringtonOct 14, 1991 5:20 PM
Keith, In my discussion with LserTools last week, they indicated that 2.3a was the most rescent release, but you know sales types. <g> Fonts On The Fly is a font generating program for WordPerfect. Printer Control Panel is a utility for laser printers that have both PS and LJ emulations. It determines the correct pdl used from each document file and automatically resets the printer emulation as needed. Seemed a little steep to me at $100. –dennis There is 1 Reply.
#3071From: Keith PleasOct 14, 1991 7:31 PM
Dennis: Hmm, I called them in the meantime, and was quoted $149 for Printer Control Panel. I have a IIP with the PDP cartridge, and they said they'd licensed it to PDP a while ago, but I never heard anything; since I'm the registered owner of three of four of these things, I DO get three copies of every mailing PDP sends out. Lastly, I asked about a Windows version of PrintCache, and was told that it will be out in another couple of weeks (gee, that's when COMDEX is happening; what a coincidence!). There is 1 Reply.
#3104From: Dennis L. HarringtonOct 14, 1991 11:20 PM
Keith, As to the Printer Control Panel price, I was probably extrapolating what it probably really costs through PC Connection. <g> On the subject of HP LJIIP's, do you have a postscript .WPD for the printer, or do you set it up as a LaserWriterII NTX as recommended by Pacific Page? A user of my app was having problems loosing the last line on every print page (actually, it printed on a page by itself), and it turned out that the printable area on an NTX is about .14" longer than on a LJIIP. This just happens to be almost exactly 1 line of helvetica 12pt text. What's the world coming to when people will purposely lie to good old friendly GetDeviceCaps? <G!> –dennis There is 1 Reply.
#3121From: Keith PleasOct 15, 1991 1:33 AM
Dennis: Hmm, your problem sounds VERY similar to a problem I had about a year ago (actually, I still have the problem but just gave up). In my case, I was printing a WFW document with spacing hard set to 12pts next to a field of embedded PostScript code, and no matter what I did WFW printed everything just a little bit bigger, causing me to lose a half a line over the course of 10". The answer I eventually got back from MS was that it was a conversion problem between twips and points, and was inherent to Windows. Seemed like a bogus answer to me, but I'd hit the wall and had to drop the application I was developing; there was no point in embedding PostScript if I couldn't be sure of it's EXACT position on the page relative to the text. But to answer your question, yes I've gone through the .WPD add-in route, and that only helped to crash the printer more often with large files (as from PowerPoint). I also tried the two semi-revved drivers that Aldus put out. I also tried to get some support from PDP, but never managed to get in touch with anyone who knew anything more than the stuff on the spec sheet. Anyway, there's a new PS driver for Win 3.1, so I can't see anybody putting any more effort into getting the existing piece of junk to work well. There is 1 Reply.
#3213From: Dennis L. HarringtonOct 15, 1991 11:34 AM
Kieth, Thanks for the input! –dennis
#3063From: john keslerOct 14, 1991 6:51 PM
Dennis, Thanks for the information on the "UnPrintable Zone" (sounds like a Rod Serling TV show). I thought that .25" was some kind of standard. Thanks for clearing it up. john k There is 1 Reply.
#3105From: Dennis L. HarringtonOct 14, 1991 11:20 PM
John, There's also another very good reason to use GetDeviceCaps to determine the printable page size. If you know the actual printable page length, it's then easy to adjust your printing to any length paper. Compute the number of verticle twips on the page and subtract whatever you want for top and bottom margins and 1 line of text. Then just print from some form of loop and increment the CurrentY yourself by the number of verticle twips required for each line. Each time you increment the CurrentY, test the new value against the maximum computed above. If the new CurrentY is greater than the maximum, you've filled the page and it's time to start a new page. This is especially handy with laser printers may be use either letter or legal size paper. Another really nice API function for printing is SetTextAlign. By default, windows aligns text characters based on the top of each character's cell. If you use only one font in a document, that's fine. But if you want to use several fonts, this can result in some funny looking typography because their base lines don't lineup, even if they're the same point size. By resetting the text alignment to TA_BASELINE which aligns characters on their typographical baselines, you can now mix different fonts and different sizes and they line up correctly. If you do this, just remember that with base aligned text, CurrentY is the text baseline and not the top of the character cell. Printing the first line with CurrentY = 0 will only print the descenders of text characters on that line. –dennis There is 1 Reply.
#3147From: john keslerOct 15, 1991 8:06 AM
Dennis, Thanks for the SetTextAlign() API tip. I've run into the exact problem you described before, and didn't know how to get around it. Now I do… 🙂 john k
#2978From: Keith Funk/Vanc.BC,CAN.Oct 14, 1991 12:10 PM
Hi John, I don't think it's really a good idea to assume that an unprintable zone exists for all printer drivers. I've only checked two – the Epson 9 pin and HP Laser II. Other drivers may have different values. KeithF There are 3 Replies.
#2998From: George CampbellOct 14, 1991 1:12 PM
Keith, You're right, the unprintable area, if any, is different on all printers. There are good solutions in the API, but then again, you can fake them all out by assuming a slighly larger margin in your apps. You'll print a little farther from the edge, but you'll compensate for most printers, if totally accurate page design isn't needed. Again, one of George's funky solutions that works nevertheless. George There is 1 Reply.
#3003From: Keith Funk/Vanc.BC,CAN.Oct 14, 1991 1:59 PM
Hi George, So the unprintable area does vary from printer to printer. Thanks. KeithF There is 1 Reply.
#3053From: Bryon ScottOct 14, 1991 6:04 PM
I found a solution. Instead of using Printer.Width & Printer.Height, use the Printer.ScaleWidth and Printer.ScaleHeight properties. This returns the printable height and width. Bryon Scott There are 2 Replies.
#3056From: George CampbellOct 14, 1991 6:32 PM
Bryon, It's true that ScaleWidth/Height returns the actual printable area, but be careful with these two properties, especially if you're setting Printer.CurrentX and CurrentY. If you change these figures, you revert to the User setting for ScaleMode, and that can throw your printing off. It's OK, however, to read these properties. George
#3112From: Keith Funk/Vanc.BC,CAN.Oct 14, 1991 11:50 PM
Hi Bryon, The Scale.Width returns the printable area? Well, I'll be damned. Thanks. Now do you know anyone who needs a 100 pages of paper that only contain a partial header at the top of each page?<g> KeithF There is 1 Reply.
#3161From: George CampbellOct 15, 1991 9:08 AM
Keith, Isn't developing a printer-intensive application a joy? You get to give your friends with children piles and piles of scratch paper for them to draw pretty pictures on. You also get lots of time to scratch your head waiting for the printer to spew out your pages. The app I'm currently working on includes graphics on the page as well. That's even more fun. I have time for coffee every time I make a change. George There is 1 Reply.
#3464From: Don FunkOct 16, 1991 6:26 PM
Hi George, You can duplicate all printing to go to a picture control that is scaled to the printer. Then when you have proved that your code it "good", then change the "picture" to "printer" in your code and you should get the same. I solved the problem with one piece of paper, after I tested it in the picture control. (my printer is too far away for trial and error<g>) Don Funk There is 1 Reply.
#3557From: George CampbellOct 17, 1991 9:02 AM
Don, You're absolutely right. Setting up a scaled picture box, then writing to it makes it easy to print. As long as you keep the ScaleMode the same for the box and the printer, you can basically just do a find/replace to switch from picture to print. The only place that's not true is when you're doing stuff like lines, etc. and bitmaps. Since the resolution of the screen is so much different than that of the printer, you can get some interesting shifts on the screen image of your page or whatever. They're small, but can be significant in the long run. George
#3064From: john keslerOct 14, 1991 6:51 PM
Keith, >"I don't think it's really a good idea to assume that an > unprintable zone exists for all printer drivers…" So I learned from Dennis. I guess the only "real" solution is to insist on a 1" border all the way around! <big grin> john k
#3072From: Keith PleasOct 14, 1991 7:31 PM
KeithF: Well, I think it would be correct to say that there IS an unprintable region for all printers, but that it differs from printer to printer and MAY be 0" in any particular dimension (particularly top & bottom). The book "Printer Information for MS Word" lists the unprintable regions for LOTS of printers. A sampling: TOP BOTTOM LEFT RIGHT ALPS LPX600 = 0.33 0.25 0.15 0.41 Apple Imagewriter II = 0.00 0.00 0.25 0.25 Apple LasterWriter = 0.22 0.33 0.25 0.25 Canon BJ-130 Bubble Jet = 0.67 0.25 0.50 0.25 Canon BJ-130e Bubble Jet = 0.66 0.50 0.25 0.25 Epson FX Series = 0.00 0.00 0.00 0.50 HP LaserJet Series II = 0.20 0.20 0.17 0.33 HP LaserJet IIP = 0.17 0.17 0.25 0.25 HP LaserJet Series III = 0.20 0.20 0.25 0.25 I think that this stuff is stored in the printer driver itself, and is exported to your application. There aren't specific entries in the DEVMODE data structure for margins, so I think's it's burried in the dmDriverData field and may be handled differently for different devices. I think you'll need the DDK to get any further. There are 2 Replies.
#3111From: Keith Funk/Vanc.BC,CAN.Oct 14, 1991 11:50 PM
Hi Keith, Thanks for the list of unprintable zones. It's almost as long as the list of errogen…naw, let's not get into that.<g> KeithF
#3117From: Dennis L. HarringtonOct 15, 1991 12:55 AM
Kieth, I'm not sure I'd trust those figures too much. Do a GetDeviceCaps on your LJIIP with the standard windows PCL driver, and I think you'll find the top and bottom unprintable areas are closer to .375". –dennis There are 2 Replies.
#3162From: George CampbellOct 15, 1991 9:12 AM
Dennis, If that's true about the GetDeviceCaps and the PCL driver, then calling it is just about worthless. The actual unprintable area on a Series II is almost exactly .20, as measured from an actual printout which prints off the edges of both sides of the page. If accuracy is critical, then the figure you mentioned won't give you what you need. What I'm doing these days is just assuming .33 for all my stuff, then adjusting from there. That wouldn't work for printing on pre-printed forms, but it seems to work OK when dimensioning isn't critical. George There is 1 Reply.
#3214From: Dennis L. HarringtonOct 15, 1991 11:34 AM
George, The discrepency with the LJIIP was more with height than width. And the problem wasn't with the PCL driver. It reported the correct values. It was the substitution of the LaserWriter IINTX driver when the IIP was using the PDP PS cartridge. The NTX driver reports the printable sizes for the NTX which are different than those of the HPLJIIP. In the end, the whole problem is really PDP's. They should provide a good .WPD file for the IIP is they're going to sell PS carts for it, IMHO. –dennis
#3215From: Keith PleasOct 15, 1991 11:39 AM
Dennis: The PCL driver? I thought we were talking about the PSCRIPT driver. That's what I've used the .WPD method for (there's one for a IIP with a PostScript cartridge). Are we crossing wires? There is 1 Reply.
#3263From: Dennis L. HarringtonOct 15, 1991 4:58 PM
Kieth, You're correct. We were discussing a .WPD for the LJIIP in PostScript mode. I just used the PCL driver suplied with windows to check the printable area for these printers as I don't have one. Hope I haven't muddied the waters too much. –dennis There is 1 Reply.
#3304From: Keith PleasOct 15, 1991 9:24 PM
Dennis: There's a program in the back of Ross Smith's book "Learning PostScript: A Visual Approach" that shows you how to query the RIP to get stuff like this. Running it on my setup showed: – Product: PacificPage – Version: 4.06 – Revision: 0 – Language Level: 1 – Total Memory: 597 Kb – Available Memroy: 526 Kb – Max. Image Width: 7.9133 inches – Max. Image Height: 10.6233 inches Let me know if you want the code. There is 1 Reply.
#3347From: Dennis L. HarringtonOct 16, 1991 12:02 AM
Keith, Thank's for the info. As I read it, it dawned on me, there is a feature in Costas Kitsos' WinPSX font downloader that wrings this information out of a printer. Costas' will even make it list every resident font. My big problem is that my only printer is a NEC LC890 and a DeskJet, so I have to rely on the MS drivers when I need to experiment with other printer values. Thnaks again. –dennis
#3192From: Don FunkOct 15, 1991 10:45 AM
Hi Keith, You may want to look at the example about ScaleWidth that I sent Bryon. Don Funk
#3191From: Don FunkOct 15, 1991 10:45 AM
Hi Bryon, Use Scale[Width/Height] for your computation. Scale[Width/Height] will give you the client area which is the printable area. Don Funk Sample code… Sub Command1_Click () Dim PageNo As String Header$ = "Yess" Printer.CurrentX = 0 Printer.Print Date$; Printer.CurrentX = (Printer.ScaleWidth – Printer.TextWidth(Header$)) Printer.CurrentX = Printer.CurrentX / 2 Printer.Print Header$; PageNo = "Page: " + Format$(12, "###") Printer.CurrentX = Printer.ScaleWidth – Printer.TextWidth(PageNo) Printer.Print PageNo Printer.Print " " Printer.EndDoc End Sub