Cansado de que mis reportes se deformen segun los diferentes tipos/MARCAS de impresoras: PdfCreator, HP DeskJet 305, Canon iP2700 y otros, decidi modificar la clase tReport de la siguiente forma:
Defini dos nuevas datas
- Code: Select all Expand view
DATA lAutoFit, lReFit
El el metodo New() las inicialice
- Code: Select all Expand view
::lAutoFit := .f.
::lReFit := .f.
En el metodo Activate() añadi el siguiente codigo (es el que hace el Fit (Ajuste), disminuyendo el tamaño de los FONT)
- Code: Select all Expand view
if ::lReFit
do while !::lStable .AND. ::nRptWidth > ( ::nWidth - ::nLeftMargin - ::nRightMargin )// .and. ( ::lScreen .or. ::lPrinter )
Aeval(::aFont,;
{|oFont,elem,oNewFont| ;
oNewFont:= TFont():New( oFont:cFaceName ,;
INT(oFont:nWidth * 0.999) ,;
INT(oFont:nHeight * 0.999),;
.F. ,;
oFont:lBold ,;
oFont:nEscapement ,;
oFont:nOrientation ,;
oFont:nWeight ,;
oFont:lItalic ,;
oFont:lUnderline ,;
oFont:lStrikeOut ,;
oFont:nCharSet ,;
oFont:nOutPrecision ,;
oFont:nClipPrecision ,;
oFont:nQuality ),;
oFont:End(),;
::aFont[elem] := oNewFont })
::Stabilize()
enddo
endif
En el metodo Stabilize() modifique el siguiente codigo
- Code: Select all Expand view
if ::nRptWidth > ( ::nWidth - ::nLeftMargin - ::nRightMargin ) .and. ( ::lScreen .or. ::lPrinter )
if ::lAutoLand .and. ;
! ::lIsNarrow .and. ;
::oDevice:GetOrientation() == PORTRAIT
::lStable := .f.
::lIsNarrow := .t.
return nil
endif
if ::lAutoFit
::lStable := .f.
::lReFit := .t.
return nil
endif
if ! MsgYesNo( TXT_REPORT_WIDTH, TXT_ATENTION )
::lStable := .f.
return nil
endif
endif
Y lo uso de la siguiente forma:
- Code: Select all Expand view
oRpt:=TReport():New(...)
oRpt:lAutoFit := .T.
y todo perfecto por el momento...
Por favor si alguien puede revisarlo y probarlo para ver si funciona bien o hay que mejorar algo.
Atentamente,
Rolando.
Cochabamba, Bolivia