by James Bott » Tue Jun 23, 2020 12:21 am
Hi Tim,
Tim,
I haven't done anything like this in a long time, but below (after my signature) is a note from my FW printing notes file. Keep in mind that everything from the colon on is a remark. I don't know why I did it that way now.
I am not sure exactly what you are trying to accomplish, but here are some options:
To find out how many characters of a specific font will fit in a specific width you will have to create a function that calculates it in pixels. Generally, one uses the widest character (usually a W or M). Just create a DO WHILE loop that keeps adding a new "W" until it exceeds the printable width of the printer page. Then subtract 1. Now any combination of characters will fit. Alternatively, you could do a similar thing with the real characters. You would keep adding the real text, character by character until is exceeds the printable width, then subtract everything up to the last space and print. Tedious.
I assume there is some reason you can't just let the printer object handle all this for you? If you are doing some kind of a special report where you need to fit a string of characters on one line without word wrapping, then maybe you need to process the entire report looking for the longest line, then find the font width that will be required to print that line.
Complicated stuff.
Regards,
James
--------------------------------------------
12/8/2006 7:58 PM - JBott
Here are two sets of data from different devices (both for 8.5x11 inch paper). Previously, I assumed that nHorzRes() was the dimension of the paper but it is the printable area of the page. All the vars refer to the printable area except for GetPhySize().
oPrn:cModel: HP DeskJet 420,winspool,LPT1:
oPrn:nHorzRes(): 2400 [2400/300 dpi = 8 inches]
oPrn:nVertRes(): 3025 [3025/300 dpi = 10.1 inches]
oPrn:nLogPixelx(): 300
oPrn:nLogPixely(): 300
oPrn:nXOffset: 75
oPrn:nYOffset: 75
oPrn:nHorzSize() : 203 mm = 8.0 in
oPrn:nVertSize() : 256 mm = 10.1 in
oPrn:GetPhySize()[1]: 215.900 [ 215.9 mm / 25.4 = 8.5 in ]
oPrn:GetPhySize()[2]: 279.400 [ 279.4 mm / 25.4 = 11 in ]
8.5 in * 300 dpi = 2550 pixels - (2 * nXOffset ) = 2400
===========================
oPrn:cModel: hp officejet 5500 series,winspool,USB001
oPrn:nHorzRes(): 4800
oPrn:nVertRes(): 6258
oPrn:nLogPixelx(): 600
oPrn:nLogPixely(): 600
oPrn:nXOffset: 150
oPrn:nYOffset: 42
oPrn:nHorzSize() : 203 mm = 8 in
oPrn:nVertSize() : 264 mm = 10.4 in
oPrn:GetPhySize()[1]: 215.900
oPrn:GetPhySize()[2]: 279.400
FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10