Cesar paisa:
Ya lo probe y hace lo mismo.. probe haciendo pruebas con cada uno de los motores de reportes, pero solo con tReport funciona..
/* File : Dosprin.prg
Autor : Jorge Mason
Wwww : http://www.htcsoft.cl
mail : htcsoft@iname.com
CopyRight : hctsoft
Version : 1.12
Description : CLASS for manage DOS printer
This version not need any .bat or .pif files
and work with any port printer like LPTx,COMx,\\netaddress,
and use Windows Spooler and setprinter method
*/
#include "FiveWin.ch"
#include "DosPrint.ch"
CLASS TDosPrint
DATA aLines
DATA aFonts
DATA cPrinter
DATA cPort
DATA nHeight
DATA nLines
DATA hFile
DATA cFile
// Margins
DATA nLeft
DATA nRight
DATA nTop
DATA nBottom
// Position
DATA nLine
DATA nColumn
DATA nAlign
DATA nMultiLine
// Page Sizes
DATA nWidth
DATA nLength
// Font
DATA cFont
// Estos data son para las variables
DATA CPIMedium
DATA CPINormal
DATA CPICompress
DATA CPILarge
DATA CPIBold
DATA CPITiny
DATA CPINoTiny
DATA CPIImage
DATA CPIHeader
DATA CPIFooter
DATA CPIJump
DATA CPIFormFeed
DATA CPILength
METHOD End()
METHOD NewPage()
METHOD New(nLeft,nRight,nTop,nBottom,nAlign,nWidth,nLength,cPort,cPrinter,nHeight) CONSTRUCTOR
METHOD Paint(nLine,nColumn,uData,nAlign,nWidth)
METHOD Say(nLine,nColumn,uData,nWidth,lNextLine,nAlign,lDuplicate,lMultiline)
METHOD SetFont(cFont,nWidth,nLeft,nRight)
METHOD SetPrinter(cPrinter)
METHOD SetHeight(nHeight) INLINE ::nHeight := nHeight
ENDCLASS
METHOD End() CLASS TDosPrint
LOCAL nWSOV := 2 //ObtWinSOVer()
FCLOSE( ::hFile )
IF ISWINNT() //nWSOV == 1
// Para Windos NT/W2K/XP --------------------------------
WAITRUN("cmd.exe /c copy /b " + ::cFile + " " + ::cPort , 0 )
ELSE
// Para Windows 9x ---------------------------------------
WAITRUN("command.com /c copy /b " + ::cFile + " " + ::cPort , 0 )
ENDIF
FERASE( ::cFile )
RETURN nil
METHOD NewPage() CLASS TDosPrint
LOCAL nStep
LOCAL nUltima := LEN(::aLines)
FWRITE( ::hFile , CPILength + CHR(::nHeight) + CPIHeader )
WHILE EMPTY(::aLines[nUltima])
--nUltima
END
FOR nStep = 1 TO nUltima
FWRITE( ::hFile , ::aFonts[nStep] + TRIM(::aLines[nStep]) + CRLF )
NEXT
FWRITE( ::hFile , CPIFormFeed + CPIFooter )
AFILL(::aLines,SPACE(500))
AFILL(::aFonts,"")
::nLine = ::nTop + 1
::nColumn = 1
SysRefresh()
RETURN nil
METHOD Paint(nLine,nColumn,uData,nAlign,nWidth,lDuplicate) CLASS TDosPrint
LOCAL linea := nLine + ::nTop
LOCAL cLine
IF nLine + ::nTop <= ::nLength - ::nBottom .AND. ;
nLine > ::nTop
cLine = ::aLines[nLine+::nTop]
DO CASE
CASE nAlign = ALEFT
uData = PADR(uData,nWidth)
CASE nAlign = ARIGHT
uData = PADL(uData,nWidth)
CASE nAlign = ACENTER
IF nWidth > LEN(uData)
uData = PADR(SPACE((nWidth-LEN(uData))/2)+uData,nWidth)
ELSE
uData = PADR(uData,nWidth)
ENDIF
ENDCASE
cLine = LEFT(cLine,nColumn-1+::nLeft) + uData + SUBS( cLine , (nColumn+LEN(uData)+::nLeft) )
IF lDuplicate
cLine = PADR( PADR(cLine,::nWidth) + PADR(cLine,::nWidth) , 500 )
ENDIF
::aLines[nLine+::nTop] = cLine
::aFonts[nLine+::nTop] = ::cFont
ENDIF
RETURN nil
METHOD Say(nLine,nColumn,uData,nWidth,lNextLine,nAlign,lDuplicate,lMultiline) CLASS TDosPrint
LOCAL nNext := 0
LOCAL cLine
LOCAL nAt
DEFAULT uData := "" ,;
nWidth := LEN( cValToChar(uData) ) ,;
nAlign := ALEFT ,;
lDuplicate := .F. ,;
lNextLine := .F. ,;
lMultiLine := .F.
IF nLine = nil
nLine = MIN( ::nLine + IF( lNextLine , MAX(::nMultiLine,1) , 0 ) , ::nLength )
IF lNextLine
::nMultiLine = 0
ENDIF
ENDIF
IF nColumn = nil
IF lNextLine
nColumn = 1
ELSE
nColumn = ::nColumn
ENDIF
ENDIF
uData = cValtoChar( uData )
IF lMultiLine
WHILE !EMPTY(uData)
IF ( nAt := AT(CRLF,uData) ) < nWidth .AND. ;
nAt > 0
cLine = Saca(@uData,CRLF)
ELSE
cLine = Corta(@uData,nWidth)
ENDIF
::Paint(nLine+nNext,nColumn,cLine,nAlign,nWidth,lDuplicate)
++nNext
IF nLine + nNext > ::nLength - ::nBottom
::NewPage()
nLine = ::nTop + 1
nNext = 0
ENDIF
::nMultiLine = MAX( ::nMultiLine , nNext )
END
ELSE
::Paint(nLine,nColumn,uData,nAlign,nWidth,lDuplicate)
ENDIF
::nColumn = nColumn + nWidth
::nLine = nLine
RETURN nil
METHOD SetFont(cFont,nWidth,nLeft) CLASS TDosPrint
DEFAULT cFont := CPINormal ,;
nWidth := ::nWidth ,;
nLeft := ::nLeft
::cFont := cFont
::nWidth := nWidth
::nLeft := nLeft
RETURN nil
METHOD New( nLeft,nRight,nTop,nBottom,nAlign,nWidth,nLength,cPort,cPrinter,nHeight) CLASS TDosPrint
DEFAULT nLeft := 0 ,;
nRight := 0 ,;
nTop := 0 ,;
nBottom := 0 ,;
nAlign := ALEFT ,;
nWidth := 80 ,;
nLength := 66 ,;
cPort := "LPT1" ,;
cPrinter := "IBM-PROPRINTER" ,;
nHeight := 11
::cPort := cPort
::cPrinter := cPrinter
::nLeft := nLeft
::nRight := nRight
::nTop := nTop
::nBottom := nBottom
::nAlign := nAlign
::nWidth := nWidth
::nLength := nLength
::nLine := ::nTop + 1
::nColumn := 1
::nMultiLine := 1
::cFont := ""
::aLines := ARRAY(nLength)
::aFonts := ARRAY(nLength)
::hFile := FCREATE( ::cFile := L2HEX(GETTICKCOUNT()) , 0 )
AFILL(::aLines,SPACE(500))
AFILL(::aFonts,"")
::SetPrinter(cPrinter)
::SetHeight(nHeight)
RETURN Self
METHOD SetPrinter(cPrinter) CLASS TDosPrint
LOCAL oIni
LOCAL cCompress
LOCAL cNormal
LOCAL cMedium
LOCAL cLarge
LOCAL cBold
LOCAL cTiny
LOCAL cNoTiny
LOCAL cImage
LOCAL cHeader
LOCAL cFooter
LOCAL cJump
LOCAL cFormFeed
LOCAL cLength
INI oIni FILE "Dosprint"
GET cNormal SECTION cPrinter ENTRY "Normal" OF oIni DEFAULT "27,70,27,84,27,50,27,15,18"
GET cBold SECTION cPrinter ENTRY "Bold" OF oIni DEFAULT "27,18,27,69"
GET cMedium SECTION cPrinter ENTRY "Medium" OF oIni DEFAULT "27,70,27,58"
GET cCompress SECTION cPrinter ENTRY "Compress" OF oIni DEFAULT "27,70,27,84,27,15"
GET cLarge SECTION cPrinter ENTRY "Large" OF oIni DEFAULT "27,69,27,18,27,14"
GET cTiny SECTION cPrinter ENTRY "Tiny" OF oIni DEFAULT "27,70,27,83,0,27,49,18,15"
GET cNoTiny SECTION cPrinter ENTRY "NoTiny" OF oIni DEFAULT "27,70,27,84,27,50"
GET cImage SECTION cPrinter ENTRY "Image" OF oIni DEFAULT "27,76"
GET cHeader SECTION cPrinter ENTRY "Header" OF oIni DEFAULT ""
GET cFooter SECTION cPrinter ENTRY "Footer" OF oIni DEFAULT ""
GET cJump SECTION cPrinter ENTRY "Jump" OF oIni DEFAULT "216"
GET cFormFeed SECTION cPrinter ENTRY "FormFeed" OF oIni DEFAULT "12"
GET cLength SECTION cPrinter ENTRY "Length" OF oIni DEFAULT "27,67,0"
ENDINI
CPINormal = cPrnCodes( cNormal )
CPIBold = cPrnCodes( cBold )
CPIMedium = cPrnCodes( cMedium )
CPICompress = cPrnCodes( cCompress )
CPILarge = cPrnCodes( cLarge )
CPITiny = cPrnCodes( cTiny )
CPINoTiny = cPrnCodes( cNoTiny )
CPIImage = cPrnCodes( cImage )
CPIHeader = cPrnCodes( cHeader )
CPIFooter = cPrnCodes( cFooter )
CPIJump = cPrnCodes( cJump )
CPIFormFeed = cPrnCodes( cFormFeed )
CPILength = cPrnCodes( cLength )
RETURN nil
FUNCTION cPrnCodes(cPrnCodes,cDelimited)
LOCAL cCodes := ""
DEFAULT cDelimited := ","
WHILE !EMPTY(cPrnCodes)
cCodes += CHR( VAL( Saca(@cPrnCodes,cDelimited) ) )
END
RETURN cCodes
FUNCTION Corta(cVar,nAt)
LOCAL cReturn := LEFT( cVar , nAt )
cVar = SUBS( cVar , nAt + 1 )
RETURN TRIM(cReturn)
FUNCTION Saca(cVariable,cString,lUpper,lLtrim)
LOCAL nPosition
LOCAL cResult
DEFAULT lUpper := .f. ,;
lLTrim := .f.
nPosition := AT( cString , IF( lUpper , UPPER(cVariable) , cVariable ) + cString )
cResult := LEFT( cVariable , nPosition - 1 )
cVariable = SUBS( cVariable , nPosition + LEN(cString) )
cVariable = IF( lLtrim , LTRIM(cVariable) , cVariable )
RETURN cResult
#define ALEFT 0
#define ARIGHT 1
#define ACENTER 2
STATIC CPIMedium
STATIC CPINormal
STATIC CPICompress
STATIC CPILarge
STATIC CPIBold
STATIC CPITiny
STATIC CPINoTiny
STATIC CPIImage
STATIC CPIHeader
STATIC CPIFooter
STATIC CPIJump
STATIC CPIFormFeed
STATIC CPILength
#xcommand @ <nLine>,<nColumn> DPSAY <uData> ;
OF <oPrinter> ;
[ WIDTH <nWidth> ] ;
[ ALIGN <nAlign> ] ;
[ <lDuplicate: DUPLICATE> ] ;
[ <lMultiline: MULTILINE> ] ;
=> ;
<oPrinter>:Say(<nLine>,<nColumn>,<uData>,<nWidth>,.F.,<nAlign>,<.lDuplicate.>,<.lMultiline.>)
#xcommand ? <uData> ;
OF <oPrinter> ;
[ WIDTH <nWidth> ] ;
[ ALIGN <nAlign> ] ;
[ <lDuplicate: DUPLICATE> ] ;
[ <lMultiline: MULTILINE> ] ;
=> ;
<oPrinter>:Say(,,<uData>,<nWidth>,.T.,<nAlign>,<.lDuplicate.>,<.lMultiline.>)
#xcommand ?? <uData> ;
OF <oPrinter> ;
[ WIDTH <nWidth> ] ;
[ ALIGN <nAlign> ] ;
[ <lDuplicate: DUPLICATE> ] ;
[ <lMultiline: MULTILINE> ] ;
=> ;
<oPrinter>:Say(,,<uData>,<nWidth>,.F.,<nAlign>,<.lDuplicate.>,<.lMultiline.>)
#xcommand DEFINE DOS PRINTER <oPrinter> ;
[ ALIGN <nAlign> ] ;
[ TOP <nTop> ] ;
[ BOTTOM <nBottom> ] ;
[ LEFT <nLeft> ] ;
[ RIGHT <nRight> ] ;
[ WIDTH <nWidth> ] ;
[ LENGTH <nLength> ] ;
[ PORT <cPort> ] ;
[ PRINTER <cPrinter> ] ;
[ PAPER <nInches> ] ;
=> ;
<oPrinter> := TDosPrint():New(<nLeft>,<nRight>,<nTop>,<nBottom>,<nAlign>,<nWidth>,<nLength>,<cPort>,<cPrinter>,<nInches>)
#xcommand SET FONT <cFont> OF <oPrinter> ;
[ WIDTH <nWidth> ] ;
[ LEFT <nLeft> ] ;
=> ;
<oPrinter>:SetFont(<cFont>,<nWidth>,<nLeft>)
#xcommand NEWPAGE OF <oPrinter> ;
=> ;
<oPrinter>:NewPage()
#xcommand END OF <oPrinter> ;
=> ;
<oPrinter>:End()
[IMPRESORAS]
Numero=7
Impresora001=IBM-PROPRINTER
Impresora002=OKIDATA
Impresora003=EPSON
Impresora004=PANASONIC
Impresora005=XEROX
Impresora006=HP-LASER-II
Impresora007=GENERICA
[IBM-PROPRINTER]
Medium=27,70,27,58
Normal=27,70,27,84,27,50,27,15,18
Compress=27,70,27,84,27,15
Large=27,69,27,18,27,14
Bold=27,18,27,69
Tiny=27,70,27,83,0,27,49,18,15
NoTiny=27,70,27,84,27,50
Image=27,76
Header=
Footer=
Jump=216
FormFeed=12
[OKIDATA]
Medium=27,70,27,58
Normal=27,70,27,84,27,50,27,15,18
Compress=27,70,27,84,27,15
Large=27,69,27,18,27,14
Bold=27,18,27,69
Tiny=27,70,27,83,0,27,49,18,15
NoTiny=27,70,27,84,27,50
Image=27,76
Header=
Footer=
Jump=188
FormFeed=12
Length=27,67,0
[EPSON]
Medium=27,70,27,15,18,27,77
Normal=27,70,27,15,18,27,80
Compress=27,70,27,15
Large=27,70,27,15,18,27,14
Bold=27,69
Tiny=27,70,27,83,0,27,49,18,15
NoTiny=27,70,27,84,27,50
Image=27,75
Header=
Footer=
Jump=216
[PANASONIC]
Medium=27,70,27,58
Normal=27,70,27,84,27,50,27,18
Compress=27,70,27,84,27,15
Large=27,69,27,18,27,14
Bold=27,18,27,69
Tiny=27,70,27,83,0,27,49,18,15
NoTiny=27,70,27,84,27,50
Image=27,75
Header=
Footer=
Jump=216
[XEROX]
Medium=27,84,27,77
Normal=27,84,27,70,27,80
Compress=27,84,27,70,27,18,15
Large=27,84,27,70,27,80,27,14
Bold=27,84,27,69,27,80
Tiny=27,70,27,83,0,27,49,18,15
NoTiny=27,70,27,84
Image=27,76
Header=
Footer=
Jump=216
[HP-LASER-II]
Medium=27,40,115,45,51,66,27,40,115,49,50,72
Normal=27,40,115,45,51,66,27,40,115,49,48,72
Compress=27,40,115,45,51,66,27,40,115,49,54,46,54,54,72
Large=
Bold=27,40,115,51,66,27,40,115,49,48,72
Tiny=
NoTiny=
Image=
Header=
Footer=
Jump=216
FormFeed=12
[GENERICA]
Medium=
Normal=
Compress=
Large=
Bold=
Tiny=
NoTiny=
Image=
Header=
Footer=
Jump=216
Return to FiveWin para Harbour/xHarbour
Users browsing this forum: carlos vargas, Google [Bot] and 66 guests