printing several pages

Re: printing several pages

Postby Antonio Linares » Mon Oct 08, 2018 6:39 am

René,

Class TPrinter Method Say() enhanced to use colors and fonts:
Code: Select all  Expand view  RUN
METHOD Say( nRow, nCol, cText, nClrText, nClrBack, cFontName, nFontSize ) CLASS TPrinter

   local oSay

   @ ::RowPos( nRow ), nCol SAY oSay PROMPT cText OF Self

   if nClrText != nil ..and. nClrBack != nil
      oSay:SetColor( nClrText, nClrBack )
   endif

   if cFontName != nil .and. nFontSize != nil
      oSay:SetFont( cFontName, nFontSize )
   endif

return nil


FiveMac updated libs available from:
https://bitbucket.org/fivetech/fivemac/src/master/lib/
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42122
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: printing several pages

Postby plantenkennis » Tue Oct 09, 2018 6:10 pm

Hello Antonio and Manuel,

Thank you for all your effort sofar. I will test this in the next few days.
Kind regards,

René Koot
User avatar
plantenkennis
 
Posts: 166
Joined: Wed Nov 25, 2015 7:13 pm
Location: the Netherlands

Re: printing several pages

Postby plantenkennis » Thu Oct 11, 2018 5:56 am

Hello Manuel and Antoni,

I have tested the new class TPrinter and method Say. There are a few things that are not working like it should be:
    When I use oPrn:Say( nRow, nCol, 'This is a very long line to see if it all prints') the text is not printed as far as 'This is a very'. So we should be able to set the length of the oPrnSay.
    I can't get the fontname- size and color to work.
    We should be able to set the height of the Row to print so we can differ in linespaces if needed.


I have some printouts that i want to be able to make.

First there is a plantlist that can be viewed by this link:
http://www.plantenkennis.com/FiveMac/plantlist.pdf
As you can se I first print a header with a line and underneath some colums. This all comes from an array

Than I have a leaflet. This is one page for each plant with the name and characteristics of the plant and an image:
http://www.plantenkennis.com/FiveMac/plant_leaflet.pdf

At last I have a flowering scheme where you can see in what month what colors are bloming:
http://www.plantenkennis.com/FiveMac/plant_flowering_scheme.pdf
For this I used next code:
Code: Select all  Expand view  RUN

FUNCTION RK_PrintGrafiek(cPrintTitel)
* to print a raster with flowering periods
* date: 20-06-2017

LOCAL nCol := 28
LOCAL nRow := 56
LOCAL nRowHeight := 18
LOCAL n
LOCAL nAantalPlanten := 0

LOCAL oSay

LOCAL aMaand[12]
LOCAL aKleur[0][3]
    AADD(aKleur, { 255, 218, 185 } )    && abrikoos
    AADD(aKleur, { 0, 0, 255 } )        && blauw
    AADD(aKleur, { 244, 164, 96 } )     && brons
    AADD(aKleur, { 255, 255, 217 } )    && creme
    AADD(aKleur, { 255, 255, 0 } )      && geel
    AADD(aKleur, { 0, 128, 0 } )        && groen
    AADD(aKleur, { 200, 162, 200 } )    && lila
    AADD(aKleur, { 224, 176, 255 } )    && mauve
    AADD(aKleur, { 255, 165, 0 } )      && oranje
    AADD(aKleur, { 170, 0 ,255 } )      && paars
    AADD(aKleur, { 128, 0, 128 } )      && purper
    AADD(aKleur, { 255, 0, 0 } )        && rood
    AADD(aKleur, { 255, 192, 203 } )    && roze
    AADD(aKleur, { 238, 130, 238 } )    && violet
    AADD(aKleur, { 255, 255, 230 } )    && wit
    AADD(aKleur, { 250, 128, 114 } )    && zalm
    AADD(aKleur, { 0, 0 ,0 } )          && zwart

PUBLIC oPrn:=TPrinter():new(0,0,0,0)
PUBLIC nPage := 1       && paginanummer onderaan
PUBLIC nPages       && het totaal aantal pagina's
PUBLIC nPagePx := 819

    IF ROUND(LEN(aPrintArray)/35,0) < LEN(aPrintArray)/35
        nPages := ROUND(LEN(aPrintArray)/35,0)+1
    ELSE
        nPages := ROUND(LEN(aPrintArray)/35,0)
    ENDIF

oPrn:SetLeftMargin(0)
oPrn:SetRightMargin(0)
oPrn:SetTopMargin(0)
oPrn:SetbottomMargin(0)
oPrn:setPaperName("A4")
oPrn:AutoPage(.F.)
oPrn:setSize( oPrn:pageWidth()-56 , ( oPrn:pageHeight()-28) *nPages )

@ nRow, nCol SAY oSay PROMPT cPrintTitel OF oPrn SIZE 450, 20
    oSay:Setfont("Arial",12 )
   
nRow := nRow + 2*nRowHeight
   
@ nRow, nCol SAY oSay PROMPT '
Latijnse naam' OF oPrn SIZE 200, 20
    oSay:Setfont("Arial",10 )
    oSay:setBkColor(255,255,255,100)
    oSay:setBezeled(.t.,.f.)
@ nRow, nCol+200 SAY oSay PROMPT '
Jan' OF oPrn SIZE 25, 20
    oSay:Setfont("Arial",9 )
    oSay:setBkColor(255,255,255,100)
    oSay:setBezeled(.t.,.f.)
@ nRow, nCol+225 SAY oSay PROMPT '
Feb' OF oPrn SIZE 25, 20
    oSay:Setfont("Arial",9 )
    oSay:setBkColor(255,255,255,100)
    oSay:setBezeled(.t.,.f.)
@ nRow, nCol+250 SAY oSay PROMPT '
Mrt' OF oPrn SIZE 25, 20
    oSay:Setfont("Arial",9 )
    oSay:setBkColor(255,255,255,100)
    oSay:setBezeled(.t.,.f.)
@ nRow, nCol+275 SAY oSay PROMPT '
Apr' OF oPrn SIZE 25, 20
    oSay:Setfont("Arial",9 )
    oSay:setBkColor(255,255,255,100)
    oSay:setBezeled(.t.,.f.)
@ nRow, nCol+300 SAY oSay PROMPT '
Mei' OF oPrn SIZE 25, 20
    oSay:Setfont("Arial",9 )
    oSay:setBkColor(255,255,255,100)
    oSay:setBezeled(.t.,.f.)
@ nRow, nCol+325 SAY oSay PROMPT '
Jun' OF oPrn SIZE 25, 20
    oSay:Setfont("Arial",9 )
    oSay:setBkColor(255,255,255,100)
    oSay:setBezeled(.t.,.f.)
@ nRow, nCol+350 SAY oSay PROMPT '
Jul' OF oPrn SIZE 25, 20
    oSay:Setfont("Arial",9 )
    oSay:setBkColor(255,255,255,100)
    oSay:setBezeled(.t.,.f.)
@ nRow, nCol+375 SAY oSay PROMPT '
Aug' OF oPrn SIZE 25, 20
    oSay:Setfont("Arial",9 )
    oSay:setBkColor(255,255,255,100)
    oSay:setBezeled(.t.,.f.)
@ nRow, nCol+400 SAY oSay PROMPT '
Sep' OF oPrn SIZE 25, 20
    oSay:Setfont("Arial",9 )
    oSay:setBkColor(255,255,255,100)
    oSay:setBezeled(.t.,.f.)
@ nRow, nCol+425 SAY oSay PROMPT '
Okt' OF oPrn SIZE 25, 20
    oSay:Setfont("Arial",9 )
    oSay:setBkColor(255,255,255,100)
    oSay:setBezeled(.t.,.f.)
