Impresion de Variable/Campos Memos Just.

Impresion de Variable/Campos Memos Just.

Postby dobfivewin » Tue Aug 25, 2009 10:18 am

Estimados...

Estoy realizando una impresión (tprinter) de una Variable o Campo MEMO de esta forma:
Code: Select all  Expand view
       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. :roll:
El tema es que NO SE calcular el tamaño total de renglon. :oops:

muchas gracias

Salu2

David
Argentina
dobfivewin
 
Posts: 325
Joined: Sun Feb 03, 2008 11:04 pm
Location: Argetnina

Re: Impresion de Variable/Campos Memos Just.

Postby dobfivewin » Tue Aug 25, 2009 4:47 pm

Se puede saber cuantos centimetro mide lo que quiero imprimir :?:

Code: Select all  Expand view
oPrn:CmSay( line, If((ECOINMO)->IMP_IMDE==0,5.5,2+Espacio),;
                     MEMOLINE((ECOINTE)->V_TEXT,85.5,I) ,oFont22,,,,0)


Salu2

David
dobfivewin
 
Posts: 325
Joined: Sun Feb 03, 2008 11:04 pm
Location: Argetnina

Re: Impresion de Variable/Campos Memos Just.

Postby dobfivewin » Wed Aug 26, 2009 9:01 am

Se puede o busco otra alternativa

graicas

David
dobfivewin
 
Posts: 325
Joined: Sun Feb 03, 2008 11:04 pm
Location: Argetnina

Re: Impresion de Variable/Campos Memos Just.

Postby RenOmaS » Wed Aug 26, 2009 11:06 am

Utiliza SetTextJustification
Code: Select all  Expand view

----
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
Saludos/regards
RenOmaS

skype: americo.balboa
User avatar
RenOmaS
 
Posts: 205
Joined: Fri Oct 07, 2005 5:07 pm

Re: Impresion de Variable/Campos Memos Just.

Postby ADBLANCO » Wed Aug 26, 2009 1:36 pm

Aqui Tienes un Ejemplo

Espero te sirva

Code: Select all  Expand view
******************************************************************************************
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
 
Saludos

Angel, Valencia, Venezuela

xH .997 - FW 7.9 - BCC55 - WorkShop - MySql
User avatar
ADBLANCO
 
Posts: 299
Joined: Mon Oct 22, 2007 3:03 pm
Location: Valencia - Venezuela


Return to FiveWin para Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 92 guests