PrintLen on Test

Moderator: Rathinagiri

User avatar
hmgchang
Posts: 240
Joined: Tue Aug 13, 2013 4:46 am
Location: Indonesia
Has thanked: 1 time
Been thanked: 4 times

Re: PrintLen on Test

Post by hmgchang » Sat Aug 23, 2014 6:21 am

Dear Sirs,

After applying your new PrintLen....
Attachments
testfontwidth on Microsoft XPS Document Writer.JPG
the PrintLen value... Pixel ? mm ?
testfontwidth on Microsoft XPS Document Writer.JPG (86.86 KiB) Viewed 2501 times
Just Hmg It !

User avatar
hmgchang
Posts: 240
Joined: Tue Aug 13, 2013 4:46 am
Location: Indonesia
Has thanked: 1 time
Been thanked: 4 times

Post by hmgchang » Fri Jun 05, 2015 9:15 pm

Dear Masters,

Till now I am still struggling with the correct string width printed by the PRINT DATA command, Anyone pls help !

TIA....

best rgds,
Chang
Just Hmg It !

User avatar
dragancesu
Posts: 714
Joined: Mon Jun 24, 2013 11:53 am
DBs Used: DBF, MySQL, Oracle
Location: Subotica, Serbia
Has thanked: 24 times
Been thanked: 149 times

Post by dragancesu » Fri Jun 05, 2015 10:42 pm

Each font is defined by the need to know the size, height and width character

example
PRIVATE cFontName: = "Courier", nFontSize: = 10, nFontHeight: = 5, nCharWidth = 2.5

and then it is easy

User avatar
hmgchang
Posts: 240
Joined: Tue Aug 13, 2013 4:46 am
Location: Indonesia
Has thanked: 1 time
Been thanked: 4 times

Post by hmgchang » Sat Jun 06, 2015 3:26 am

Thanks Mr. Dragancesu,

According to the syntax, i provide fontname, fontsize, fontattribute( B, I or U).
I dont understand how to define the nFontHeight and nCharWidth that related to
fontname and fontsize. Can you pls give me some advise or sample ?

TIA

best rgds,
Chang
Just Hmg It !

User avatar
dragancesu
Posts: 714
Joined: Mon Jun 24, 2013 11:53 am
DBs Used: DBF, MySQL, Oracle
Location: Subotica, Serbia
Has thanked: 24 times
Been thanked: 149 times

Post by dragancesu » Sat Jun 06, 2015 4:59 am

No table for it, print out and measure it
(might have but not looking)

when look:

Java have font functions https://docs.oracle.com/javase/tutorial ... gtext.html
but for display (pixel) and you need for print (mm)

User avatar
hmgchang
Posts: 240
Joined: Tue Aug 13, 2013 4:46 am
Location: Indonesia
Has thanked: 1 time
Been thanked: 4 times

Post by hmgchang » Tue Jun 16, 2015 10:56 pm

Dear Masters and Mr. Rathinagiri,

Thanks for the your printlen function.
I experimented and modified your printlen function,

Code: Select all

function printLen( cString, nFontsize, cFontname)
  cCreateFont := _HMG_CREATEFONT( OpenPrinterGetDC(), cFontname, nFontSize )
  nGetTextWidth := gettextwidth( OpenPrinterGetDC(), cString, cCreateFont )
	nWidth := nGetTextWidth * 25.4 / 600
	RETURN( ROUND( nWidth, 2))
	*- return round( nGetTextWidth * 0.0254 * nFontsize, 2 ) 
and the result,
printlen.JPG
printlen.JPG (76.3 KiB) Viewed 2375 times
it works but not perfectly, esp with the fontsize 8, any suggestions ?
_FontSizeWidth.zip
(3.41 KiB) Downloaded 109 times
Just Hmg It !

User avatar
hmgchang
Posts: 240
Joined: Tue Aug 13, 2013 4:46 am
Location: Indonesia
Has thanked: 1 time
Been thanked: 4 times

Post by hmgchang » Wed Jun 17, 2015 5:15 am

But on Epson L210 Color Printer, the formula should be :
nWidth := nGetTextWidth * 25.4 / 360

Now, my question is :
1. How to get the printer name selected ?
2. How the number 600 ( for HP LaserJet) or 360 ( Epson Color Printer) related to printer resolution ?

TIA
Just Hmg It !

Post Reply