@ nRow, nCol+450 SAY oSay PROMPT '
Nov' OF oPrn SIZE 25, 20
    oSay:Setfont("Arial",9 )
    oSay:setBkColor(255,255,255,100)
    oSay:setBezeled(.t.,.f.)
@ nRow, nCol+475 SAY oSay PROMPT '
Dec' OF oPrn SIZE 25, 20
    oSay:Setfont("Arial",9 )
    oSay:setBkColor(255,255,255,100)
    oSay:setBezeled(.t.,.f.)
    nRow := nRow + nRowHeight

FOR n = 1 TO LEN(aPrintArray)
        cText := RK_PrintShort(ALLTRIM(RK_GetLatijnseNaam(aPrintArray[n,1])), 220, "Arial", 10)
        nColor := RK_GetKleur(aPrintArray[n,1])
        aMaand := RK_CollectBloeiMaanden(aPrintArray[n,1])
   
    @ nRow, nCol SAY oSay PROMPT cText OF oPrn SIZE 200, 20
        oSay:Setfont("Arial",10 )
    oSay:setBkColor(255,255,255,100)
        oSay:setBezeled(.t.,.f.)
    @ nRow, nCol+200 SAY oSay PROMPT '
' OF oPrn SIZE 25, 20
        oSay:Setfont("Arial",10 )
        IF aMaand[1]
            oSay:setBkColor(aKleur[nColor,1],aKleur[nColor,2],aKleur[nColor,3],100)
        ELSE
            oSay:setBkColor(255,255,255,100)
        ENDIF
        oSay:setBezeled(.t.,.f.)
    @ nRow, nCol+225 SAY oSay PROMPT '
' OF oPrn SIZE 25, 20
        oSay:Setfont("Arial",10 )
        IF aMaand[2]
            oSay:setBkColor(aKleur[nColor,1],aKleur[nColor,2],aKleur[nColor,3],100)
        ELSE
            oSay:setBkColor(255,255,255,100)
        ENDIF
        oSay:setBezeled(.t.,.f.)
    @ nRow, nCol+250 SAY oSay PROMPT '
' OF oPrn SIZE 25, 20
        oSay:Setfont("Arial",10 )
        IF aMaand[3]
            oSay:setBkColor(aKleur[nColor,1],aKleur[nColor,2],aKleur[nColor,3],100)
        ELSE
            oSay:setBkColor(255,255,255,100)
        ENDIF
        oSay:setBezeled(.t.,.f.)
    @ nRow, nCol+275 SAY oSay PROMPT '
' OF oPrn SIZE 25, 20
        oSay:Setfont("Arial",10 )
        IF aMaand[4]
            oSay:setBkColor(aKleur[nColor,1],aKleur[nColor,2],aKleur[nColor,3],100)
        ELSE
            oSay:setBkColor(255,255,255,100)
        ENDIF
        oSay:setBezeled(.t.,.f.)
    @ nRow, nCol+300 SAY oSay PROMPT '
' OF oPrn SIZE 25, 20
        oSay:Setfont("Arial",10 )
        IF aMaand[5]
            oSay:setBkColor(aKleur[nColor,1],aKleur[nColor,2],aKleur[nColor,3],100)
        ELSE
            oSay:setBkColor(255,255,255,100)
        ENDIF
        oSay:setBezeled(.t.,.f.)
    @ nRow, nCol+325 SAY oSay PROMPT '
' OF oPrn SIZE 25, 20
        oSay:Setfont("Arial",10 )
        IF aMaand[6]
            oSay:setBkColor(aKleur[nColor,1],aKleur[nColor,2],aKleur[nColor,3],100)
        ELSE
            oSay:setBkColor(255,255,255,100)
        ENDIF
        oSay:setBezeled(.t.,.f.)
    @ nRow, nCol+350 SAY oSay PROMPT '
' OF oPrn SIZE 25, 20
        oSay:Setfont("Arial",10 )
        IF aMaand[7]
            oSay:setBkColor(aKleur[nColor,1],aKleur[nColor,2],aKleur[nColor,3],100)
        ELSE
            oSay:setBkColor(255,255,255,100)
        ENDIF
        oSay:setBezeled(.t.,.f.)
    @ nRow, nCol+375 SAY oSay PROMPT '
' OF oPrn SIZE 25, 20
        oSay:Setfont("Arial",10 )
        IF aMaand[8]
            oSay:setBkColor(aKleur[nColor,1],aKleur[nColor,2],aKleur[nColor,3],100)
        ELSE
            oSay:setBkColor(255,255,255,100)
        ENDIF
        oSay:setBezeled(.t.,.f.)
    @ nRow, nCol+400 SAY oSay PROMPT '
' OF oPrn SIZE 25, 20
        oSay:Setfont("Arial",10 )
        IF aMaand[9]
            oSay:setBkColor(aKleur[nColor,1],aKleur[nColor,2],aKleur[nColor,3],100)
        ELSE
            oSay:setBkColor(255,255,255,100)
        ENDIF
        oSay:setBezeled(.t.,.f.)
    @ nRow, nCol+425 SAY oSay PROMPT '
' OF oPrn SIZE 25, 20
        oSay:Setfont("Arial",10 )
        IF aMaand[10]
            oSay:setBkColor(aKleur[nColor,1],aKleur[nColor,2],aKleur[nColor,3],100)
        ELSE
            oSay:setBkColor(255,255,255,100)
        ENDIF
        oSay:setBezeled(.t.,.f.)
    @ nRow, nCol+450 SAY oSay PROMPT '
' OF oPrn SIZE 25, 20
        oSay:Setfont("Arial",10 )
        IF aMaand[11]
            oSay:setBkColor(aKleur[nColor,1],aKleur[nColor,2],aKleur[nColor,3],100)
        ELSE
            oSay:setBkColor(255,255,255,100)
        ENDIF
        oSay:setBezeled(.t.,.f.)
    @ nRow, nCol+475 SAY oSay PROMPT '
' OF oPrn SIZE 25, 20
        oSay:Setfont("Arial",10 )
        IF aMaand[12]
            oSay:setBkColor(aKleur[nColor,1],aKleur[nColor,2],aKleur[nColor,3],100)
        ELSE
            oSay:setBkColor(255,255,255,100)
        ENDIF
        oSay:setBezeled(.t.,.f.)
    nRow := nRow + nRowHeight

    IF nRow > nPage*nPagePx - 90
        RK_PrintFooter()
        nPage++
        nRow := nRow + 170
        @ nRow, nCol SAY oSay PROMPT '
Latijnse naam' OF oPrn SIZE 200, 20
            oSay:Setfont("Arial",10 )
            oSay:setBkColor(255,255,255,100)
            oSay:setBezeled(.t.,.f.)
        @ nRow, nCol+200 SAY oSay PROMPT '
Jan' OF oPrn SIZE 25, 20
            oSay:Setfont("Arial",9 )
            oSay:setBkColor(255,255,255,100)
            oSay:setBezeled(.t.,.f.)
        @ nRow, nCol+225 SAY oSay PROMPT '
Feb' OF oPrn SIZE 25, 20
            oSay:Setfont("Arial",9 )
            oSay:setBkColor(255,255,255,100)
            oSay:setBezeled(.t.,.f.)
        @ nRow, nCol+250 SAY oSay PROMPT '
Mrt' OF oPrn SIZE 25, 20
            oSay:Setfont("Arial",9 )
            oSay:setBkColor(255,255,255,100)
            oSay:setBezeled(.t.,.f.)
        @ nRow, nCol+275 SAY oSay PROMPT '
