Page 2 of 3

Re: TReport samples

PostPosted: Sun Apr 28, 2013 2:37 pm
by ADutheil
Code: Select all  Expand view
#include "fivewin.ch"
#include "report.ch"

FUNCTION PrnDisVav
LOCAL dData := date() + 1
LOCAL oRepo
LOCAL oFon1
LOCAL oFon2

IF SeleDatRep( @dData )
    disv->( ordSetFocus( "DNOM" ), ordScope( 0, dToS( dData ) ), ordScope( 1, dToS( dData ) ), dbGoTop() )
    DEFINE FONT oFon1 NAME "ARIAL" SIZE 0,-8
    DEFINE FONT oFon2 NAME "ARIAL" SIZE 0,-10 BOLD
    REPORT oRepo TITLE  "ENTREGA DE VENDA AVULSA DE " + dToC( dData ), "JORNAL DO COMÉRCIO DE PETROLINA" ;
          FOOTER "PrnDisVav             Emissão:" + dToC( date() ) + " " + time() + " PAG:("+ allTrim( str( oRepo:nPage, 4 ) ) + ")", "" RIGHT CAPTION "RELATÓRIO PrnDisVav" FONT oFon1, oFon2 PREVIEW
        COLUMN TITLE "PONTO DE VENDA"       DATA disv->NOME
        COLUMN TITLE "QTD"                  DATA disv->REPA TOTAL
        COLUMN TITLE "DETAILS"              DATA "" SIZE 40
    END REPORT
    IF oRepo:lCreated()
        oRepo:oTitle:aFont[ 1 ]:= { || 2 }
        oRepo:oTitle:aFont[ 2 ]:= { || 2 }
        oRepo:oHeader:aFont[ 1 ] := { || 2 }
        oRepo:Margin( .1, RPT_RIGHT )
        oRepo:bStartRecord := { || oRepo:box( oRepo:nRow / oRepo:oDevice:nLogPixelY, oRepo:nMargin/oRepo:oDevice:nLogPixelX, ( oRepo:nRow + oRepo:nStdLineHeight) / oRepo:oDevice:nLogPixelY, RightMargin( oRepo ) / oRepo:oDevice:nLogPixelX , 1 )  }
    ENDIF
    ACTIVATE REPORT oRepo  ON CHANGE SayDetails( oRepo )
    oFon1:End()
    oFon2:End()
    disv->( ordScope( 0, NIL ), ordScope( 1, NIL ), dbSkip( 0 ) )
ENDIF
RETURN ( NIL )


FUNCTION RightMargin( oRepo )
LOCAL nRight := oRepo:nMargin

AEval( oRepo:aColumns, { | v | nRight += v:nWidth } )
nRight += ( ( Len( oRepo:aColumns )- 1 ) * oRepo:nSeparator )
RETURN nRight


FUNCTION SayDetails( oRepo )
LOCAL nI

oRepo:BackLine( 1 ) // remove this line if you want details to begin the line after master
FOR nI := 1 TO 4
    oRepo:StartLine()
    oRepo:Say( 3, "Detail " + str( nI ) )
    oRepo:EndLine()
NEXT
oRepo:Newline()
RETURN NIL
 

Re: TReport samples

PostPosted: Mon Apr 29, 2013 1:22 pm
by mosh1
ADutheil wrote:The test I wrote seems OK:

It seems depend on the device - different printers give me different results. Perhaps TReport is performing some internal calculation which is wrong.

Re: TReport samples

PostPosted: Mon Apr 29, 2013 2:11 pm
by Antonio Linares
Mosh, André,

When fonts are going to be created for different printers, we should do:

DEFINE FONT oFon1 NAME "ARIAL" SIZE 0,-8 OF oPrinter

Where oPrinter is a PRINTER object previously created:

PRINTER oPrinter ...

Re: TReport samples

PostPosted: Mon Apr 29, 2013 2:54 pm
by ADutheil
Try this way:

Code: Select all  Expand view
FUNCTION PrnDisVav
LOCAL dData := date() + 1
LOCAL oRepo
LOCAL oFon1
LOCAL oFon2

IF SeleDatRep( @dData )
    disv->( ordSetFocus( "DNOM" ), ordScope( 0, dToS( dData ) ), ordScope( 1, dToS( dData ) ), dbGoTop() )
    DEFINE FONT oFon1 NAME "ARIAL" SIZE 0,-8
    DEFINE FONT oFon2 NAME "ARIAL" SIZE 0,-10 BOLD
    REPORT oRepo TITLE  "ENTREGA DE VENDA AVULSA DE " + dToC( dData ), "JORNAL DO COMÉRCIO DE PETROLINA" ;
          FOOTER "PrnDisVav             Emissão:" + dToC( date() ) + " " + time() + " PAG:("+ allTrim( str( oRepo:nPage, 4 ) ) + ")", "" RIGHT CAPTION "RELATÓRIO PrnDisVav" FONT oFon1, oFon2 PREVIEW
        COLUMN TITLE "PONTO DE VENDA"       DATA disv->NOME GRID
        COLUMN TITLE "QTD"                  DATA disv->REPA TOTAL GRID
        COLUMN TITLE "DETAILS"              DATA "" SIZE 40 GRID
    END REPORT
    IF oRepo:lCreated()
        oRepo:oTitle:aFont[ 1 ]:= { || 2 }
        oRepo:oTitle:aFont[ 2 ]:= { || 2 }
        oRepo:oHeader:aFont[ 1 ] := { || 2 }
        oRepo:Margin( .1, RPT_RIGHT )
        oRepo:bStartRecord := { || oRepo:separator() }
        //oRepo:bStartRecord := { || oRepo:box( oRepo:nRow / oRepo:oDevice:nLogPixelY, oRepo:nMargin/oRepo:oDevice:nLogPixelX, ( oRepo:nRow + oRepo:nStdLineHeight) / oRepo:oDevice:nLogPixelY, RightMargin( oRepo ) / oRepo:oDevice:nLogPixelX , 1 )  }
    ENDIF
    ACTIVATE REPORT oRepo  ON CHANGE SayDetails( oRepo )
    oFon1:End()
    oFon2:End()
    disv->( ordScope( 0, NIL ), ordScope( 1, NIL ), dbSkip( 0 ) )
