Hello Everyone, I am having inconsistancy problems when setting the paper size on printer. We are trying to set the paper size to 4 inches wide by 6 inches high on a thermal printer that only prints 4 by 6 labels. However, when we send output to printer it prints at 8.5 by 11 ignoring our printer size request. My source code is listed below, can anyone provide sample code that will resolve my problem. I thank you in advance for your assistance.
// Paper Size...
nPWid := 254 * 4
nPHgt := 254 * 6
PrnSetSize( nPWid, nPHgt )
PRINT oPrinter FROM USER NAME "M/R Package Detail Label " + ALLTRIM( cPartno ) PREVIEW
/* Check if Object is Empty */
if empty( oPrinter:hDC )
return nil
endif
// Fonts...
DEFINE FONT oFont1 NAME "Arial" SIZE 0,-24 BOLD OF oPrinter
DEFINE FONT oFont2 NAME "Arial" SIZE 0,-18 OF oPrinter
DEFINE FONT oFont3 NAME "Arial" SIZE 0,-10 OF oPrinter
DEFINE FONT oFont4 NAME "Arial" SIZE 0,-8 OF oPrinter
// Init...
Mwidth = oPrinter:nHorzRes()
Mheight = oPrinter:nVertRes()
M_hgt = oPrinter:GetTextHeight("X", oFont3 )
SELECT (cTmpDb)
GO TOP
DO WHILE ! EOF()
IF EMPTY( (cTmpdb)->prt )
SKIP
LOOP
ENDIF
// Start...
PAGE
M_row = ROUND( Mheight * .03, 2)
M_rto = ROUND( Mheight * .13, 2)
M_col = ROUND( Mwidth * .05, 2)
M_cto = ROUND( Mwidth * .25, 2)
IF FILE(cLogo)
DEFINE BITMAP oLogo FILENAME cLogo
oPrinter:SayBitmap( M_row, M_col, cLogo, (M_cto-M_col), M_row+(M_rto-M_row) )
ENDIF
// Header...
Mrow := ROUND( Mheight * .03, 0)
FOR nX=1 TO LEN( aHeader )
M_dat = aHeader[nX]
M_col = ROUND( Mwidth * .40,0)
M_hgt = oPrinter:GetTextHeight("X", oFont4 )
oPrinter:Say( Mrow, M_col, M_dat, oFont4 )
Mrow += M_hgt
NEXT nX
// Part No...
Mrow := ROUND( Mheight * .20, 0)
M_dat = "PART NUMBER"
M_wid = oPrinter:GetTextWidth(M_dat, oFont4 )
M_col = ROUND( Mwidth * .50,0) - (M_wid/2)
M_hgt = oPrinter:GetTextHeight("X", oFont4 )
oPrinter:Say( Mrow, M_col, M_dat, oFont4 )
Mrow += M_hgt
M_dat = ALLTRIM( cPartno )
M_wid = oPrinter:GetTextWidth(M_dat, oFont2 )
M_col = ROUND( Mwidth * .50,0) - (M_wid/2)
M_hgt = oPrinter:GetTextHeight("X", oFont2 )
oPrinter:Say( Mrow, M_col, M_dat, oFont2 )
Mrow += M_hgt
// Barcode...
@Mrow, M_col CODE128 M_dat of oPrinter MODE 'A'
Mrow += M_hgt
Mrow += M_hgt
Mrow += M_hgt
// Init...
nW = 28
nN = MLCOUNT( (cTmpdb)->desc, nW, 0, .T.)
IF nN>2
nN := 2
ENDIF
FOR nZ = 1 TO nN
M_dat = MEMOLINE( (cTmpdb)->desc, nW, nZ )
M_wid = oPrinter:GetTextWidth(M_dat, oFont3 )
M_col = ROUND( Mwidth * .50,0) - (M_wid/2)
M_hgt = oPrinter:GetTextHeight("X", oFont3 )
oPrinter:Say( Mrow, M_col, M_dat, oFont3 )
Mrow += M_hgt
NEXT nZ
Mrow += M_hgt
// Serial...
Mrow := ROUND( Mheight * .50, 0)
M_dat = "SERIAL / CCL NUMBER"
M_wid = oPrinter:GetTextWidth(M_dat, oFont4 )
M_col = ROUND( Mwidth * .50,0) - (M_wid/2)
M_hgt = oPrinter:GetTextHeight("X", oFont4 )
oPrinter:Say( Mrow, M_col, M_dat, oFont4 )
Mrow += M_hgt
M_dat = ALLTRIM( (cTmpdb)->number )
M_wid = oPrinter:GetTextWidth(M_dat, oFont2 )
M_col = ROUND( Mwidth * .50,0) - (M_wid/2)
M_hgt = oPrinter:GetTextHeight("X", oFont2 )
oPrinter:Say( Mrow, M_col, M_dat, oFont2 )
Mrow += M_hgt
// Barcode...
@Mrow, M_col CODE128 M_dat of oPrinter MODE 'A'
// Date-Time...
Mrow := ROUND( Mheight * .75, 0)
M_dat = "DATE / TIME"
M_wid = oPrinter:GetTextWidth(M_dat, oFont4 )
M_col = ROUND( Mwidth * .50,0) - (M_wid/2)
M_hgt = oPrinter:GetTextHeight("X", oFont4 )
oPrinter:Say( Mrow, M_col, M_dat, oFont4 )
Mrow += M_hgt
M_dat = DTOC( DATE() )
M_wid = oPrinter:GetTextWidth(M_dat, oFont4 )
M_col = ROUND( Mwidth * .25,0) - (M_wid/2)
M_hgt = oPrinter:GetTextHeight("X", oFont4 )
oPrinter:Say( Mrow, M_col, M_dat, oFont4 )
M_dat = TIME()
M_wid = oPrinter:GetTextWidth(M_dat, oFont4 )
M_col = ROUND( Mwidth * .75,0) - (M_wid/2)
M_hgt = oPrinter:GetTextHeight("X", oFont4 )
oPrinter:Say( Mrow, M_col, M_dat, oFont4 )
Mrow += M_hgt
Mrow += M_hgt
// Packer...
Mrow := ROUND( Mheight * .90, 0)
M_dat = "PACKER NAME"
M_wid = oPrinter:GetTextWidth(M_dat, oFont4 )
M_col = ROUND( Mwidth * .50,0) - (M_wid/2)
M_hgt = oPrinter:GetTextHeight("X", oFont4 )
oPrinter:Say( Mrow, M_col, M_dat, oFont4 )
Mrow += M_hgt
// End page...
ENDPAGE
SELECT (cTmpdb)
SKIP
ENDDO
// End...
ENDPRINT
nPWid := 254 * 8.5
nPHgt := 254 * 11
PrnSetSize( nPWid, nPHgt )
PrnSetPage(1)
// Release Fonts...
RELEASE oFont1
RELEASE oFont2
RELEASE oFont3
RELEASE oFont4