Apr' OF oPrn SIZE 25, 20
            oSay:Setfont("Arial",9 )
            oSay:setBkColor(255,255,255,100)
            oSay:setBezeled(.t.,.f.)
        @ nRow, nCol+300 SAY oSay PROMPT '
Mei' OF oPrn SIZE 25, 20
            oSay:Setfont("Arial",9 )
            oSay:setBkColor(255,255,255,100)
            oSay:setBezeled(.t.,.f.)
        @ nRow, nCol+325 SAY oSay PROMPT '
Jun' OF oPrn SIZE 25, 20
            oSay:Setfont("Arial",9 )
            oSay:setBkColor(255,255,255,100)
            oSay:setBezeled(.t.,.f.)
        @ nRow, nCol+350 SAY oSay PROMPT '
Jul' OF oPrn SIZE 25, 20
            oSay:Setfont("Arial",9 )
            oSay:setBkColor(255,255,255,100)
            oSay:setBezeled(.t.,.f.)
        @ nRow, nCol+375 SAY oSay PROMPT '
Aug' OF oPrn SIZE 25, 20
            oSay:Setfont("Arial",9 )
            oSay:setBkColor(255,255,255,100)
            oSay:setBezeled(.t.,.f.)
        @ nRow, nCol+400 SAY oSay PROMPT '
Sep' OF oPrn SIZE 25, 20
            oSay:Setfont("Arial",9 )
            oSay:setBkColor(255,255,255,100)
            oSay:setBezeled(.t.,.f.)
        @ nRow, nCol+425 SAY oSay PROMPT '
Okt' OF oPrn SIZE 25, 20
            oSay:Setfont("Arial",9 )
            oSay:setBkColor(255,255,255,100)
            oSay:setBezeled(.t.,.f.)
        @ nRow, nCol+450 SAY oSay PROMPT '
Nov' OF oPrn SIZE 25, 20
            oSay:Setfont("Arial",9 )
            oSay:setBkColor(255,255,255,100)
            oSay:setBezeled(.t.,.f.)
        @ nRow, nCol+475 SAY oSay PROMPT '
Dec' OF oPrn SIZE 25, 20
            oSay:Setfont("Arial",9 )
            oSay:setBkColor(255,255,255,100)
            oSay:setBezeled(.t.,.f.)
            nRow := nRow + nRowHeight
    ENDIF

NEXT

RK_PrintFooter()

oPrn:run()

RETURN NIL


I hope this all is possible?
Kind regards,

René Koot
User avatar
plantenkennis
 
Posts: 166
Joined: Wed Nov 25, 2015 7:13 pm
Location: the Netherlands

Re: printing several pages

Postby mastintin » Thu Oct 11, 2018 2:56 pm

If Use this ?

#xcommand @ <nRow>, <nCol> SAY [ <oSay> PROMPT ] <cText> ;
OF <oPrn> PAGINED ;
[ SIZE <nWidth>, <nHeight> ] ;
[ <raised: RAISED> ] ;
[ <cPostext: TEXTLEFT, TEXTRIGHT, TEXTCENTER> ] ;
[ AUTORESIZE <nAutoResize> ] ;
[ TOOLTIP <cToolTip> ] ;
[ <lutf8: UTF8 > ] ;
[ PIXEL ] ;
=> ;
<nRow>:= oPrn:RowPos( <nRow> ) ;;
[ <oSay> := ] TSay():New( <nRow>, <nCol>, <nWidth>, <nHeight>,;
<oPrn>, <cText>, <.raised.>, [ Upper(<(cPostext)>) ],;
[<nAutoResize>], [<cToolTip>], [<(oSay)>] )

I will try to test it to see if it compiles and works.

Bad command ... :-)
Last edited by mastintin on Fri Oct 12, 2018 8:59 am, edited 1 time in total.
User avatar
mastintin
 
Posts: 1516
Joined: Thu May 27, 2010 2:06 pm

Re: printing several pages

Postby mastintin » Fri Oct 12, 2018 8:56 am

First approach...
Rene , that is good for you ?

Code: Select all  Expand view  RUN


#include "FiveMac.ch"

*a test program for printing multiple pages
*made by René Koot

#xcommand @ <nRow>, <nCol> SAY [ <oSay> PROMPT ] <cText> ;
OF <oPrn> PAGINED ;
[ SIZE <nWidth>, <nHeight> ] ;
[ <raised: RAISED> ] ;
[ <cPostext: TEXTLEFT, TEXTRIGHT, TEXTCENTER> ] ;
[ AUTORESIZE <nAutoResize> ] ;
[ TOOLTIP <cToolTip> ] ;
[ <lutf8: UTF8 > ] ;
[ PIXEL ] ;
=> ;
[ <oSay> := ] TSay():New( oPrn:RowPos(<nRow>), <nCol>, <nWidth>, <nHeight>,;
<oPrn>, <cText>, <.raised.>, [ Upper(<(cPostext)>) ],;
[<nAutoResize>], [<cToolTip>], [<(oSay)>] )


#xcommand @ <nRow>, <nCol> IMAGE [ <oImg> ] ;
 OF <oPrn> PAGINED ;
[ SIZE <nWidth>, <nHeight> ] ;
[ FILENAME <cFileName> ] ;
[ <resource: NAME, RESOURCE, RESNAME> <cResName> ] ;
[ TOOLTIP <cToolTip> ] ;
=> ;
[ <oImg> := ] TImage():New( oPrn:RowPos(<nRow>), <nCol>, <nWidth>, <nHeight>,;
[<oPrn>], [<cFileName>], [<cResName>], [<cToolTip> ], [<(oImg)>]  )



FUNCTION Main()

   LOCAL oDlg
   
   DEFINE DIALOG oDlg TITLE "Dialog"
   
   @ 40, 40 BUTTON "print" OF oDlg ACTION RK_PrintTest()
   
   DEFINE MSGBAR OF oDlg
   
   ACTIVATE DIALOG oDlg
   
RETURN NIL  

*************************************************

FUNCTION RK_PrintTest()


LOCAL nCol := 28
LOCAL nRow := 0
LOCAL nRowHeight := 0
LOCAL n
LOCAL oSay, oImg
local nfixRow:=  0

LOCAL aPrintArray[0][5]

AADD(aPrintArray, {'Line 1_1', 'Line2_1', 'Line3_1', 'Line4_1', 'Line5_1'})
AADD(aPrintArray, {'Line 1_2', 'Line2_2', 'Line3_2', 'Line4_2', 'Line5_2'})
AADD(aPrintArray, {'Line 1_3', 'Line2_3', 'Line3_3', 'Line4_3', 'Line5_3'})
AADD(aPrintArray, {'Line 1_4', 'Line2_4', 'Line3_4', 'Line4_4', 'Line5_4'})
AADD(aPrintArray, {'Line 1_5', 'Line2_5', 'Line3_5', 'Line4_5', 'Line5_5'})
AADD(aPrintArray, {'Line 1_6', 'Line2_6', 'Line3_6', 'Line4_6', 'Line5_6'})
AADD(aPrintArray, {'Line 1_7', 'Line2_7', 'Line3_1', 'Line4_1', 'Line5_1'})
AADD(aPrintArray, {'Line 1_8', 'Line2_8', 'Line3_2', 'Line4_2', 'Line5_2'})
AADD(aPrintArray, {'Line 1_9', 'Line2_9', 'Line3_3', 'Line4_3', 'Line5_3'})
AADD(aPrintArray, {'Line 1_10', 'Line2_10', 'Line3_4', 'Line4_4', 'Line5_4'})
AADD(aPrintArray, {'Line 1_11', 'Line2_11', 'Line3_5', 'Line4_5', 'Line5_5'})
AADD(aPrintArray, {'Line 1_12', 'Line2_12', 'Line3_6', 'Line4_6', 'Line5_6'})
AADD(aPrintArray, {'Line 1_13', 'Line2_13', 'Line3_1', 'Line4_1', 'Line5_1'})
AADD(aPrintArray, {'Line 1_14', 'Line2_14', 'Line3_2', 'Line4_2', 'Line5_2'})
AADD(aPrintArray, {'Line 1_15', 'Line2_15', 'Line3_3', 'Line4_3', 'Line5_3'})
AADD(aPrintArray, {'Line 1_16', 'Line2_16', 'Line3_4', 'Line4_4', 'Line5_4'})
AADD(aPrintArray, {'Line 1_17', 'Line2_17', 'Line3_5', 'Line4_5', 'Line5_5'})
AADD(aPrintArray, {'Line 1_18', 'Line2_18', 'Line3_6', 'Line4_6', 'Line5_6'})

