Page 1 of 1

Method print() TWindow = diferences between Laser x Deskjet

Posted: Wed Aug 20, 2008 4:52 pm
by yury
Hi everyone !

This code below prints the dialog (obj is the parameter)...

In deskjet printer (300 dpi) works fine, but in laser printer (600 dpi) it´s not OK, the image on the paper is too small

It´s possible fixed this ?


Code: Select all | Expand

FUNCTION Printer_Dlg(obj)

LOCAL oPrinter

oPrinter := PrintBegin(obj:cTitle,.T.,.F.,NIL,.T.)

SysRefresh()

IF EMPTY( oPrinter:hDC )
   RETURN
ENDIF

oPrinter:SetLandscape()

oPrinter:StartPage()

SysRefresh()

obj:Print(oPrinter)

oPrinter:EndPage()

ENDPRINT

RETURN


regards

Posted: Wed Aug 20, 2008 5:18 pm
by James Bott
Yury,

This is from my notes.

James

-------------------------
The Hardcopy() method prints a graphic of the current window or dialog. Hardcopy is a method of TWindow. The syntax is:

oWnd:hardcopy( nScale, lUser )

There is no default for nScale. lUser defaults to .t. and calls up the printer setup dialog.

To call it from a dialog do:

oDlg:hardcopy(6, .f.)

The TWindows:hardcopy() method really should figure the default scale based on the resolution of the printer. Something like:

default nScale:= oPrn:nLogPixelX / 100

However here is a trick you can use to get the resolution of the current printer. Just define a temporary oPrn:

...ACTION (oPrn:=tprinter():new(),;
::hardcopy( int( oPrn:nLogPixelX()/100 ), .f. ), oPrn:end())

This won't work if you allow the user to select a printer by lUser being .t. (the default), so make sure you pass .f. Actually, it will still print but the scale will be off if the user selects a printer with a different resolution that of the current one.

Posted: Wed Aug 20, 2008 7:49 pm
by yury
Hello Mr.James, thanks for your suport !

I get your trick, it´s OK, but the :Print() allow you pass the <nScale> parameter...

In fact the :Hardcopy() calls :Print() internally...

I try your sugestion, calls :Hardcopy with a parameter <nScale> of the default printer...

And I try this way too:

Code: Select all | Expand

LOCAL oPrinter

oPrinter := PrintBegin( 'Testing', .T. , .F. , NIL , .T. )

SysRefresh()

IF EMPTY( oPrinter:hDC )
   RETURN
ENDIF

oPrinter:SetLandscape()

oPrinter:StartPage()

SysRefresh()

nScale = int(oPrinter:nLogPixelX()/100) 

obj:Print(oPrinter,,,nScale)

oPrinter:EndPage()

ENDPRINT


Unfortunately both don't work in Laser printer (prints a blank sheet), in Deskjet it´s OK...

Thanks for your help

Regards

Posted: Wed Aug 20, 2008 8:03 pm
by James Bott
You said your original code was working but the scale was wrong, correct?

I found this is the syntax for the Print() method:

Print( oTarget, nRow, nCol, nScale )

So change your line to:

obj:Print(oPrinter, 1, 1, 6)

And see if that works on the Laser.

James

Posted: Thu Aug 21, 2008 6:43 pm
by yury
Hello Mr.James,

I try this way:

Code: Select all | Expand

obj:Print(oPrinter, 1, 1, 6) 


But don´t work, print a blank sheet...

I thank you very much your help, but I quit...

I will think other way to print the dialog/screen...

Thank you again

Regards