Page 1 of 1

To Rick

Posted: Mon Feb 04, 2019 11:37 pm
by FranciscoA
Hi Rick.
Is this code still working for you, on any printer?
I not be able to obtain the same look on other printers.
Thanks.

Spanish:
Hola rick
¿Este código sigue funcionando para usted en cualquier impresora?
No puedo obtener el mismo aspecto en otras impresoras.
Gracias.

The example takes advantage of the horizontal and vertical properties of the print driver to allow the output to resolve and look ( almost ) identical on any printer.

Code: Select all | Expand

oFont8b   := TFont():New( "Times New Roman", 0,-8, .F.,.T. , , , ,.F.,,,,,,, oPRINT, )
oFont10   := TFont():New( "Times New Roman", 0,-10,.F.,.F. , , , ,.F.,,,,,,, oPRINT, )
oFont10b  := TFont():New( "Times New Roman", 0,-10,.F.,.T. , , , ,.F.,,,,,,, oPRINT, )
oFont12ib := TFont():New( "Times New Roman", 0,-12,.F.,.T. , , , ,.T.,,,,,,, oPRINT, )
oFont12b  := TFont():New( "Times New Roman", 0,-12,.F.,.T. , , , ,.F.,,,,,,, oPRINT, )
oFont14b  := TFont():New( "Times New Roman", 0,-14,.F.,.T. , , , ,.F.,,,,,,, oPRINT, )
oFont24b  := TFont():New( "Times New Roman", 0,-24,.F.,.T. , , , ,.F.,,,,,,, oPRINT, )

DEFINE FONT oFont10d  NAME "Courier New" SIZE 0,-10 of oPRINT
DEFINE PEN oPen1 WIDTH 5 //10

nLines    := 0
nPages    := 1

nRowStep := oPrint:nVertRes() / 55      // pixel per line = 57.65 @ 55
nColStep := oPrint:nHorzRes() /130      // columns

oPRINT:StartPage()

nMargin := Int(oPrint:nLogPixelX()*0.5)      // *0.2
LINE    := nMargin
nPage   := 1


...
...

// company
oPRINT:SAY ( LINE, (oPrint:nHorzRes()*.07), cOwner, oFONT14b )
Line += oFont8b:nHeight
Line += oFont10b:nHeight

oPRINT:SAY ( LINE, (oPrint:nHorzRes()*.07), cDivision , oFONT12b )
oPRINT:SAY ( LINE, (oPrint:nHorzRes()*.69),cInvoiceType, oFONT12b )
Line += oFont10b:nHeight

oPRINT:SAY ( LINE, (oPrint:nHorzRes()*.07), cAdd1 , oFONT12b )

oPRINT:SAY ( LINE, (oPrint:nHorzRes()*.69),"INVOICE", oFONT24b )
Line += oFont10b:nHeight

oPRINT:SAY ( LINE, (oPrint:nHorzRes()*.07), cAdd2 , oFONT12b )
Line += oFont10b:nHeight

oPRINT:SAY ( LINE, (oPrint:nHorzRes()*.07), alltrim(cCity)+", "+cState+" "+cZip, oFONT12b )
Line += oFont12b:nHeight
Line -= oFont8b:nHeight

oPRINT:SAY ( LINE, (oPrint:nHorzRes()*.69),cRepairNumber, oFONT14b )

Line += oFont24b:nHeight
Line += oFont24b:nHeight
Line += oFont8b:nHeight

Line += oFont12b:nHeight
Line += oFont12b:nHeight

oPRINT:SAY ( LINE, (oPrint:nHorzRes()*.07), cCustName, oFONT12b  )
oPRINT:SAY ( LINE, (oPrint:nHorzRes()*.69),"Cust Id     :", oFONT10b )
oPRINT:SAY ( LINE, (oPrint:nHorzRes()*.79),cCustomerId, oFONT10 )
Line += oFont12b:nHeight

oPRINT:SAY ( LINE, (oPrint:nHorzRes()*.07), cCustAdd1, oFONT12b  )
oPRINT:SAY ( LINE, (oPrint:nHorzRes()*.69),"Bill Date   :", oFONT10b ) // 775
oPRINT:SAY ( LINE, (oPrint:nHorzRes()*.79),dtoc( dInvDate ), oFONT10 )
Line += oFont12b:nHeight

...
...

Re: To Rick

Posted: Tue Feb 05, 2019 3:43 pm
by Rick Lipkin
Francisco

Yes .. I am still using this code in my programs today ...

oPRINT:SAY ( LINE, (oPrint:nHorzRes()*.07), cOwner, oFONT14b ) .. the oPrint:nHorzRes() is the calculation derived from the oPrint object which is your defined printer.

This calculation allows the printed content to be placed on the page at the same ( visual ) co-ordinates regardless if the printer .. laserjet, deskjet ...

Rick Lipkin

Re: To Rick

Posted: Tue Feb 05, 2019 6:13 pm
by FranciscoA
Rick.
Thanks for your reply. I'll do some tests.
Regards.

Re: To Rick

Posted: Thu Feb 07, 2019 4:25 pm
by FranciscoA
Hi Rick.
I did tests on different printers and it works fine.
Thanks.

Re: To Rick

Posted: Fri Feb 08, 2019 4:48 pm
by Rick Lipkin
Francisco

Thank you for the feedback .. you are welcome

Rick Lipkin