ENDIF
RETURN ( NIL )


FUNCTION RightMargin( oRepo )
LOCAL nRight := oRepo:nMargin

AEval( oRepo:aColumns, { | v | nRight += v:nWidth } )
nRight += ( ( Len( oRepo:aColumns )- 1 ) * oRepo:nSeparator )
RETURN nRight


FUNCTION SayDetails( oRepo )
LOCAL nI

//oRepo:BackLine( 1 )
oRepo:separator()
FOR nI := 1 TO 4
    oRepo:StartLine()
    oRepo:Say( 3, "Detail " + str( nI ) )
    oRepo:EndLine()
NEXT
oRepo:Newline()
RETURN NIL
 

Re: TReport samples

PostPosted: Mon Apr 29, 2013 3:14 pm
by HunterEC
André:

Can you show a sample of your report's output so we can learn of all the thing the code is doing ?

Thank you very much, muito obrigado.

Re: TReport samples

PostPosted: Mon Apr 29, 2013 3:42 pm
by ADutheil
With the 2 way. First one was already uploaded.

Image

Uploaded with ImageShack.us

Re: TReport samples

PostPosted: Mon Apr 29, 2013 5:32 pm
by mosh1
Antonio Linares wrote:Mosh, André,

When fonts are going to be created for different printers, we should do:

DEFINE FONT oFon1 NAME "ARIAL" SIZE 0,-8 OF oPrinter

Where oPrinter is a PRINTER object previously created:

PRINTER oPrinter ...


This produce huge font size and there is no place for report on a page.

Re: TReport samples

PostPosted: Mon Apr 29, 2013 5:51 pm
by Antonio Linares
Mosh,

Have you tried to use a smaller font size ? i.e.:

DEFINE FONT oFon1 NAME "ARIAL" SIZE 0,-4 OF oPrinter

Re: TReport samples

PostPosted: Mon Apr 29, 2013 7:30 pm
by ADutheil
Antônio, I did try but had to go down to -1.

Re: TReport samples

PostPosted: Mon Apr 29, 2013 7:54 pm
by Antonio Linares
André,

Ok, but did it properly shown on different printers ? thanks for the tests :-)

Re: TReport samples

PostPosted: Mon Apr 29, 2013 8:57 pm
by ADutheil
I just instaled another printer (Epson Stylus 85) and it did not work.

Actualy using oRepo:bStartRecord := { || oRepo:separator() } ( test version 2 ) it works. oRepo:bStartRecord := { || oRepo:box( oRepo:nRow / oRepo:oDevice:nLogPixelY, oRepo:nMargin/oRepo:oDevice:nLogPixelX, ( oRepo:nRow + oRepo:nStdLineHeight) / oRepo:oDevice:nLogPixelY, RightMargin( oRepo ) / oRepo:oDevice:nLogPixelX , 1 ) } works with cutepdf writer but not with Epson. I probably messed something in the box params.

Re: TReport samples

PostPosted: Mon Apr 29, 2013 9:22 pm
by mosh1
ADutheil wrote:I just instaled another printer (Epson Stylus 85) and it did not work.

Actualy using oRepo:bStartRecord := { || oRepo:separator() } ( test version 2 ) it works. oRepo:bStartRecord := { || oRepo:box( oRepo:nRow / oRepo:oDevice:nLogPixelY, oRepo:nMargin/oRepo:oDevice:nLogPixelX, ( oRepo:nRow + oRepo:nStdLineHeight) / oRepo:oDevice:nLogPixelY, RightMargin( oRepo ) / oRepo:oDevice:nLogPixelX , 1 ) } works with cutepdf writer but not with Epson. I probably messed something in the box params.


I reduced font size to -1

Now the results of testing :

In CutePDF and Foxit Reader PDf Printer master data fits perfectly in the box. Microsoft Office Document Image Writer works too.

On preview

HP LaserJet 1300 data is not in the box. Dell Photo Printer 720 only half of the data row is in the box.

On printout

HP LaserJet 1300 only data upper part (like upper bar of of F) is in the box. Dell Photo Printer 720 only most of the data row is in the box.

Re: TReport samples

PostPosted: Mon Apr 29, 2013 9:33 pm
by Antonio Linares
Mosh,

Do the boxes look fine or the lines ?

If the lines are fine, then the box function may be wrong

Re: TReport samples

PostPosted: Mon Apr 29, 2013 10:36 pm
by mosh1
Antonio Linares wrote:Mosh,

Do the boxes look fine or the lines ?

If the lines are fine, then the box function may be wrong


I am using box, will try lines later.

Re: TReport samples

PostPosted: Tue Apr 30, 2013 6:12 am
by Antonio Linares
I meant the text lines ? Do they look fine ?

Ib that case, we need to modify the Method Box()