PUBLIC nPage
PUBLIC nPagePx := 813

PUBLIC oPrn:=TPrinter():new(0,0,0,0)

oPrn:SetLeftMargin(0)
oPrn:SetRightMargin(0)
oPrn:SetTopMargin(0)
oPrn:SetbottomMargin(0)
oPrn:SetPaperName("A4")
oPrn:AutoPage(.T.)

oPrn:nRowsPerPage := nPagPix

nHeight := oPrn:GetPrintableHeight()
nWidth  := oPrn:GetPrintableWidth()

oPrn:SetSize( nWidth, nHeight * LEN(aPrintArray) )

cFoto := "write.png"

FOR nPage = 1 TO LEN(aPrintArray)

    oPrn:StartPage()

        @ 0, nCol SAY oSay PROMPT aPrintArray[nPage,1] OF oPrn PAGINED SIZE 480, 40
            oSay:Setfont("Arial",20 )
            oSay:setTextColor(0,51,0,100)

        @ 30, 285 IMAGE oImg OF oPrn PAGINED SIZE 250, 250 FILENAME cFoto
            oImg:SetFrame()

        @ 300, nCol SAY oSay PROMPT aPrintArray[nPage,2] OF oPrn PAGINED SIZE 240, 18
            oSay:Setfont("Arial",12 )

        @ 330, nCol SAY oSay PROMPT aPrintArray[nPage,3] OF oPrn PAGINED SIZE 240, 18
            oSay:Setfont("Arial",12 )


        @ 360, nCol SAY oSay PROMPT aPrintArray[nPage,4] OF oPrn PAGINED SIZE 240, 18
            oSay:Setfont("Arial",12 )


        @ 390 ,nCol SAY oSay PROMPT aPrintArray[nPage,5] OF oPrn PAGINED SIZE 240, 18
            oSay:Setfont("Arial",12 )

        RK_PrintFooter()

    oPrn:EndPage()

NEXT

oPrn:run()

RETURN NIL

*************************************************

FUNCTION RK_PrintFooter()

local nWidth  := oPrn:GetPrintableWidth()

@ 780 , 28 SAY oSay PROMPT CHR(0169) + ' Copyright: Plantenkennis versie ' OF oPrn PAGINED SIZE nWidth- 112, 20
oSay:Setfont("Arial",12 )

@ 780 , 450 SAY oSay PROMPT 'page ' + ALLTRIM(STR(nPage)) OF oPrn PAGINED SIZE nWidth - 112, 20
oSay:Setfont("Arial",12 )


RETURN NIL

 
User avatar
mastintin
 
Posts: 1516
Joined: Thu May 27, 2010 2:06 pm

Re: printing several pages

Postby plantenkennis » Fri Oct 12, 2018 3:25 pm

Hello Manuel,

I have addepted the code a little bit to make it work correct. First we used nCol and nRow in pixels, but with the new lib it works with lines? Here is the addapted code. I also removed some unused variables. Can you use the same approach for a line or rectangle. The only problem I see now if I use oSay:setBezeled(.t.,.f.). The text does not fit in the border

Code: Select all  Expand view  RUN

#include "FiveMac.ch"

*a test program for printing multiple pages
*made by René Koot and Manuel

#xcommand @ <nRow>, <nCol> SAY [ <oSay> PROMPT ] <cText> ;
OF <oPrn> PAGINED ;
[ SIZE <nWidth>, <nHeight> ] ;
[ <raised: RAISED> ] ;
[ <cPostext: TEXTLEFT, TEXTRIGHT, TEXTCENTER> ] ;
[ AUTORESIZE <nAutoResize> ] ;
[ TOOLTIP <cToolTip> ] ;
[ <lutf8: UTF8 > ] ;
[ PIXEL ] ;
=> ;
[ <oSay> := ] TSay():New( oPrn:RowPos(<nRow>), <nCol>, <nWidth>, <nHeight>,;
<oPrn>, <cText>, <.raised.>, [ Upper(<(cPostext)>) ],;
[<nAutoResize>], [<cToolTip>], [<(oSay)>] )


#xcommand @ <nRow>, <nCol> IMAGE [ <oImg> ] ;
 OF <oPrn> PAGINED ;
[ SIZE <nWidth>, <nHeight> ] ;
[ FILENAME <cFileName> ] ;
[ <resource: NAME, RESOURCE, RESNAME> <cResName> ] ;
[ TOOLTIP <cToolTip> ] ;
=> ;
[ <oImg> := ] TImage():New( oPrn:RowPos(<nRow>), <nCol>, <nWidth>, <nHeight>,;
[<oPrn>], [<cFileName>], [<cResName>], [<cToolTip> ], [<(oImg)>]  )



FUNCTION Main()

   LOCAL oDlg
   
   DEFINE DIALOG oDlg TITLE "Dialog"
   
   @ 40, 40 BUTTON "print" OF oDlg ACTION RK_PrintTest()
   
   DEFINE MSGBAR OF oDlg
   
   ACTIVATE DIALOG oDlg
   
RETURN NIL  

*************************************************

FUNCTION RK_PrintTest()


LOCAL nCol := 2
LOCAL nRow := 0
LOCAL nRowHeight := 0
LOCAL n
LOCAL oSay, oImg
local nfixRow:=  0

LOCAL aPrintArray[0][5]

AADD(aPrintArray, {'This is a very long line to see if it works', 'Line2_1', 'Line3_1', 'Line4_1', 'Line5_1'})
AADD(aPrintArray, {'Line 1_2', 'Line2_2', 'Line3_2', 'Line4_2', 'Line5_2'})
AADD(aPrintArray, {'Line 1_3', 'Line2_3', 'Line3_3', 'Line4_3', 'Line5_3'})
AADD(aPrintArray, {'Line 1_4', 'Line2_4', 'Line3_4', 'Line4_4', 'Line5_4'})
AADD(aPrintArray, {'Line 1_5', 'Line2_5', 'Line3_5', 'Line4_5', 'Line5_5'})
AADD(aPrintArray, {'Line 1_6', 'Line2_6', 'Line3_6', 'Line4_6', 'Line5_6'})
AADD(aPrintArray, {'Line 1_7', 'Line2_7', 'Line3_1', 'Line4_1', 'Line5_1'})
AADD(aPrintArray, {'Line 1_8', 'Line2_8', 'Line3_2', 'Line4_2', 'Line5_2'})
AADD(aPrintArray, {'Line 1_9', 'Line2_9', 'Line3_3', 'Line4_3', 'Line5_3'})
AADD(aPrintArray, {'Line 1_10', 'Line2_10', 'Line3_4', 'Line4_4', 'Line5_4'})
AADD(aPrintArray, {'Line 1_11', 'Line2_11', 'Line3_5', 'Line4_5', 'Line5_5'})
AADD(aPrintArray, {'Line 1_12', 'Line2_12', 'Line3_6', 'Line4_6', 'Line5_6'})
AADD(aPrintArray, {'Line 1_13', 'Line2_13', 'Line3_1', 'Line4_1', 'Line5_1'})
AADD(aPrintArray, {'Line 1_14', 'Line2_14', 'Line3_2', 'Line4_2', 'Line5_2'})
AADD(aPrintArray, {'Line 1_15', 'Line2_15', 'Line3_3', 'Line4_3', 'Line5_3'})
AADD(aPrintArray, {'Line 1_16', 'Line2_16', 'Line3_4', 'Line4_4', 'Line5_4'})
AADD(aPrintArray, {'Line 1_17', 'Line2_17', 'Line3_5', 'Line4_5', 'Line5_5'})
AADD(aPrintArray, {'Line 1_18', 'Line2_18', 'Line3_6', 'Line4_6', 'Line5_6'})

PUBLIC nPage

PUBLIC oPrn:=TPrinter():new(0,0,0,0)

oPrn:SetLeftMargin(0)
oPrn:SetRightMargin(0)
oPrn:SetTopMargin(0)
oPrn:SetbottomMargin(0)
oPrn:SetPaperName("A4")
oPrn:AutoPage(.T.)

cFoto := "write.png"

FOR nPage = 1 TO LEN(aPrintArray)

    oPrn:StartPage()

        @ 0, nCol SAY oSay PROMPT aPrintArray[nPage,1] OF oPrn PAGINED SIZE 480, 40
            oSay:Setfont("Arial",20 )
            oSay:setTextColor(0,51,0,100)

        @ 1, 285 IMAGE oImg OF oPrn PAGINED SIZE 250, 250 FILENAME cFoto
            oImg:SetFrame()

        @ 2, nCol SAY oSay PROMPT aPrintArray[nPage,2] OF oPrn PAGINED SIZE 240, 18
            oSay:Setfont("Arial",12 )
            oSay:setBkColor(0, 0, 255,100)
        oSay:setBezeled(.t.,.f.)

        @ 3, nCol SAY oSay PROMPT aPrintArray[nPage,3] OF oPrn PAGINED SIZE 240, 18
            oSay:Setfont("Arial",12 )


        @ 4, nCol SAY oSay PROMPT aPrintArray[nPage,4] OF oPrn PAGINED SIZE 240, 18
            oSay:Setfont("Arial",12 )


        @ 5 ,nCol SAY oSay PROMPT aPrintArray[nPage,5] OF oPrn PAGINED SIZE 240, 18
            oSay:Setfont("Arial",12 )

        RK_PrintFooter()

    oPrn:EndPage()

NEXT

oPrn:run()

RETURN NIL

*************************************************

FUNCTION RK_PrintFooter()

local nWidth  := oPrn:GetPrintableWidth()

@ oPrn:LastRow(), 28 SAY oSay PROMPT CHR(0169) + ' Copyright: Plantenkennis versie ' OF oPrn PAGINED SIZE nWidth- 112, 20
oSay:Setfont("Arial",12 )

@ oPrn:LastRow() , 450 SAY oSay PROMPT 'page ' + ALLTRIM(STR(nPage)) OF oPrn PAGINED SIZE nWidth - 112, 20
oSay:Setfont("Arial",12 )


RETURN NIL
 
Kind regards,

René Koot
User avatar
plantenkennis
 
Posts: 166
Joined: Wed Nov 25, 2015 7:13 pm
Location: the Netherlands

Re: printing several pages

Postby mastintin » Fri Oct 12, 2018 7:51 pm

Can you use the same approach for a line or rectangle.

Yes , of course , with any control that can be put in a view.

The only problem I see now if I use oSay:setBezeled(.t.,.f.). The text does not fit in the border

Is normal . The text has a measure that depends on the font used, but you are assigned some measures to adjust in SIZE clausule.
NSTEXTField not fix borders to content and it has no alignment vertical , only align Text to left , center o right.
User avatar
mastintin
 
Posts: 1516
Joined: Thu May 27, 2010 2:06 pm

Re: printing several pages

Postby plantenkennis » Tue Nov 13, 2018 9:03 pm

Hello Antonio and Manuel,

Thanks a lot for all the help with printing. This week I have released a new version of my software, including several printing options. I want to share some code with you and everybody.

My software is a digital plant encyclopedia and users (landscapers) can make garden plans with this software. So the users can put some plants in a list for his customer and show the plants with some prints.

First he can make a list with the plants used in the garden, including sizes, prices etc. A preview you can see from this linkhttp://www.plantenkennis.com/FiveMac/plantlist.pdf. i made is with this code:
Code: Select all  Expand view  RUN

FUNCTION RK_BeplantingsLijstPrint()
*to print a beplantingslijst
*date: 21-09-2018

LOCAL aNAW[0]
LOCAL cLatnaam := ''
LOCAL nTotaalPrijs := 0.00
LOCAL nColTotaalPrijs := 0
LOCAL nPrintBovenMarge := VAL(cPrintBovenMarge)

LOCAL oSay

PUBLIC nPrintFontSize := VAL(aFontSize[nFontSize])
PUBLIC nCol := 0    && de kolom waarop we printen
PUBLIC nRow := 1    && de rij waar we beginnen
PUBLIC ndubbelRij := .F.

IF VAL(cPrintBovenMarge) > 0
    nRow := ROUND(VAL(cPrintBovenMarge)/5,0)
ENDIF

IF lPrintNeder .OR. lPrintOpmerking .OR. lPrintAfmeting
    ndubbelRij := .T.
    nAantalRegels := 18
ENDIF

lFooterPrint := lPrintFooter

PUBLIC nPage := 1       && paginanummer onderaan
PUBLIC oPrn:=TPrinter():new(0,0,0,0)

oPrn:SetLeftMargin(0)
oPrn:SetRightMargin(0)
oPrn:SetTopMargin(0)
oPrn:SetbottomMargin(0)
oPrn:setPaperName("A4")
oPrn:AutoPage(.T.)

    oPrn:StartPage()

    @ nRow, nCol+285 SAY oSay PROMPT 'lijst: ' + cPlantLijst OF oPrn PAGINED SIZE 450, 20
        oSay:Setfont(cFontName, nPrintFontSize)
   
    IF lPrintNAW
        aNAW := RK_CollectNAW(nKlantID)
        IF LEN(aNAW) > 0
            @ nRow, nCol+15 SAY oSay PROMPT 'beplantingslijst voor:' OF oPrn PAGINED SIZE 450, 20
                oSay:Setfont(cFontName, nPrintFontSize)
            nRow++
            FOR nNAW = 1 TO LEN(aNAW)
                @ nRow, nCol+15 SAY oSay PROMPT aNAW[nNAW] OF oPrn PAGINED SIZE 450, 20
                    oSay:Setfont(cFontName, nPrintFontSize)
                nRow++
            NEXT
        ELSE
                nRow++
        ENDIF
    ENDIF

    nRow++

    RK_PrintKopBeplantingslijst()

SELECT PlantLijst
FOR n = 1 TO LEN(aPlantenLijst)
    GOTO aPlantenLijst[n,8]
    IF lPrintAantal
        @ nRow, nCol SAY oSay PROMPT STR(aantal) OF oPrn PAGINED SIZE 40, 20
            oSay:Setfont(cFontName, nPrintFontSize )
            oSay:SetAlign( 1 )
        nCol := nCol + 40
    ENDIF
    cLatnaam := RK_PrintShort(ALLTRIM(latnaam), 250, cFontName, nPrintFontSize)
    @ nRow, nCol SAY oSay PROMPT cLatnaam OF oPrn PAGINED SIZE 250, 20
        oSay:Setfont(cFontName, nPrintFontSize )
    IF lPrintNeder
        @ nRow+1, nCol SAY oSay PROMPT RK_GetNederNaam(Plantnum) OF oPrn PAGINED SIZE 250, 20
            oSay:Setfont(cFontName, nPrintFontSize )
    ENDIF
    nCol := nCol + 250
    IF lPrintMaat
        @ nRow, nCol SAY oSay PROMPT maat OF oPrn PAGINED SIZE 100, 20
            oSay:Setfont(cFontName, nPrintFontSize)
       
        IF lPrintOpmerking 
            @ nRow+1, nCol SAY oSay PROMPT opmerking OF oPrn PAGINED SIZE 130, 20
                oSay:Setfont(cFontName, nPrintFontSize)
        ENDIF
        nCol := nCol + 100
    ENDIF

    IF lPrintPrijs
        @ nRow, nCol SAY oSay PROMPT STR(prijs) OF oPrn PAGINED SIZE 55, 20
            oSay:Setfont(cFontName, nPrintFontSize )
            oSay:SetAlign( 1 )
        nCol := nCol + 55
    ENDIF
    IF lPrintVerkoop .AND. !lPrintPrijs
        @ nRow, nCol SAY oSay PROMPT STR(verkoop) OF oPrn PAGINED SIZE 55, 20
            oSay:Setfont(cFontName, nPrintFontSize )
            oSay:SetAlign( 1 )
        nCol := nCol + 55
    ENDIF
    IF lPrintTotaal
        @ nRow, nCol SAY oSay PROMPT STR(aantal*prijs) OF oPrn PAGINED SIZE 55, 20
            oSay:Setfont(cFontName, nPrintFontSize )
            oSay:SetAlign( 1 )
        nTotaalPrijs := nTotaalPrijs + aantal*prijs
        nColTotaalPrijs := nCol
        nCol := nCol + 55
    ENDIF
    IF lPrintVak
        @ nRow, nCol SAY oSay PROMPT vaknr OF oPrn PAGINED SIZE 30, 20
            oSay:Setfont(cFontName, nPrintFontSize )
        nEindCol := nCol + 30
    ELSE
        nEindCol := nCol
    ENDIF
    nCol := 0
    IF ndubbelRij
        nRow++
        nRow++
    ELSE
        nRow++
    ENDIF
    IF lPrintRaster
        @ oPrn:RowPos(nRow)-5, 0 LINE HORIZONTAL PAGINED SIZE oPrn:pageWidth() OF oPrn
    ENDIF
           
    IF nRow > oPrn:LastRow()-3
        RK_PrintFooter()
        nPage++
        IF VAL(cPrintBovenMarge) > 0 .AND. !lPrintBovenMarge
            nRow := ROUND(VAL(cPrintBovenMarge)/5,0)
        ELSE
            nRow := 1
        ENDIF
        oPrn:EndPage()
        oPrn:StartPage()
        RK_PrintKopBeplantingslijst()
    ENDIF
NEXT

IF lPrintTotaal
    nRow := nRow +2
    @ nRow, nColTotaalPrijs-50 SAY oSay PROMPT 'totaal:' OF oPrn PAGINED SIZE 40, 20
        oSay:Setfont(cFontName, nPrintFontSize )
        oSay:SetAlign( 2 )
    @ nRow, nColTotaalPrijs SAY oSay PROMPT STR(nTotaalPrijs) OF oPrn PAGINED SIZE 55, 20
        oSay:Setfont(cFontName, nPrintFontSize )
        oSay:SetAlign( 1 )
ENDIF

nRow++
RK_PrintFooter()
oPrn:EndPage()

oPrn:run()

lFooterPrint := .T.

RETURN NIL

*************************************************

FUNCTION RK_PrintKopBeplantingslijst()

*om de kop boven elke pagina te printen
*date: 25-9-2018

IF lPrintAantal
    @ nRow, nCol SAY oSay PROMPT 'aantal' OF oPrn PAGINED SIZE 40, 20
        oSay:Setfont(cFontName, nPrintFontSize )
        oSay:SetAlign( 1 )
       
    IF lPrintAfmeting
        @ nRow+1, nCol SAY oSay PROMPT 'afm.' OF oPrn PAGINED SIZE 40, 20
            oSay:Setfont(cFontName, nPrintFontSize )
            oSay:SetAlign( 1 )
    ENDIF
    nCol := nCol + 40
ENDIF
   
@ nRow, nCol SAY oSay PROMPT 'Latijnse naam' OF oPrn PAGINED SIZE 250, 20
    oSay:Setfont(cFontName, nPrintFontSize)
   
IF lPrintNeder
    @ nRow+1, nCol SAY oSay PROMPT 'Nederlandse naam' OF oPrn PAGINED SIZE 250, 20
        oSay:Setfont(cFontName, nPrintFontSize )
ENDIF
nCol := nCol + 250

IF lPrintMaat
    @ nRow, nCol SAY oSay PROMPT 'maat' OF oPrn PAGINED SIZE 100, 20
        oSay:Setfont(cFontName, nPrintFontSize)
       
    IF lPrintOpmerking 
        @ nRow+1, nCol SAY oSay PROMPT 'opmerking' OF oPrn PAGINED SIZE 130, 20
            oSay:Setfont(cFontName, nPrintFontSize)
    ENDIF
    nCol := nCol + 100
ENDIF

IF lPrintPrijs .OR. lPrintVerkoop
    @ nRow, nCol SAY oSay PROMPT 'prijs' OF oPrn PAGINED SIZE 55, 20
        oSay:Setfont(cFontName, nPrintFontSize )
        oSay:SetAlign( 1 )
    nCol := nCol + 55
ENDIF
IF lPrintTotaal
    @ nRow, nCol SAY oSay PROMPT 'totaal' OF oPrn PAGINED SIZE 55, 20
        oSay:Setfont(cFontName, nPrintFontSize )
        oSay:SetAlign( 1 )
    nCol := nCol + 55
ENDIF
IF lPrintVak
    @ nRow, nCol SAY oSay PROMPT 'vak' OF oPrn PAGINED SIZE 30, 20
        oSay:Setfont(cFontName, nPrintFontSize )
ENDIF
nCol := 0
nGroupRow := nRow
IF ndubbelRij
    nRow++
    nRow++
    nGroupHeight := 55
ELSE
    nRow++
    nGroupHeight := 35
ENDIF
@ oPrn:RowPos(nRow)-nGroupHeight, 0 GROUP oGroup PROMPT '' SIZE oPrn:pageWidth(), nGroupHeight OF oPrn
        oGroup:setBorderType(bezelBorder)
        oGroup:setStyle(1)
       
RETURN

*************************************************

FUNCTION RK_PrintShort(cText, nMaxBreedte, cfontName, nFontSize)
*to make a text shorter for fitting in a print say
*date: 20-06-2017

DO WHILE TxtGetWidth( cText, cfontName, nFontSize ) >= (nMaxBreedte*0.95)
    cText := SUBSTR(cText, 1, LEN(cText)-1)
ENDDO

RETURN cText

*************************************************
 


Also the user can print a smal book where there is one plant on every page. It looks like this:http://www.plantenkennis.com/FiveMac/leaflet.pdf

Therefore I use this code:

Code: Select all  Expand view  RUN

FUNCTION RK_PrintLeaflet()
*to print all plantinfo
*date: 13-12-2016
*date: 30-10-2018, diverse aanpassingen zodat het printen op elke printer goed werkt
*A4 papier 595 px breed, 841,5 px hoog

*10 mm = 28 px

LOCAL cLatijnNaam
LOCAL aGegevens
LOCAL aKenmerken
LOCAL cAanteken
LOCAL cSnoei
LOCAL cFoto
LOCAL cText := ''
LOCAL nMaxAantal := 0
LOCAL n
LOCAL oSay, oImg

PUBLIC nCol := 28   && de kolom waarop we printen
PUBLIC nRow := 1    && de rij waar we beginnen
PUBLIC nPage := 1       && paginanummer onderaan

PUBLIC oPrn:=TPrinter():new(0,0,0,0)
oPrn:SetLeftMargin(0)
oPrn:SetRightMargin(0)
oPrn:SetTopMargin(0)
oPrn:SetbottomMargin(0)
oPrn:setPaperName("A4")
oPrn:AutoPage(.T.)

FOR nPage = 1 TO LEN(aPrintArray)
    oPrn:StartPage()
    nRow := 1
    cText := ''
    cLatijnNaam         := RK_GetLatijnseNaam(aPrintArray[nPage,1])
    aGegevens           := RK_CollectGegevens(aPrintArray[nPage,1])
    aKenmerken          := RK_CollectKenmerken(aPrintArray[nPage,1])
    cAanteken           := RK_GetAanteken(aPrintArray[nPage,1])
    cSnoei              := RK_GetSnoei(aPrintArray[nPage,1])
    cFoto               := cFotoPad + ALLTRIM(STR(aPrintArray[nPage,1] + 1)) + ".jpg"

*Latijnse naam
    @ nRow, nCol SAY oSay PROMPT cLatijnNaam OF oPrn PAGINED SIZE 480, 40
        oSay:Setfont("Arial",20 )
        oSay:setTextColor(0,51,0,100)
    nRow++
   
*foto
    @ oPrn:RowPos(nRow), 285 IMAGE oImg OF oPrn SIZE 240, 240 FILENAME cFoto
        oImg:SetFrame()

*vaknr
    @ nRow, nCol SAY oSay PROMPT aPrintArray[nPage,2] OF oPrn PAGINED SIZE 240, 18
            oSay:Setfont("Arial",12 )
    nRow++
   
*plantgegevens
    FOR nGegevens = 1 TO LEN(aGegevens)
        IF LEN(ALLTRIM(aGegevens[nGegevens,1])) > 0
            IF TxtGetWidth( (ALLTRIM(aGegevens[nGegevens,1]) + ': ' + ALLTRIM(aGegevens[nGegevens,2])), "Arial", 12 ) < 255
                cText := cText + ALLTRIM(aGegevens[nGegevens,1]) + ': ' + ALLTRIM(aGegevens[nGegevens,2]) + CR_LF
            ELSE
                cText := cText + ALLTRIM(aGegevens[nGegevens,1]) + ': ' + CR_LF
                cText := cText + SPACE(5) + ALLTRIM(aGegevens[nGegevens,2]) + CR_LF
            ENDIF
        ELSE
            cText := cText + SPACE(5) + ALLTRIM(aGegevens[nGegevens,2]) + CR_LF
        ENDIF
    NEXT
    @ nRow, nCol SAY oSay PROMPT cText OF oPrn PAGINED SIZE 255, 250
        oSay:Setfont("Arial",12 )
   
    IF nRow < 13
        nRow := 13
    ENDIF

    @ nRow, nCol SAY oSay PROMPT 'Kenmerken' OF oPrn PAGINED SIZE 150, 20
        oSay:Setfont("Arial Black",12 )
        nRow++

    @ oPrn:RowPos(nRow), nCol  LINE HORIZONTAL SIZE oPrn:pageWidth() OF oPrn

    FOR nKenmerken = 1 TO LEN(aKenmerken)
        @ nRow, nCol SAY oSay PROMPT aKenmerken[nKenmerken,1] + ':' OF oPrn PAGINED SIZE 90, 20
            oSay:Setfont("Arial",12 )
        @ nRow, nCol+100 SAY oSay PROMPT aKenmerken[nKenmerken,2] OF oPrn PAGINED SIZE 450, 20
            oSay:Setfont("Arial",12 )
        nRow++
    NEXT

    IF LEN(ALLTRIM(cAanteken)) > 0
        cAanteken := RK_GetTextFromRich(cAanteken)
        nLines := MLCount(cAanteken, 95, 3, .T. )
        @ nRow, nCol SAY oSay PROMPT 'Aantekeningen' OF oPrn PAGINED SIZE 300, 20
            oSay:Setfont("Arial Black",12 )
        nRow++
        @ oPrn:RowPos(nRow), nCol LINE HORIZONTAL SIZE oPrn:pageWidth() OF oPrn
        @ nRow, nCol SAY oSay PROMPT cAanteken OF oPrn PAGINED SIZE 525, 200
            oSay:Setfont("Arial",12 )
   
        nRow := nRow + nLines
    ENDIF

    IF LEN(ALLTRIM(cSnoei)) > 0 .AND. oPrn:LastRow()-nRow > 4
   
        @ nRow, nCol SAY oSay PROMPT 'Snoei: ' OF oPrn PAGINED SIZE 150, 20
            oSay:Setfont("Arial Black",12 )
        nRow++

        @ oPrn:RowPos(nRow), nCol LINE HORIZONTAL SIZE oPrn:pageWidth() OF oPrn

        @ nRow, nCol SAY oSay PROMPT cSnoei OF oPrn PAGINED SIZE 500, (oPrn:LastRow()-nRow-1)*20
            oSay:Setfont("Arial",12 )
    ENDIF
   
    RK_PrintFooter()
    oPrn:EndPage()
NEXT

oPrn:run()

RETURN NIL

*************************************************
 


At last we can print a flowering scheme, where you can see in which month there is flowering something. You can also see the colors. Look for a example here: http://www.plantenkennis.com/FiveMac/flowerperiod.pdf

And here is the code for it:

Code: Select all  Expand view  RUN

FUNCTION RK_PrintGrafiek(cPrintTitel)
* to print a raster with flowering periods
* date: 20-06-2017

LOCAL aMaand[12]
LOCAL aKleur[0][3]
    AADD(aKleur, { 255, 218, 185 } )    && abrikoos
    AADD(aKleur, { 0, 0, 255 } )        && blauw
    AADD(aKleur, { 244, 164, 96 } )     && brons
    AADD(aKleur, { 255, 255, 217 } )    && creme
    AADD(aKleur, { 255, 255, 0 } )      && geel
    AADD(aKleur, { 0, 128, 0 } )        && groen
    AADD(aKleur, { 200, 162, 200 } )    && lila
    AADD(aKleur, { 224, 176, 255 } )    && mauve
    AADD(aKleur, { 255, 165, 0 } )      && oranje
    AADD(aKleur, { 170, 0 ,255 } )      && paars
    AADD(aKleur, { 128, 0, 128 } )      && purper
    AADD(aKleur, { 255, 0, 0 } )        && rood
    AADD(aKleur, { 255, 192, 203 } )    && roze
    AADD(aKleur, { 238, 130, 238 } )    && violet
    AADD(aKleur, { 255, 255, 230 } )    && wit
    AADD(aKleur, { 250, 128, 114 } )    && zalm
    AADD(aKleur, { 0, 0 ,0 } )          && zwart

PUBLIC nCol := 28   && de kolom waarop we printen
PUBLIC nRow := 1    && de rij waar we beginnen
PUBLIC nPage := 1       && paginanummer onderaan

PUBLIC oPrn:=TPrinter():new(0,0,0,0)
oPrn:SetLeftMargin(0)
oPrn:SetRightMargin(0)
oPrn:SetTopMargin(0)
oPrn:SetbottomMargin(0)
oPrn:setPaperName("A4")
oPrn:AutoPage(.T.)

oPrn:StartPage()

@ nRow, nCol SAY oSay PROMPT cPrintTitel OF oPrn PAGINED SIZE 450, 20
    oSay:Setfont("Arial",12 )
   
nRow++
RK_PrintBloeiHeader()
   
FOR n = 1 TO LEN(aPrintArray)
        cText := RK_PrintShort(ALLTRIM(RK_GetLatijnseNaam(aPrintArray[n,1])), 220, "Arial", 10)
        nColor := RK_GetKleur(aPrintArray[n,1])
        aMaand := RK_CollectBloeiMaanden(aPrintArray[n,1])
   
    @ nRow, nCol SAY oSay PROMPT cText OF oPrn PAGINED SIZE 200, 20
        oSay:Setfont("Arial",10 )
        oSay:setBkColor(255,255,255,100)
        oSay:setBezeled(.t.,.f.)
    @ nRow, nCol+200 SAY oSay PROMPT '' OF oPrn PAGINED SIZE 25, 20
        oSay:Setfont("Arial",10 )
        IF aMaand[1]
            oSay:setBkColor(aKleur[nColor,1],aKleur[nColor,2],aKleur[nColor,3],100)
        ELSE
            oSay:setBkColor(255,255,255,100)
        ENDIF
        oSay:setBezeled(.t.,.f.)
    @ nRow, nCol+225 SAY oSay PROMPT '' OF oPrn PAGINED SIZE 25, 20
        oSay:Setfont("Arial",10 )
        IF aMaand[2]
            oSay:setBkColor(aKleur[nColor,1],aKleur[nColor,2],aKleur[nColor,3],100)
        ELSE
            oSay:setBkColor(255,255,255,100)
        ENDIF
        oSay:setBezeled(.t.,.f.)
    @ nRow, nCol+250 SAY oSay PROMPT '' OF oPrn PAGINED SIZE 25, 20
        oSay:Setfont("Arial",10 )
        IF aMaand[3]
            oSay:setBkColor(aKleur[nColor,1],aKleur[nColor,2],aKleur[nColor,3],100)
        ELSE
            oSay:setBkColor(255,255,255,100)
        ENDIF
        oSay:setBezeled(.t.,.f.)
    @ nRow, nCol+275 SAY oSay PROMPT '' OF oPrn PAGINED SIZE 25, 20
        oSay:Setfont("Arial",10 )
        IF aMaand[4]
            oSay:setBkColor(aKleur[nColor,1],aKleur[nColor,2],aKleur[nColor,3],100)
        ELSE
            oSay:setBkColor(255,255,255,100)
        ENDIF
        oSay:setBezeled(.t.,.f.)
    @ nRow, nCol+300 SAY oSay PROMPT '' OF oPrn PAGINED SIZE 25, 20
        oSay:Setfont("Arial",10 )
        IF aMaand[5]
            oSay:setBkColor(aKleur[nColor,1],aKleur[nColor,2],aKleur[nColor,3],100)
        ELSE
            oSay:setBkColor(255,255,255,100)
        ENDIF
        oSay:setBezeled(.t.,.f.)
    @ nRow, nCol+325 SAY oSay PROMPT '' OF oPrn PAGINED SIZE 25, 20
        oSay:Setfont("Arial",10 )
        IF aMaand[6]
            oSay:setBkColor(aKleur[nColor,1],aKleur[nColor,2],aKleur[nColor,3],100)
        ELSE
            oSay:setBkColor(255,255,255,100)
        ENDIF
        oSay:setBezeled(.t.,.f.)
    @ nRow, nCol+350 SAY oSay PROMPT '' OF oPrn PAGINED SIZE 25, 20
        oSay:Setfont("Arial",10 )
        IF aMaand[7]
            oSay:setBkColor(aKleur[nColor,1],aKleur[nColor,2],aKleur[nColor,3],100)
        ELSE
            oSay:setBkColor(255,255,255,100)
        ENDIF
        oSay:setBezeled(.t.,.f.)
    @ nRow, nCol+375 SAY oSay PROMPT '' OF oPrn PAGINED SIZE 25, 20
        oSay:Setfont("Arial",10 )
        IF aMaand[8]
            oSay:setBkColor(aKleur[nColor,1],aKleur[nColor,2],aKleur[nColor,3],100)
        ELSE
            oSay:setBkColor(255,255,255,100)
        ENDIF
        oSay:setBezeled(.t.,.f.)
    @ nRow, nCol+400 SAY oSay PROMPT '' OF oPrn PAGINED SIZE 25, 20
        oSay:Setfont("Arial",10 )
        IF aMaand[9]
            oSay:setBkColor(aKleur[nColor,1],aKleur[nColor,2],aKleur[nColor,3],100)
        ELSE
            oSay:setBkColor(255,255,255,100)
        ENDIF
        oSay:setBezeled(.t.,.f.)
    @ nRow, nCol+425 SAY oSay PROMPT '' OF oPrn PAGINED SIZE 25, 20
        oSay:Setfont("Arial",10 )
        IF aMaand[10]
            oSay:setBkColor(aKleur[nColor,1],aKleur[nColor,2],aKleur[nColor,3],100)
        ELSE
            oSay:setBkColor(255,255,255,100)
        ENDIF
        oSay:setBezeled(.t.,.f.)
    @ nRow, nCol+450 SAY oSay PROMPT '' OF oPrn PAGINED SIZE 25, 20
        oSay:Setfont("Arial",10 )
        IF aMaand[11]
            oSay:setBkColor(aKleur[nColor,1],aKleur[nColor,2],aKleur[nColor,3],100)
        ELSE
            oSay:setBkColor(255,255,255,100)
        ENDIF
        oSay:setBezeled(.t.,.f.)
    @ nRow, nCol+475 SAY oSay PROMPT '' OF oPrn PAGINED SIZE 25, 20
        oSay:Setfont("Arial",10 )
        IF aMaand[12]
            oSay:setBkColor(aKleur[nColor,1],aKleur[nColor,2],aKleur[nColor,3],100)
        ELSE
            oSay:setBkColor(255,255,255,100)
        ENDIF
        oSay:setBezeled(.t.,.f.)
    nRow++

    IF nRow > oPrn:LastRow()-3
        RK_PrintFooter()
        nPage++
        nRow := 1
        oPrn:EndPage()
        oPrn:StartPage()
        RK_PrintBloeiHeader()
    ENDIF

NEXT

RK_PrintFooter()
oPrn:EndPage()

oPrn:run()

RETURN NIL

 
Kind regards,

René Koot
User avatar
plantenkennis
 
Posts: 166
Joined: Wed Nov 25, 2015 7:13 pm
Location: the Netherlands

Re: printing several pages

Postby Antonio Linares » Wed Nov 14, 2018 8:45 am

René,

Great work!

Many thanks for sharing your code with all of us.

Really nice :-)
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42122
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Previous

Return to FiveMac / FivePhone (iPhone, iPad)

Who is online

Users browsing this forum: No registered users and 1 guest