I have tested the new class TPrinter and method Say. There are a few things that are not working like it should be:
I have some printouts that i want to be able to make.
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:
At last I have a flowering scheme where you can see in what month what colors are bloming:
Code: Select all
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