Page 1 of 1
Impresion de Variable/Campos Memos Just.
Posted: Tue Aug 25, 2009 10:18 am
by dobfivewin
Estimados...
Estoy realizando una impresión (tprinter) de una Variable o Campo MEMO de esta forma:
Code: Select all
FOR I = 1 TO MLCOUNT((ECOINTE)->V_TEXT,85.5)
oPrn:CmSay( line, If((ECOINMO)->IMP_IMDE==0,5.5,2+Espacio),;
MEMOLINE((ECOINTE)->V_TEXT,85.5,I) ,oFont22,,,,0)
line := Ctrl_InfEco(oPrn,line,0.5)
NEXT I
La consulta es:
como puedo agregar espacios entre las palabras de la linea a Imprimir, es para que me cubra el renglon en forma pareja.
La Idea es que la impresión de total la Variable o Campo MEMO quedaria en forma Justificada.
Se me ocurre es calcular que tamaño deberia tener es espacio a imprimir (final de 85.5 segun mi ejemplo) e ir agregando espacios es blanco entre la palabras hasta que llegue a cubrir dicho tamaño.
El tema es que NO SE calcular el tamaño total de renglon.
muchas gracias
Salu2
David
Argentina
Re: Impresion de Variable/Campos Memos Just.
Posted: Tue Aug 25, 2009 4:47 pm
by dobfivewin
Se puede saber cuantos centimetro mide lo que quiero imprimir
Code: Select all
oPrn:CmSay( line, If((ECOINMO)->IMP_IMDE==0,5.5,2+Espacio),;
MEMOLINE((ECOINTE)->V_TEXT,85.5,I) ,oFont22,,,,0)
Salu2
David
Re: Impresion de Variable/Campos Memos Just.
Posted: Wed Aug 26, 2009 9:01 am
by dobfivewin
Se puede o busco otra alternativa
graicas
David
Re: Impresion de Variable/Campos Memos Just.
Posted: Wed Aug 26, 2009 11:06 am
by RenOmaS
Utiliza SetTextJustification
Code: Select all
----
SetTextJustification( oPrn:hDCOut, nWidth - oPrn:GetTextWidth( cText, oFont ), nTemp ) //nTemp : numero de espacios que tiene el texto
oPrn:Say(
SetTextJustification( oPrn:hDCOut, 0, 0 )
//ten presente que esto es por una linea, no se como funciona cuando tieen CRLF
Salu2
Re: Impresion de Variable/Campos Memos Just.
Posted: Wed Aug 26, 2009 1:36 pm
by ADBLANCO
Aqui Tienes un Ejemplo
Espero te sirva
Code: Select all
******************************************************************************************
FUNCTION Imp_MemoW(cTxt,nline,nLpos,nWid,nFont,nSkp)
******************************************************************************************
// cTxt - dato tipo memo, en relidad basta con que sea texto
// nLpos - posicion en cm del inicio del texto en la linea
// oPrn - objeto TPrinter
// nWid - ancho mAximo de texTo (en cmt)
// oFont - fuente (Numero Salida)
// nSkp - salto o espaciado por renglon
// nClr - color
// Nota solo para usar con salida()
LOCAL cLin, lCont:=.T., nP:=0, lNext, cC, nW,cFont,cPatron,nIp,nlcT,nCol := 1,nRow := 1
DEFAULT nSkp := 01.0
DEFAULT nWid := 19.0
DEFAULT nFont:= 01.0
DEFAULT nLpos:= 01.6
oPrn:Cmtr2Pix(0,@nWid)
cTxt := Alltrim(cTxt)
nW := nWid-0.2
cFont := "oFont"+STR(IIF(nFont<7 .and. nFont>0,nFont,1),1)
DO WHILE lCont // un desmadre para separar
cLin := cC := "" // y justificar los memos!!
lNext := .T.
DO WHILE oPrn:GetTextWidth(cLin,&cFont)<nWid .AND. nP<=Len(cTxt) .AND. lNext
nP++
cC:=Substr(cTxt,nP,1)
IF ASC(cC)<>13
cLin+=cC
ELSE
nP++
lNext := .F.
ENDIF
ENDDO
IF ASC(cC)<>13 .AND. ASC(cC)<>0
CPATRON := CLIN
cC := Substr(cTxt,nP+1,1)
IF " "$cLin .AND. cC<>" "
ELSE
// palabra cortada, retrocede
nIp := 1
nlct := len(clin)
DO WHILE Substr(cLin,nlct-nIp,1)<>" " .and. nIP<nlct
nIp++
ENDDO
IF nIp>0
cLin := SubStr(cLin,1,nlct-nIp-1)
nP -=nIp
ENDIF
ENDIF
DO WHILE cC<>" " .AND. Len(cLin)>0
cLin := Substr(cLin,1,Len(cLin)-1)
cC := Right(cLin,1)
nP--
ENDDO
nlct := len(clin)
DO WHILE oPrn:GetTextWidth(cLin,&cFont)<nWid // JUSTIFICADO
nIp := 1
DO WHILE oPrn:GetTextWidth(cLin,&cFont)<nWid .and. nIP<nlct
nIP++
DO WHILE Substr(cLin,nlct-nIp,1)<>" " .and. nIP<nlct
nIp++
ENDDO
IF Substr(cLin,nlct-nIp,1)=" "
cLin := Substr(cLin,1,nlct-nIp-1)+" "+SubStr(cLin,nlct-nIp,len(clin))
nIp++
ENDIF
ENDDO
ENDDO // FIN DEL JUSTIFICADO
pagina(1)
nline:=line
PSAY3(line,nLpos,cLin,nFont)
nline += nSkp
line := nline
ELSE
pagina(1)
nline:=line
PSAY3(line,nLpos,cLin,nFont)
nline += nSkp
line := nline
ENDIF
IF nP >= Len(cTxt)
lCont := .F.
ENDIF
ENDDO
RETURN nline