|
//----------------------------------------------------------------------
// Project ................: pdfAlmanac.bpr
// Version ................: 1.2.0
// Author .................: G.Ciaccio
// Email ..................: ciacciogi@infinito.it
// Created ................: 22-11-2003
// Development Tool .......: C++ Builder 6.0
// Environment ............: Windows 98
// Copyright ..............: 2002-2003
//----------------------------------------------------------------------
// DISCLAIMER:
// This software is provided 'as-is', without any express or
// implied warranty. In no event will the author be held liable
// for any damages arising from the use of this software.
//----------------------------------------------------------------------
// PURPOSE:
// pdfAlmanac.exe produce different calendars in PDF format for any year
// in the range 1583-2299
//----------------------------------------------------------------------
#include <vcl.h>
//---------------------------------------------------------------------------
#pragma hdrstop
#include "Almanac.h"
#include "Unit1.h"
#include "math.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
//============================================================================
int Almanac::bold=0; //0=No 1=Yes
int Almanac::autostart=1; //0=No 1=Yes
int Almanac::language=1; //0=Italian Help 1=English Help
int Almanac::xfont=0;
int Almanac::xcalendartype=1;
int Almanac::xdaynames=0;
int Almanac::xmarkedfestivity=0;
int Almanac::xbannercolor=1;
int Almanac::xlanguage=0;
TColor Almanac::mesecolor=clBlue; //month name color
TColor Almanac::bandcolor=clWhite; //banner color
//============================================================================
Almanac::Almanac(int year){
int valrit,iniday,psq;
mese=1;
anno=year;
valrit=infoyear(year);
if(valrit<0){bstile=1;iniday=-valrit;nday=366;}
else{bstile=0;iniday=valrit;nday=365;}
firstday=iniday;
setmesi(bstile);
setgiorni(bstile);
setweekchar(bstile,iniday);
setfixedholidays(bstile);
psq=gauss(year,bstile);
setafterpsq(psq);
setmoon(year,bstile);
if(xdaynames==0)loadnames(bstile,psq); //get names from resource file
else setweekdaynames(bstile);
}
//---------------------------------------------------------------------------
void Almanac::reset(int year){
int valrit,iniday,psq;
mese=1;
anno=year;
valrit=infoyear(year);
if(valrit<0){bstile=1;iniday=-valrit;nday=366;}
else{bstile=0;iniday=valrit;nday=365;}
firstday=iniday;
setmesi(bstile);
setgiorni(bstile);
setweekchar(bstile,iniday);
setfixedholidays(bstile);
psq=gauss(year,bstile);
setafterpsq(psq);
setmoon(year,bstile);
if(xdaynames==0)loadnames(bstile,psq);
else setweekdaynames(bstile);
}
//---------------------------------------------------------------------------
int Almanac::infoyear(int anno){
//Return a number between 1 and 7 to qualify the first day of the year passed
//as argument (Monday=1,Tuesday=2,...,Sunday=7)
//This function is valid only if 1583<=anno<=2299
bool vbool;
int capod,xanno;
int valrit;
if(anno==1583){
capod=6;
}else{
xanno=1583;
capod=6;
do{
xanno=xanno+1;
vbool=isleapyear(xanno-1);
if(vbool==true)capod=capod+2;else capod=capod+1;
if(capod>7)capod=capod-7;
}while(xanno<anno);
}
if(isleapyear(anno)==true)valrit=-capod;else valrit=capod;
return valrit;
}
//--------------------------------------------------------------------------
bool Almanac::isleapyear(int anno){
int r4,r100,r400;
bool vbool;
r4=anno%4;
r100=anno%100;
r400=anno%400;
if(r100==0){
//century year
if(r400==0)vbool=true;else vbool=false;
}else{
//not century year
if(r4==0)vbool=true;else vbool=false;
}
return vbool;
}
//--------------------------------------------------------------------------
void Almanac::loadnames(int bstile,int psqday){
//Loads calendar names from the resource file names.rc (for italian calendar)
int j,ymese,jday,jstr;
AnsiString astr;
jstr=0;
if(xlanguage==0){
//Italian calendar
for(j=1;j<=365+bstile;j=j+1){
jday=xday[j].mday;
ymese=xday[j].mese;
if(ymese==2 && jday==29){
//29 february
astr=AnsiString::LoadStr(IDS_NAME59bis);
}else{
jstr=jstr+1;
if(j==psqday)astr="Pasqua";else astr=AnsiString::LoadStr(100+jstr);
}//else
lstrcpy(&xday[j].nameday[0],astr.c_str());
}//for_j
}else{
for(j=1;j<=365+bstile;j=j+1){
jday=xday[j].mday;
ymese=xday[j].mese;
if(ymese==2 && jday==29){
//29 february
//astr=AnsiString::LoadStr(IDS_NAME59bis);
astr="____________";
}else{
jstr=jstr+1;
//if(j==psqday)astr="Pasqua";else astr=AnsiString::LoadStr(100+jstr);
astr="____________";
}//else
lstrcpy(&xday[j].nameday[0],astr.c_str());
}//for_j
}
}
//--------------------------------------------------------------------------
void Almanac::showparam(){
AnsiString astr;
if(Almanac::language==0){astr="anno="+IntToStr(anno)+"\n";
}else{
astr="year="+IntToStr(anno)+"\n";
}
astr=astr+"ngold="+IntToStr(ngold)+"\n";
astr=astr+"epatta="+IntToStr(epatta)+"\n";
astr=astr+"psqday="+IntToStr(psqday)+"\n";
astr=astr+"psqgauss="+IntToStr(psqgauss);
ShowMessage(astr.c_str());
}
//--------------------------------------------------------------------------
int Almanac::maxwname(CPDFdoc *pdf,int day1,int day2){
char str[256];
int wmaxname,j;
AnsiString astrname;
int wstr;
wmaxname=0;
for(j=day1;j<=day2;j=j+1){
astrname=&xday[j].nameday[0];
lstrcpy(&str[0],astrname.c_str());
wstr=cpdf_stringWidth(pdf,&str[0]);
if(wstr>wmaxname){wmaxname=wstr;}
}//for_j
return wmaxname;
}
//--------------------------------------------------------------------------
void Almanac::setmesi(int bstile){
int j,bs,xmese;
bs=bstile;
for(j=1;j<=365+bs;j=j+1){
if(j>=1 && j<=31)xmese=1;
else if(j>31 && j<=59+bs)xmese=2;
else if(j>59+bs && j<=90+bs)xmese=3;
else if(j>90+bs && j<=120+bs)xmese=4;
else if(j>120+bs && j<=151+bs)xmese=5;
else if(j>151+bs && j<=181+bs)xmese=6;
else if(j>181+bs && j<=212+bs)xmese=7;
else if(j>212+bs && j<=243+bs)xmese=8;
else if(j>243+bs && j<=273+bs)xmese=9;
else if(j>273+bs && j<=304+bs)xmese=10;
else if(j>304+bs && j<=334+bs)xmese=11;
else if(j>334+bs && j<=365+bs)xmese=12;
else ShowMessage("Errore in setmesi");
xday[j].mese=xmese;
}//for_j
}
//--------------------------------------------------------------------------
void Almanac::setgiorni(int bstile){
int j,bs,mday;
bs=bstile;
for(j=1;j<=365+bs;j=j+1){
if(bs==0){
//normal year
switch(j){
case 1:mday=1;break;
case 32:mday=1;break;
case 60:mday=1;break;
case 91:mday=1;break;
case 121:mday=1;break;
case 152:mday=1;break;
case 182:mday=1;break;
case 213:mday=1;break;
case 244:mday=1;break;
case 274:mday=1;break;
case 305:mday=1;break;
case 335:mday=1;break;
case 366:mday=1;break;
default:mday=mday+1;
}//switch_jday
}else{
//leap year
switch(j){
case 1:mday=1;break;
case 32:mday=1;break;
case 61:mday=1;break;
case 92:mday=1;break;
case 122:mday=1;break;
case 153:mday=1;break;
case 183:mday=1;break;
case 214:mday=1;break;
case 245:mday=1;break;
case 275:mday=1;break;
case 306:mday=1;break;
case 336:mday=1;break;
case 367:mday=1;break;
default:mday=mday+1;
}//switch_jday
}//else
xday[j].mday=mday;
}//for_j
}
//--------------------------------------------------------------------------
void Almanac::setweekchar(int bstile,int wday1gen){
int j,wday,bs;
bs=bstile;
for(j=1;j<=365+bs;j=j+1){
if(j==1)wday=wday1gen;
else{wday=wday+1;if(wday>7)wday=1;}
xday[j].wday=wday;
if(xlanguage==0){
//Italian calendar
switch(wday){
case 1:xday[j].chday='L';break; //Lunedì
case 2:xday[j].chday='M';break; //Martedì
case 3:xday[j].chday='M';break; //Mercoledì
case 4:xday[j].chday='G';break; //Giovedì
case 5:xday[j].chday='V';break; //Venerdì
case 6:xday[j].chday='S';break; //Sabato
case 7:xday[j].chday='D';break; //Domenica
}//switch_wday
}else if(xlanguage==1){
//English calendar
switch(wday){
case 1:xday[j].chday='M';break; //Monday
case 2:xday[j].chday='T';break; //Tuesday
case 3:xday[j].chday='W';break; //Wednesday
case 4:xday[j].chday='T';break; //Thursday
case 5:xday[j].chday='F';break; //Friday
case 6:xday[j].chday='S';break; //Saturday
case 7:xday[j].chday='S';break; //Sunday
}//switch_wday
}else if(xlanguage==2){
//French calendar
switch(wday){
case 1:xday[j].chday='L';break; //Lundì
case 2:xday[j].chday='M';break; //Mardì
case 3:xday[j].chday='M';break; //Mercredì
case 4:xday[j].chday='J';break; //Jeudì
case 5:xday[j].chday='V';break; //Vendredi
case 6:xday[j].chday='S';break; //Samedi
case 7:xday[j].chday='D';break; //Dimanche
}//switch_wday
}else if(xlanguage==3){
//German calendar
switch(wday){
case 1:xday[j].chday='M';break; //Montag
case 2:xday[j].chday='D';break; //Diestag
case 3:xday[j].chday='M';break; //Mittwoch
case 4:xday[j].chday='D';break; //Donnerstag
case 5:xday[j].chday='F';break; //Freitag
case 6:xday[j].chday='S';break; //Samstag
case 7:xday[j].chday='S';break; //Sonntag
}//switch_wday
}else{
//Spanish calendar (not implemented)
}
if(wday==7)xday[j].festflag=1;else xday[j].festflag=0;
}//for_j
}
//--------------------------------------------------------------------------
void Almanac::setfixedholidays(int bstile){
int bs;
bs=bstile;
switch(xlanguage){
case 0:
//Italian calendar
if(xmarkedfestivity==0){
//Fixed holidays of italian calendar
xday[1].festflag=2; //1 gennaio
xday[6].festflag=2; //6 gennaio
xday[115+bs].festflag=2; //25 aprile
xday[121+bs].festflag=2; //1 maggio
xday[153+bs].festflag=2; //2 giugno
xday[227+bs].festflag=2; //15 agosto
xday[305+bs].festflag=2; //1 novembre
xday[342+bs].festflag=2; //8 dicembre
xday[359+bs].festflag=2; //25 dicembre
xday[360+bs].festflag=2; //26 dicembre
}else{
//Set as fixed holiday only 1 January
xday[1].festflag=2;}//else_xmarkedfestivity
break;
case 1:
//English calendar
if(xmarkedfestivity==0){
//Fixed holidays of english calendar
xday[1].festflag=2; //1 January
//...
//...
//...
}else{
//Set as fixed holiday only 1 January
xday[1].festflag=2;}//else_xmarkedfestivity
break;
case 2:
//French calendar
if(xmarkedfestivity==0){
//Fixed holidays of french calendar
xday[1].festflag=2; //1 January
//...
//...
//...
}else{
//Set as fixed holiday only 1 January
xday[1].festflag=2;}//else_xmarkedfestivity
break;
case 3:
//German calendar
if(xmarkedfestivity==0){
//Fixed holidays of german calendar
xday[1].festflag=2; //1 January
//...
//...
//...
}else{
//Set as fixed holiday only 1 January
xday[1].festflag=2;}//else_xmarkedfestivity
break;
case4:
//Spanish calendar
if(xmarkedfestivity==0){
//Fixed holidays of spanish calendar
xday[1].festflag=2; //1 January
//...
//...
//...
}else{
//Set as fixed holiday only 1 January
xday[1].festflag=2;
}//else_xmarkedfestivity
break;
default:
break;
}//switch_xlanguage
}
//--------------------------------------------------------------------------
int Almanac::gauss(int anno,int bstile){
int m,n;
int a,b,c,d,e,psqmarzo,psqgen,vp;
if(anno>=1583 && anno<1700){m=22;n=2;}
else if(anno>=1700 && anno<1800){m=23;n=3;}
else if(anno>=1800 && anno<1900){m=23;n=4;}
else if(anno>=1900 && anno<2100){m=24;n=5;}
else if(anno>=2100 && anno<2200){m=24;n=6;}
else if(anno>=2200 && anno<2300){m=25;n=0;}
else {ShowMessage("Valore non gestito");return -1;}
vp=anno/19;a=anno-19*vp;
vp=anno/4;b=anno-4*vp;
vp=anno/7;c=anno-7*vp;
vp=(19*a+m)/30;d=(19*a+m)-30*vp;
vp=(2*b+4*c+6*d+n)/7;e=(2*b+4*c+6*d+n)-7*vp;
psqmarzo=22+d+e;
psqgauss=psqmarzo;
psqgen=psqmarzo;
//exceptions to Gauss method
if(e==6){
if(d==29){psqgen=psqgen-7;}
if(d==28 && a>10){psqgen=psqgen-7;}
}//if_e
psqgen=psqgen+59+bstile;
psqday=psqgen;
return psqgen;
}
//--------------------------------------------------------------------------
void Almanac::setafterpsq(int psq){
if(xlanguage==0 && xmarkedfestivity==0)xday[psq+1].festflag=3;
}
//--------------------------------------------------------------------------
int Almanac::gauss(int anno){
int m,n;
int a,b,c,d,e,psqmarzo,vp;
if(anno>=1583 && anno<1700){m=22;n=2;}
else if(anno>=1700 && anno<1800){m=23;n=3;}
else if(anno>=1800 && anno<1900){m=23;n=4;}
else if(anno>=1900 && anno<2100){m=24;n=5;}
else if(anno>=2100 && anno<2200){m=24;n=6;}
else if(anno>=2200 && anno<2300){m=25;n=0;}
else {ShowMessage("Valore non gestito");return -1;}
vp=anno/19;a=anno-19*vp;
vp=anno/4;b=anno-4*vp;
vp=anno/7;c=anno-7*vp;
vp=(19*a+m)/30;d=(19*a+m)-30*vp;
vp=(2*b+4*c+6*d+n)/7;e=(2*b+4*c+6*d+n)-7*vp;
psqmarzo=22+d+e;
//exceptions to Gauss method
if(e==6){
if(d==29){psqmarzo=psqmarzo-7;}
if(d==28 && a>10){psqmarzo=psqmarzo-7;}
}//if_e
return psqmarzo;
}
//--------------------------------------------------------------------------
void Almanac::setmoon(int anno,int bstyle){
//Calcolo approssimato di pleniluni e noviluni tramite l'epatta
//Rough estimate of plenilune and new moon
int j,bs;
int divint,pl0,plenilunio1,pluniox,nl0,novilunio1,nluniox,flipflop;
divint=anno/19;
ngold=1+anno-19*divint;
epatta=18+ngold*11;
while(epatta>30) epatta=epatta-30;
bs=bstile;
for(j=1;j<=365+bs;j=j+1){xday[j].chmoon=' ';}
//plenilune
pl0=14-epatta; //plenilunio di competenza del 1 Gennaio
if(pl0>0)plenilunio1=pl0;else plenilunio1=pl0+29;
pluniox=plenilunio1;
flipflop=0;
do{
xday[pluniox].chmoon='>';
if(flipflop==0){pluniox=pluniox+30;flipflop=1;}
else{pluniox=pluniox+29;flipflop=0;}
}while(pluniox<=365+bstyle);
//new moon
nl0=plenilunio1-14;
if(nl0>0)novilunio1=nl0;else novilunio1=nl0+29;
nluniox=novilunio1;
flipflop=0;
do{
xday[nluniox].chmoon='<';
if(flipflop==0){nluniox=nluniox+30;flipflop=1;}
else{nluniox=nluniox+29;flipflop=0;}
}while(nluniox<=365+bstyle);
}
//--------------------------------------------------------------------------
void Almanac::gopdfalmanac(){
char buf[32];
CPDFdoc *pdf;
AnsiString astr;
int j;
pdf=cpdf_open(0,NULL);
cpdf_enableCompression(pdf,YES);
cpdf_init(pdf);
for(j=1;j<=12;j=j+1){makepdfpage(pdf,j);}
cpdf_finalizeAll(pdf);
if(xfont==0){astr="_Almanac"+IntToStr(anno)+"ag.pdf";}
else if(xfont==1){astr="_Almanac"+IntToStr(anno)+"bm.pdf";}
else if(xfont==2){astr="_Almanac"+IntToStr(anno)+"co.pdf";}
else if(xfont==3){astr="_Almanac"+IntToStr(anno)+"he.pdf";}
else if(xfont==4){astr="_Almanac"+IntToStr(anno)+"hc.pdf";}
else if(xfont==5){astr="_Almanac"+IntToStr(anno)+"hn.pdf";}
else if(xfont==6){astr="_Almanac"+IntToStr(anno)+"pa.pdf";}
else if(xfont==7){astr="_Almanac"+IntToStr(anno)+"ti.pdf";}
else ShowMessage("Caso non previsto");
psavedlg=new TSaveDialog(Application);
psavedlg->FileName=astr;
if (psavedlg->Execute()){
astr=psavedlg->FileName;
cpdf_savePDFmemoryStreamToFile(pdf,astr.c_str());
if(autostart!=0)cpdf_launchPreview(pdf); //start Acrobat Reader
}//if_psavedialog
cpdf_close(pdf);
if(psavedlg!=0){delete psavedlg;psavedlg=0;}
}
//--------------------------------------------------------------------------
void Almanac::makepdfpage(CPDFdoc *pdf,int jmese){
char str[64];
char riga[256];
char chstr[6];
int j,festflag;
float wpage,hpage;
float hh,centerpos,wstr;
float red,green,blue;
int iniday,endday;
float numberspace,w1,w2,w3,w4,w5,w6,wmaxname;
float wbordo,wrigatura;
int n_;
AnsiString xastr;
wpage=595;hpage=842;
cpdf_pageInit(pdf,jmese,PORTRAIT,A4,A4);
cpdf_setgrayFill(pdf, 0.0); //Black
cpdf_beginText(pdf, 0);
if(xlanguage==0){
//Italian calendar
switch(jmese){
case 1:wsprintf(&str[0],"GENNAIO %i\0",anno);
iniday=1;endday=31;break;
case 2:wsprintf(&str[0],"FEBBRAIO %i\0",anno);
iniday=32;endday=59+bstile;break;
case 3:wsprintf(&str[0],"MARZO %i\0",anno);
iniday=60+bstile;endday=90+bstile;break;
case 4:wsprintf(&str[0],"APRILE %i\0",anno);
iniday=91+bstile;endday=120+bstile;break;
case 5:wsprintf(&str[0],"MAGGIO %i\0",anno);
iniday=121+bstile;endday=151+bstile;break;
case 6:wsprintf(&str[0],"GIUGNO %i\0",anno);
iniday=152+bstile;endday=181+bstile;break;
case 7:wsprintf(&str[0],"LUGLIO %i\0",anno);
iniday=182+bstile;endday=212+bstile;break;
case 8:wsprintf(&str[0],"AGOSTO %i\0",anno);
iniday=213+bstile;endday=243+bstile;break;
case 9:wsprintf(&str[0],"SETTEMBRE %i\0",anno);
iniday=244+bstile;endday=273+bstile;break;
case 10:wsprintf(&str[0],"OTTOBRE %i\0",anno);
iniday=274+bstile;endday=304+bstile;break;
case 11:wsprintf(&str[0],"NOVEMBRE %i\0",anno);
iniday=305+bstile;endday=334+bstile;break;
case 12:wsprintf(&str[0],"DICEMBRE %i\0",anno);
iniday=335+bstile;endday=365+bstile;break;
}//switch_mese
}else if(xlanguage==1){
//English calendar
switch(jmese){
case 1:wsprintf(&str[0],"JANUARY %i\0",anno);
iniday=1;endday=31;break;
case 2:wsprintf(&str[0],"FEBRUARY %i\0",anno);
iniday=32;endday=59+bstile;break;
case 3:wsprintf(&str[0],"MARCH %i\0",anno);
iniday=60+bstile;endday=90+bstile;break;
case 4:wsprintf(&str[0],"APRIL %i\0",anno);
iniday=91+bstile;endday=120+bstile;break;
case 5:wsprintf(&str[0],"MAY %i\0",anno);
iniday=121+bstile;endday=151+bstile;break;
case 6:wsprintf(&str[0],"JUNE %i\0",anno);
iniday=152+bstile;endday=181+bstile;break;
case 7:wsprintf(&str[0],"JULY %i\0",anno);
iniday=182+bstile;endday=212+bstile;break;
case 8:wsprintf(&str[0],"AUGUST %i\0",anno);
iniday=213+bstile;endday=243+bstile;break;
case 9:wsprintf(&str[0],"SEPTEMBER %i\0",anno);
iniday=244+bstile;endday=273+bstile;break;
case 10:wsprintf(&str[0],"OCTOBER %i\0",anno);
iniday=274+bstile;endday=304+bstile;break;
case 11:wsprintf(&str[0],"NOVEMBER %i\0",anno);
iniday=305+bstile;endday=334+bstile;break;
case 12:wsprintf(&str[0],"DECEMBER %i\0",anno);
iniday=335+bstile;endday=365+bstile;break;
}//switch_mese
}else if(xlanguage==2){
//French calendar
switch(jmese){
case 1:wsprintf(&str[0],"JANVIER %i\0",anno);
iniday=1;endday=31;break;
case 2:wsprintf(&str[0],"FEVRIER %i\0",anno);
iniday=32;endday=59+bstile;break;
case 3:wsprintf(&str[0],"MARS %i\0",anno);
iniday=60+bstile;endday=90+bstile;break;
case 4:wsprintf(&str[0],"AVRIL %i\0",anno);
iniday=91+bstile;endday=120+bstile;break;
case 5:wsprintf(&str[0],"MAI %i\0",anno);
iniday=121+bstile;endday=151+bstile;break;
case 6:wsprintf(&str[0],"JUIN %i\0",anno);
iniday=152+bstile;endday=181+bstile;break;
case 7:wsprintf(&str[0],"JUILLET %i\0",anno);
iniday=182+bstile;endday=212+bstile;break;
case 8:wsprintf(&str[0],"AOUT %i\0",anno);
iniday=213+bstile;endday=243+bstile;break;
case 9:wsprintf(&str[0],"SEPTEMBRE %i\0",anno);
iniday=244+bstile;endday=273+bstile;break;
case 10:wsprintf(&str[0],"OCTOBRE %i\0",anno);
iniday=274+bstile;endday=304+bstile;break;
case 11:wsprintf(&str[0],"NOVEMBRE %i\0",anno);
iniday=305+bstile;endday=334+bstile;break;
case 12:wsprintf(&str[0],"DECEMBRE %i\0",anno);
iniday=335+bstile;endday=365+bstile;break;
}//switch_mese
}//else_language
else if(xlanguage==3){
//German calendar
switch(jmese){
case 1:wsprintf(&str[0],"JANUAR %i\0",anno);
iniday=1;endday=31;break;
case 2:wsprintf(&str[0],"FEBRUAR %i\0",anno);
iniday=32;endday=59+bstile;break;
case 3:wsprintf(&str[0],"MARZ %i\0",anno);
iniday=60+bstile;endday=90+bstile;break;
case 4:wsprintf(&str[0],"APRIL %i\0",anno);
iniday=91+bstile;endday=120+bstile;break;
case 5:wsprintf(&str[0],"MAI %i\0",anno);
iniday=121+bstile;endday=151+bstile;break;
case 6:wsprintf(&str[0],"JUNI %i\0",anno);
iniday=152+bstile;endday=181+bstile;break;
case 7:wsprintf(&str[0],"JULI %i\0",anno);
iniday=182+bstile;endday=212+bstile;break;
case 8:wsprintf(&str[0],"AUGUST %i\0",anno);
iniday=213+bstile;endday=243+bstile;break;
case 9:wsprintf(&str[0],"SEPTEMBRE %i\0",anno);
iniday=244+bstile;endday=273+bstile;break;
case 10:wsprintf(&str[0],"OKTOBER %i\0",anno);
iniday=274+bstile;endday=304+bstile;break;
case 11:wsprintf(&str[0],"NOVEMBER %i\0",anno);
iniday=305+bstile;endday=334+bstile;break;
case 12:wsprintf(&str[0],"DEZEMBER %i\0",anno);
iniday=335+bstile;endday=365+bstile;break;
}//switch_mese
}else{
//Spanish calendar (not implemented)
}
hh=hpage-mmtotpoint(42);
pdfsetfont(pdf,28.0);
wstr=cpdf_stringWidth(pdf,&str[0]);
centerpos=(wpage-wstr)/2;
red=(float)GetRValue(ColorToRGB(mesecolor));red=red/255.0;
green=(float)GetGValue(ColorToRGB(mesecolor));green=green/255.0;
blue=(float)GetBValue(ColorToRGB(mesecolor));blue=blue/255.0;
cpdf_setrgbcolor(pdf,red,green,blue);
cpdf_rawText(pdf,centerpos,hh,0.0,&str[0]);
hh=hpage-mmtotpoint(62);
pdfsetfont(pdf,16.0);
for(j=1;j<=nday;j=j+1){
if(xday[j].mese==jmese){
xastr="1234567890";
numberspace=cpdf_stringWidth(pdf,xastr.c_str())/10;
wmaxname=maxwname(pdf,iniday,endday);
wbordo=2*numberspace;
w1=wbordo;
w2=w1+3.5*numberspace;
w3=w2+2.5*numberspace;
w4=w3+2.5*numberspace;
w5=w4+0.5*numberspace;
w6=w5+wmaxname+numberspace;
wrigatura=wpage-w6-wbordo;
n_=0;
do{
riga[n_]='_';riga[n_+1]=0;
wstr=cpdf_stringWidth(pdf,&riga[0]);
n_=n_+1;
}while(wstr<wrigatura);
riga[n_-1]=0;
festflag=xday[j].festflag;
if(festflag!=0)cpdf_setrgbcolor(pdf,1.0,0.0,0.0);
else cpdf_setrgbcolor(pdf,0.0,0.0,0.0);
xastr=IntToStr(xday[j].mday);
wstr=cpdf_stringWidth(pdf,xastr.c_str());
centerpos=w1+(w2-w1-wstr)/2;
cpdf_rawText(pdf,centerpos,hh,0.0,xastr.c_str());
chstr[0]=xday[j].chday;chstr[1]=0;
xastr=&chstr[0];
wstr=cpdf_stringWidth(pdf,xastr.c_str());
centerpos=w2+(w3-w2-wstr)/2;
cpdf_rawText(pdf,centerpos,hh,0.0,xastr.c_str());
chstr[0]=xday[j].chmoon;chstr[1]=0;
xastr=&chstr[0];
wstr=cpdf_stringWidth(pdf,xastr.c_str());
centerpos=w3+(w4-w3-wstr)/2;
cpdf_rawText(pdf,centerpos,hh,0.0,xastr.c_str());
xastr=&xday[j].nameday[0];
cpdf_rawText(pdf,w5,hh,0.0,xastr.c_str());
cpdf_rawText(pdf,w6,hh,0.0,&riga[0]);
hh=hh-21;
}//if_day[j].mese
}//for_j
cpdf_endText(pdf);
cpdf_finalizePage(pdf,jmese);
}
//--------------------------------------------------------------------------
void Almanac::goboxpdfalmanac(){
CPDFdoc *pdf;
AnsiString astr;
int j;
pdf=cpdf_open(0,NULL);
cpdf_enableCompression(pdf,YES);
cpdf_init(pdf);
for(j=1;j<=12;j=j+1){makeboxpdfpage(pdf,j);}
cpdf_finalizeAll(pdf);
if(xfont==0){astr="Almanac"+IntToStr(anno)+"ag.pdf";}
else if(xfont==1){astr="Almanac"+IntToStr(anno)+"bm.pdf";}
else if(xfont==2){astr="Almanac"+IntToStr(anno)+"co.pdf";}
else if(xfont==3){astr="Almanac"+IntToStr(anno)+"he.pdf";}
else if(xfont==4){astr="Almanac"+IntToStr(anno)+"hc.pdf";}
else if(xfont==5){astr="Almanac"+IntToStr(anno)+"hn.pdf";}
else if(xfont==6){astr="Almanac"+IntToStr(anno)+"pa.pdf";}
else if(xfont==7){astr="Almanac"+IntToStr(anno)+"ti.pdf";}
else ShowMessage("Caso non previsto");
psavedlg=new TSaveDialog(Application);
psavedlg->FileName=astr;
if (psavedlg->Execute()){
astr=psavedlg->FileName;
cpdf_savePDFmemoryStreamToFile(pdf,astr.c_str());
if(autostart!=0)cpdf_launchPreview(pdf); //start Acrobat Reader
}//if_psavedialog
cpdf_close(pdf);
if(psavedlg!=0){delete psavedlg;psavedlg=0;}
}
//--------------------------------------------------------------------------
void Almanac::makeboxpdfpage(CPDFdoc *pdf,int jmese){
char str[64];
char riga[256];
char chstr[6];
int j,festflag;
float wpage,hpage;
float hh,centerpos;
float wstr,hstr,xstr,ystr;
float red,green,blue;
float fontsize,fontsize1;
int iniday,endday;
float wbordo,wrigatura;
float x1,x2,x3,x4,x5,x6,x7,x8,x9,x10,x11,x12,x13,x14,margine;
float y1,y2,y3,y4,y5,y6,y7,y8,y9,y10,y11,y12,y13,y14;
int n_;
AnsiString xastr;
wpage=595;hpage=842;
margine=mmtotpoint(2);
x1=mmtotpoint(5);
x2=wpage-mmtotpoint(5);
x3=x1;
x4=x2;
x5=x1;
x6=x2;
x7=x1+mmtotpoint(10);x8=x7;
x9=x7+mmtotpoint(8);x10=x9;
x11=x9+mmtotpoint(6);x12=x11;
x13=x11+mmtotpoint(40);x14=x13;
//se si varia names.rc può essere necessario variare x13
//modifying names.rc may require to change x13 value
y1=hpage-mmtotpoint(30);
y3=hpage-mmtotpoint(50);
y5=mmtotpoint(5);
y6=y5;
y2=y1;
y4=y3;
y7=y5;y8=y3;
y9=y5;y10=y3;
y11=y5;y12=y3;
y13=y5;y14=y3;
cpdf_pageInit(pdf,jmese,PORTRAIT,A4,A4);
cpdf_gsave(pdf);
cpdf_newpath(pdf);
cpdf_setlinewidth(pdf,1.0);
if(xbannercolor!=0){
switch(jmese){
case 1:red=255.0/255.0;green=170.0/255.0;blue=170.0/255.0;break;
case 2:red=204.0/255.0;green=204.0/255.0;blue=255.0/255.0;break;
case 3:red=135.0/255.0;green=206.0/255.0;blue=235.0/255.0;break;
case 4:red=204.0/255.0;green=255.0/255.0;blue=204.0/255.0;break;
case 5:red=252.0/255.0;green=186.0/255.0;blue=217.0/255.0;break;
case 6:red=204.0/255.0;green=204.0/255.0;blue=128.0/255.0;break;
case 7:red=240.0/255.0;green=230.0/255.0;blue=140.0/255.0;break;
case 8:red=255.0/255.0;green=192.0/255.0;blue=255.0/255.0;break;
case 9:red=152.0/255.0;green=255.0/255.0;blue=255.0/255.0;break;
case 10:red=182.0/255.0;green=201.0/255.0;blue=211.0/255.0;break;
case 11:red=204.0/255.0;green=204.0/255.0;blue=204.0/255.0;break;
case 12:red=255.0/255.0;green=204.0/255.0;blue=204.0/255.0;break;
default:
ShowMessage("Caso non previsto");
break;
}//switch_jmese
}else{
red=(float)GetRValue(ColorToRGB(bandcolor));red=red/255.0;
green=(float)GetGValue(ColorToRGB(bandcolor));green=green/255.0;
blue=(float)GetBValue(ColorToRGB(bandcolor));blue=blue/255.0;
}
cpdf_setrgbcolorFill(pdf,red,green,blue);
cpdf_setrgbcolorStroke(pdf,0.0,0.0,0.0);
cpdf_rawRect(pdf,x3,y3,x4-x3,y1-y3);
cpdf_fillAndStroke(pdf);
cpdf_rawMoveto(pdf,x3,y3);
cpdf_rawLineto(pdf,x5,y5);
cpdf_rawLineto(pdf,x6,y6);
cpdf_rawLineto(pdf,x4,y4);
cpdf_rawMoveto(pdf,x7,y7);cpdf_rawLineto(pdf,x8,y8);
cpdf_rawMoveto(pdf,x9,y9);cpdf_rawLineto(pdf,x10,y10);
cpdf_rawMoveto(pdf,x11,y11);cpdf_rawLineto(pdf,x12,y12);
cpdf_rawMoveto(pdf,x13,y13);cpdf_rawLineto(pdf,x14,y14);
cpdf_stroke(pdf);
cpdf_grestore(pdf);
cpdf_beginText(pdf, 0);
//------------------------------------
if(xlanguage==0){
//Italian calendar
switch(jmese){
case 1:wsprintf(&str[0],"GENNAIO %i\0",anno);
iniday=1;endday=31;break;
case 2:wsprintf(&str[0],"FEBBRAIO %i\0",anno);
iniday=32;endday=59+bstile;break;
case 3:wsprintf(&str[0],"MARZO %i\0",anno);
iniday=60+bstile;endday=90+bstile;break;
case 4:wsprintf(&str[0],"APRILE %i\0",anno);
iniday=91+bstile;endday=120+bstile;break;
case 5:wsprintf(&str[0],"MAGGIO %i\0",anno);
iniday=121+bstile;endday=151+bstile;break;
case 6:wsprintf(&str[0],"GIUGNO %i\0",anno);
iniday=152+bstile;endday=181+bstile;break;
case 7:wsprintf(&str[0],"LUGLIO %i\0",anno);
iniday=182+bstile;endday=212+bstile;break;
case 8:wsprintf(&str[0],"AGOSTO %i\0",anno);
iniday=213+bstile;endday=243+bstile;break;
case 9:wsprintf(&str[0],"SETTEMBRE %i\0",anno);
iniday=244+bstile;endday=273+bstile;break;
case 10:wsprintf(&str[0],"OTTOBRE %i\0",anno);
iniday=274+bstile;endday=304+bstile;break;
case 11:wsprintf(&str[0],"NOVEMBRE %i\0",anno);
iniday=305+bstile;endday=334+bstile;break;
case 12:wsprintf(&str[0],"DICEMBRE %i\0",anno);
iniday=335+bstile;endday=365+bstile;break;
}//switch_mese
}else if(xlanguage==1){
//English calendar
switch(jmese){
case 1:wsprintf(&str[0],"JANUARY %i\0",anno);
iniday=1;endday=31;break;
case 2:wsprintf(&str[0],"FEBRUARY %i\0",anno);
iniday=32;endday=59+bstile;break;
case 3:wsprintf(&str[0],"MARCH %i\0",anno);
iniday=60+bstile;endday=90+bstile;break;
case 4:wsprintf(&str[0],"APRIL %i\0",anno);
iniday=91+bstile;endday=120+bstile;break;
case 5:wsprintf(&str[0],"MAY %i\0",anno);
iniday=121+bstile;endday=151+bstile;break;
case 6:wsprintf(&str[0],"JUNE %i\0",anno);
iniday=152+bstile;endday=181+bstile;break;
case 7:wsprintf(&str[0],"JULY %i\0",anno);
iniday=182+bstile;endday=212+bstile;break;
case 8:wsprintf(&str[0],"AUGUST %i\0",anno);
iniday=213+bstile;endday=243+bstile;break;
case 9:wsprintf(&str[0],"SEPTEMBER %i\0",anno);
iniday=244+bstile;endday=273+bstile;break;
case 10:wsprintf(&str[0],"OCTOBER %i\0",anno);
iniday=274+bstile;endday=304+bstile;break;
case 11:wsprintf(&str[0],"NOVEMBER %i\0",anno);
iniday=305+bstile;endday=334+bstile;break;
case 12:wsprintf(&str[0],"DECEMBER %i\0",anno);
iniday=335+bstile;endday=365+bstile;break;
}//switch_mese
}else if(xlanguage==2){
//French calendar
switch(jmese){
case 1:wsprintf(&str[0],"JANVIER %i\0",anno);
iniday=1;endday=31;break;
case 2:wsprintf(&str[0],"FEVRIER %i\0",anno);
iniday=32;endday=59+bstile;break;
case 3:wsprintf(&str[0],"MARS %i\0",anno);
iniday=60+bstile;endday=90+bstile;break;
case 4:wsprintf(&str[0],"AVRIL %i\0",anno);
iniday=91+bstile;endday=120+bstile;break;
case 5:wsprintf(&str[0],"MAI %i\0",anno);
iniday=121+bstile;endday=151+bstile;break;
case 6:wsprintf(&str[0],"JUIN %i\0",anno);
iniday=152+bstile;endday=181+bstile;break;
case 7:wsprintf(&str[0],"JUILLET %i\0",anno);
iniday=182+bstile;endday=212+bstile;break;
case 8:wsprintf(&str[0],"AOUT %i\0",anno);
iniday=213+bstile;endday=243+bstile;break;
case 9:wsprintf(&str[0],"SEPTEMBRE %i\0",anno);
iniday=244+bstile;endday=273+bstile;break;
case 10:wsprintf(&str[0],"OCTOBRE %i\0",anno);
iniday=274+bstile;endday=304+bstile;break;
case 11:wsprintf(&str[0],"NOVEMBRE %i\0",anno);
iniday=305+bstile;endday=334+bstile;break;
case 12:wsprintf(&str[0],"DECEMBRE %i\0",anno);
iniday=335+bstile;endday=365+bstile;break;
}//switch_mese
}//else_language
else if(xlanguage==3){
//German calendar
switch(jmese){
case 1:wsprintf(&str[0],"JANUAR %i\0",anno);
iniday=1;endday=31;break;
case 2:wsprintf(&str[0],"FEBRUAR %i\0",anno);
iniday=32;endday=59+bstile;break;
case 3:wsprintf(&str[0],"MARZ %i\0",anno);
iniday=60+bstile;endday=90+bstile;break;
case 4:wsprintf(&str[0],"APRIL %i\0",anno);
iniday=91+bstile;endday=120+bstile;break;
case 5:wsprintf(&str[0],"MAI %i\0",anno);
iniday=121+bstile;endday=151+bstile;break;
case 6:wsprintf(&str[0],"JUNI %i\0",anno);
iniday=152+bstile;endday=181+bstile;break;
case 7:wsprintf(&str[0],"JULI %i\0",anno);
iniday=182+bstile;endday=212+bstile;break;
case 8:wsprintf(&str[0],"AUGUST %i\0",anno);
iniday=213+bstile;endday=243+bstile;break;
case 9:wsprintf(&str[0],"SEPTEMBRE %i\0",anno);
iniday=244+bstile;endday=273+bstile;break;
case 10:wsprintf(&str[0],"OKTOBER %i\0",anno);
iniday=274+bstile;endday=304+bstile;break;
case 11:wsprintf(&str[0],"NOVEMBER %i\0",anno);
iniday=305+bstile;endday=334+bstile;break;
case 12:wsprintf(&str[0],"DEZEMBER %i\0",anno);
iniday=335+bstile;endday=365+bstile;break;
}//switch_mese
}else{
//Spanish calendar (not implemented)
}
//-------------------------------------------
fontsize=28.0;
pdfsetfont(pdf,fontsize);
wstr=cpdf_stringWidth(pdf,&str[0]);
hstr=cpdf_capHeight(pdf);
centerpos=(wpage-wstr)/2;
xstr=(wpage-wstr)/2;
ystr=y3+(y1-y3-hstr)/2;
if(xbannercolor!=0){
red=0.0;
green=0.0;
blue=0.0;
}else{
red=(float)GetRValue(ColorToRGB(mesecolor));red=red/255.0;
green=(float)GetGValue(ColorToRGB(mesecolor));green=green/255.0;
blue=(float)GetBValue(ColorToRGB(mesecolor));blue=blue/255.0;
}
cpdf_setrgbcolor(pdf,red,green,blue);
cpdf_rawText(pdf,xstr,ystr,0.0,&str[0]);
fontsize1=16.0;
pdfsetfont(pdf,fontsize1);
n_=0;
do{
riga[n_]='_';riga[n_+1]=0;
wstr=cpdf_stringWidth(pdf,&riga[0]);
n_=n_+1;
}while(wstr<wpage-x13-x1);
riga[n_-1]=0;
hh=hpage-mmtotpoint(62);
for(j=1;j<=nday;j=j+1){
if(xday[j].mese==jmese){
festflag=xday[j].festflag;
if(festflag!=0)cpdf_setrgbcolor(pdf,1.0,0.0,0.0);
else cpdf_setrgbcolor(pdf,0.0,0.0,0.0);
xastr=IntToStr(xday[j].mday);
wstr=cpdf_stringWidth(pdf,xastr.c_str());
centerpos=x5+(x7-x5-wstr)/2;
cpdf_rawText(pdf,centerpos,hh,0.0,xastr.c_str());
chstr[0]=xday[j].chday;chstr[1]=0;
xastr=&chstr[0];
wstr=cpdf_stringWidth(pdf,xastr.c_str());
centerpos=x7+(x9-x7-wstr)/2;
cpdf_rawText(pdf,centerpos,hh,0.0,xastr.c_str());
chstr[0]=xday[j].chmoon;chstr[1]=0;
xastr=&chstr[0];
wstr=cpdf_stringWidth(pdf,xastr.c_str());
centerpos=x9+(x11-x9-wstr)/2;
cpdf_rawText(pdf,centerpos,hh,0.0,xastr.c_str());
xastr=&xday[j].nameday[0];
cpdf_rawText(pdf,x11+margine,hh,0.0,xastr.c_str());
wstr=cpdf_stringWidth(pdf,&riga[0]);
centerpos=x13+(x6-x13-wstr)/2;
cpdf_rawText(pdf,centerpos,hh,0.0,&riga[0]);
hh=hh-mmtotpoint(7.5);
}//if_day[j].mese
}//for_j
cpdf_endText(pdf);
cpdf_finalizePage(pdf,jmese);
}
//--------------------------------------------------------------------------
float Almanac::mmtotpoint(float mm){
float tippoint;
tippoint=72.0*mm/25.4;
return tippoint;
}
//--------------------------------------------------------------------------
void Almanac::setweekdaynames(int bstile){
int j,wday,bs;
bs=bstile;
switch(xlanguage){
case 0:
//Italian calendar
for(j=1;j<=365+bs;j=j+1){
wday=xday[j].wday;
switch(wday){
case 1:StrCopy(&xday[j].nameday[0],"Lunedì");break;
case 2:StrCopy(&xday[j].nameday[0],"Martedì");break;
case 3:StrCopy(&xday[j].nameday[0],"Mercoledì");break;
case 4:StrCopy(&xday[j].nameday[0],"Giovedì");break;
case 5:StrCopy(&xday[j].nameday[0],"Venerdì");break;
case 6:StrCopy(&xday[j].nameday[0],"Sabato");break;
case 7:StrCopy(&xday[j].nameday[0],"Domenica");break;
}//switch_wday
}//for_j
break;
case 1:
//English calendar
for(j=1;j<=365+bs;j=j+1){
wday=xday[j].wday;
switch(wday){
case 1:StrCopy(&xday[j].nameday[0],"Monday");break;
case 2:StrCopy(&xday[j].nameday[0],"Tuesday");break;
case 3:StrCopy(&xday[j].nameday[0],"Wednesday");break;
case 4:StrCopy(&xday[j].nameday[0],"Thursday");break;
case 5:StrCopy(&xday[j].nameday[0],"Freeday");break;
case 6:StrCopy(&xday[j].nameday[0],"Saturday");break;
case 7:StrCopy(&xday[j].nameday[0],"Sunday");break;
}//switch_wday
}//for_j
break;
case 2:
//French calendar
for(j=1;j<=365+bs;j=j+1){
wday=xday[j].wday;
switch(wday){
case 1:StrCopy(&xday[j].nameday[0],"Lundi");break;
case 2:StrCopy(&xday[j].nameday[0],"Mardi");break;
case 3:StrCopy(&xday[j].nameday[0],"Mercredi");break;
case 4:StrCopy(&xday[j].nameday[0],"Jeudi");break;
case 5:StrCopy(&xday[j].nameday[0],"Vendredi");break;
case 6:StrCopy(&xday[j].nameday[0],"Samedi");break;
case 7:StrCopy(&xday[j].nameday[0],"Dimanche");break;
}//switch_wday
}//for_j
break;
case 3:
//German calendar
for(j=1;j<=365+bs;j=j+1){
wday=xday[j].wday;
switch(wday){
case 1:StrCopy(&xday[j].nameday[0],"Montag");break;
case 2:StrCopy(&xday[j].nameday[0],"Dienstag");break;
case 3:StrCopy(&xday[j].nameday[0],"Mittwoch");break;
case 4:StrCopy(&xday[j].nameday[0],"Donnerstag");break;
case 5:StrCopy(&xday[j].nameday[0],"Freitag");break;
case 6:StrCopy(&xday[j].nameday[0],"Samstag");break;
case 7:StrCopy(&xday[j].nameday[0],"Sonntag");break;
}//switch_wday
}//for_j
break;
case 4:
//Spanish calendar (not implemented)
break;
default:
break;
}//switch
}
//--------------------------------------------------------------------------
void Almanac::pdfsetfont(CPDFdoc *pdf,int fontsize){
//Set the calendar font
if(bold==0){
if(xfont==0)cpdf_setFont(pdf,"AvantGarde-Book","WinAnsiEncoding",fontsize);
else if(xfont==1)cpdf_setFont(pdf,"Bookman-Light","WinAnsiEncoding",fontsize);
else if(xfont==2)cpdf_setFont(pdf,"Courier","WinAnsiEncoding",fontsize);
else if(xfont==3)cpdf_setFont(pdf,"Helvetica","WinAnsiEncoding",fontsize);
else if(xfont==4)cpdf_setFont(pdf,"Helvetica-Condensed","WinAnsiEncoding",fontsize);
else if(xfont==5)cpdf_setFont(pdf,"Helvetica-Narrow","WinAnsiEncoding",fontsize);
else if(xfont==6)cpdf_setFont(pdf,"Palatino-Roman","WinAnsiEncoding",fontsize);
else if(xfont==7)cpdf_setFont(pdf,"Times-Roman","WinAnsiEncoding",fontsize);
else ShowMessage("Caso non previsto");
}else{
if(xfont==0)cpdf_setFont(pdf,"AvantGarde-Demi","WinAnsiEncoding",fontsize);
else if(xfont==1)cpdf_setFont(pdf,"Bookman-Demi","WinAnsiEncoding",fontsize);
else if(xfont==2)cpdf_setFont(pdf,"Courier-Bold","WinAnsiEncoding",fontsize);
else if(xfont==3)cpdf_setFont(pdf,"Helvetica-Bold","WinAnsiEncoding",fontsize);
else if(xfont==4)cpdf_setFont(pdf,"Helvetica-Condensed-Bold","WinAnsiEncoding",fontsize);
else if(xfont==5)cpdf_setFont(pdf,"Helvetica-Narrow-Bold","WinAnsiEncoding",fontsize);
else if(xfont==6)cpdf_setFont(pdf,"Palatino-Bold","WinAnsiEncoding",fontsize);
else if(xfont==1)cpdf_setFont(pdf,"Times-Bold","WinAnsiEncoding",fontsize);
else ShowMessage("Caso non previsto");
}
}
//--------------------------------------------------------------------------
void Almanac::goboxpdfalmanac(AnsiString astrdir){
char *pch,ch2[2];
CPDFdoc *pdf;
AnsiString astr;
int j;
pch=AnsiLastChar(astrdir);
if(*pch=='\\'){}else {ch2[0]='\\';ch2[1]=0;astrdir=astrdir+&ch2[0];}
pdf=cpdf_open(0,NULL);
cpdf_enableCompression(pdf,YES);
cpdf_init(pdf);
for(j=1;j<=12;j=j+1){makeboxpdfpage(pdf,j);}
cpdf_finalizeAll(pdf);
if(xfont==0){astr=astrdir+"Almanac"+IntToStr(anno)+"ag.pdf";}
else if(xfont==1){astr=astrdir+"Almanac"+IntToStr(anno)+"bm.pdf";}
else if(xfont==2){astr=astrdir+"Almanac"+IntToStr(anno)+"co.pdf";}
else if(xfont==3){astr=astrdir+"Almanac"+IntToStr(anno)+"he.pdf";}
else if(xfont==4){astr=astrdir+"Almanac"+IntToStr(anno)+"hc.pdf";}
else if(xfont==5){astr=astrdir+"Almanac"+IntToStr(anno)+"hn.pdf";}
else if(xfont==6){astr=astrdir+"Almanac"+IntToStr(anno)+"pa.pdf";}
else if(xfont==7){astr=astrdir+"Almanac"+IntToStr(anno)+"ti.pdf";}
else ShowMessage("Caso non previsto");
cpdf_savePDFmemoryStreamToFile(pdf,astr.c_str());
cpdf_close(pdf);
}
//--------------------------------------------------------------------------
void Almanac::gopdfalmanac(AnsiString astrdir){
char *pch,ch2[2];
CPDFdoc *pdf;
AnsiString astr;
int j;
pch=AnsiLastChar(astrdir);
if(*pch=='\\'){}else {ch2[0]='\\';ch2[1]=0;astrdir=astrdir+&ch2[0];}
pdf=cpdf_open(0,NULL);
cpdf_enableCompression(pdf,YES);
cpdf_init(pdf);
for(j=1;j<=12;j=j+1){makepdfpage(pdf,j);}
cpdf_finalizeAll(pdf);
if(xfont==0){astr=astrdir+"_Almanac"+IntToStr(anno)+"ag.pdf";}
else if(xfont==1){astr=astrdir+"_Almanac"+IntToStr(anno)+"bm.pdf";}
else if(xfont==2){astr=astrdir+"_Almanac"+IntToStr(anno)+"co.pdf";}
else if(xfont==3){astr=astrdir+"_Almanac"+IntToStr(anno)+"he.pdf";}
else if(xfont==4){astr=astrdir+"_Almanac"+IntToStr(anno)+"hc.pdf";}
else if(xfont==5){astr=astrdir+"_Almanac"+IntToStr(anno)+"hn.pdf";}
else if(xfont==6){astr=astrdir+"_Almanac"+IntToStr(anno)+"pa.pdf";}
else if(xfont==7){astr=astrdir+"_Almanac"+IntToStr(anno)+"ti.pdf";}
else ShowMessage("Caso non previsto");
cpdf_savePDFmemoryStreamToFile(pdf,astr.c_str());
cpdf_close(pdf);
}
//--------------------------------------------------------------------------
|