diff --git a/sc/sc2100.cpp b/sc/sc2100.cpp
index 01ceb2fea..63c0fc1c0 100755
--- a/sc/sc2100.cpp
+++ b/sc/sc2100.cpp
@@ -45,6 +45,7 @@ class TEC_form : public TForm
   int _fincatura;              // 0 = nessuna, 1 = testo, 2 = grafica
   word _num_rip;               // Numero di righe usate per i riporti
   word _total_rows;            // Numero di righe usate per i totali
+  word _maxtot;                // Numero massimo di totali da stampare       
 
 protected:
   void init_header(const TMask& m);
@@ -841,12 +842,8 @@ void TEC_form::stampa_pedata(TPrinter& pr)
   THash_object* tot[MAXTOT];
   word num_rip = ordina_totali_per_valuta(tot);
   
-  // La prima riga del footer deve essere lasciata libera per la fincatura
-  // Ogni sottosezione di totale occupa _total_rows righe: per cui devo calcolare
-  // quanti totali ci stanno nelle righe riservate al footer
-  const word maxtot = (section('F').height()-1) / _total_rows;
-  if (num_rip > maxtot)
-    num_rip = maxtot;
+  if (num_rip > _maxtot)
+    num_rip = _maxtot;
   
   for (word j = 0; j < num_rip; j++)
     print_total(j*_total_rows+1, *tot[j]);
@@ -1013,17 +1010,26 @@ TEC_form::TEC_form(const TEC_mask& m, bool gesval)
   pr.setheaderhandler(ec_header_handler);
   TPrint_section& head = section('H');
   pr.headerlen(head.height());
+  
+  pr.setfooterhandler(ec_footer_handler);
+  const TPrint_section& foot = section('F');
+  pr.footerlen(foot.height());
 
   TForm_item& flags = find_field('H', last_page, PEC_FLAGS);
   TToken_string f(flags.prompt());
   _in_valuta = gesval && f.get_char(0) == 'X';     // Il profilo e' in valuta se c'e' il flag di valuta
   _fincatura = f.get_int(1);
-  init_header(m);  // Set fixed text
-   
-  pr.setfooterhandler(ec_footer_handler);
-  const TPrint_section& foot = section('F');
-  pr.footerlen(foot.height());
   
+  if (_fincatura > 0)
+  {                                      
+    const int first   = head.height()-2;
+    const int last    = pr.formlen();
+    const int horiz[] = { first+2, last-foot.height()+1, 0 };
+    genera_fincatura(odd_page, first, last, horiz);
+  }
+  
+  init_header(m);  // Set fixed text
+       
   _total_rows = 1;
   for (word fi = 0; fi < foot.fields(); fi++)
   {
@@ -1035,6 +1041,15 @@ TEC_form::TEC_form(const TEC_mask& m, bool gesval)
         _total_rows = y;
     }  
   }
+
+  _maxtot = f.get_int(3);
+
+  // La prima e l'ultima riga del footer devono essere lasciate libere per la fincatura
+  // Ogni totale occupa _total_rows righe: per cui posso calcolare il massimo di totali
+  // che posso stampare nel footer.
+  const word max = (foot.height() - 2) / _total_rows;
+  if (_maxtot <= 0 || _maxtot > max)
+    _maxtot = max;  
 }
 
 TEC_form::~TEC_form()
diff --git a/sc/sc2401.h b/sc/sc2401.h
index 9e8ba4cd3..cfd0e6ea2 100755
--- a/sc/sc2401.h
+++ b/sc/sc2401.h
@@ -127,7 +127,7 @@ class TESSL_form : public TForm
   int _fincatura;              // 0 = nessuna, 1 = testo, 2 = grafica
   word _num_rip;               // numero di righe usate per i riporti
   word _total_rows;            // numero di righe usate per i totali
-  int      _maxtot;              // numero massimo di totali
+  word _maxtot;                // numero massimo di totali
   char _who;
 
 protected: