Index: pykota/trunk/pykota/version.py
===================================================================
--- pykota/trunk/pykota/version.py (revision 2659)
+++ pykota/trunk/pykota/version.py (revision 2668)
@@ -22,5 +22,5 @@
 #
 
-__version__ = "1.24alpha10_unofficial"
+__version__ = "1.24alpha11_unofficial"
 
 __doc__ = "PyKota : a complete Printing Quota Solution for CUPS."
Index: pykota/trunk/bin/pkinvoice
===================================================================
--- pykota/trunk/bin/pkinvoice (revision 2666)
+++ pykota/trunk/bin/pkinvoice (revision 2668)
@@ -28,4 +28,5 @@
 import os
 import pwd
+import time
 import cStringIO
 
@@ -134,8 +135,22 @@
                 pass
                 
-    def pagePDF(self, invoicenumber, entry, vat, start, end) :
+    def printVar(self, label, value, size) :
+        """Outputs a variable onto the PDF canvas.
+        
+           Returns the number of points to substract to current Y coordinate.
+        """   
+        xcenter = (self.pagesize[0] / 2.0) - 1*cm
+        self.canvas.saveState()
+        self.canvas.setFont("Helvetica-Bold", size)
+        self.canvas.setFillColorRGB(0, 0, 0)
+        self.canvas.drawRightString(xcenter, self.ypos, "%s :" % label)
+        self.canvas.setFont("Courier-Bold", size)
+        self.canvas.setFillColorRGB(0, 0, 1)
+        self.canvas.drawString(xcenter + 0.5*cm, self.ypos, value)
+        self.canvas.restoreState()
+        self.ypos -= (size + 4)
+        
+    def pagePDF(self, invoicenumber, entry, vat, start, end, unitname) :
         """Generates a new page in the PDF document."""
-        self.canvas.doForm("background")
-        
         extractonly = { "username" : entry.Name }
         if start :
@@ -147,4 +162,6 @@
         vatamount = 0.0
         if records :
+            self.canvas.doForm("background")
+            self.ypos = self.yorigine - (cm + 20)
             records = self.summarizeDatas(records, "history", extractonly, True)
             fieldnames = records[0]
@@ -159,7 +176,24 @@
                 ht = ((amount * 10000.0) / (100.0 + vat)) / 100.0
                 vatamount = amount - ht
-            sys.stderr.write("#%06i    %s     %s    %s    %.2f    %.2f\n" % (invoicenumber, entry.Name, numberofpages, numberofbytes, amount, vatamount))
-        
-        self.canvas.showPage()
+            self.printVar(_("Invoice"), "#%s" % invoicenumber, 22)
+            self.printVar(_("Username"), entry.Name, 22)
+            self.ypos -= 20
+            if start : 
+                self.printVar(_("Since"), start, 14)
+            if end :
+                self.printVar(_("Until"), end, 14)
+            self.printVar(_("Edited on"), time.strftime("%c", time.localtime()), 14)
+                
+            self.ypos -= 20
+            self.printVar(_("Number of bytes"), str(numberofbytes), 14)
+            self.printVar(_("Number of pages"), str(numberofpages), 14)
+            self.ypos -= 20
+            self.printVar(_("Amount due"), "%.2f %s" % (amount, unitname), 22)
+            if vat :
+                self.ypos += 8
+                self.printVar("%s (%.2f%%)" % (_("Included VAT"), vat), "%.2f %s" % (vatamount, unitname), 14)
+            self.canvas.showPage()
+            return 1
+        return 0    
         
     def initPDF(self, logo) :
@@ -172,14 +206,13 @@
         c.setAuthor(pwd.getpwuid(os.geteuid())[0])
         c.setTitle("PyKota invoices")
-        c.setSubject("This is an invoice generated with PyKota")
-        
-        xcenter = self.pagesize[0] / 2.0
-        ycenter = self.pagesize[1] / 2.0
-                    
-        ypos = self.pagesize[1] - (2 * cm)            
+        c.setSubject("Invoices generated with PyKota")
+        
         
         self.canvas.beginForm("background")
         self.canvas.saveState()
         
+        self.ypos = self.pagesize[1] - (2 * cm)            
+        
+        xcenter = self.pagesize[0] / 2.0
         if logo :
             try :    
@@ -192,12 +225,15 @@
                 width = float(width) / multi
                 height = float(height) / multi
-                xpos = xcenter - (width / 2.0)
-                ypos -= height
-                c.drawImage(logo, xpos, ypos, width, height)
-        
-        # New top
-        xpos = self.pagesize[0] / 5.0
-        ypos -= (1 * cm) + 20
-        
+                self.ypos -= height
+                c.drawImage(logo, xcenter - (width / 2.0), \
+                                  self.ypos, \
+                                  width, height)
+        
+        self.ypos -= (cm + 20)
+        self.canvas.setFont("Helvetica-Bold", 14)
+        self.canvas.setFillColorRGB(0, 0, 0)
+        self.canvas.drawCentredString(xcenter, self.ypos, "%s :" % _("Here's the invoice for your printouts"))
+        
+        self.yorigine = self.ypos
         self.canvas.restoreState()
         self.canvas.endForm()
@@ -232,5 +268,5 @@
             
         try :    
-            number = float(options["number"])
+            firstnumber = number = int(options["number"])
             if number <= 0 :
                 raise ValueError
@@ -256,11 +292,11 @@
             for i in range(nbtotal) :
                 entry = entries[i]
-                self.pagePDF(number, entry, vat, options["start"], options["end"])
-                number += 1
+                number += self.pagePDF(number, entry, vat, options["start"], options["end"], options["unit"])
                 if outfname != "-" :
                     percent = 100.0 * float(i) / float(nbtotal)
                     self.display("\r%.02f%%" % percent)
                     
-            self.endPDF(outfname)
+            if number > firstnumber :
+                self.endPDF(outfname)
             
         if outfname != "-" :
Index: pykota/trunk/NEWS
===================================================================
--- pykota/trunk/NEWS (revision 2659)
+++ pykota/trunk/NEWS (revision 2668)
@@ -22,4 +22,9 @@
 PyKota NEWS :
        
+    - 1.24alpha11 :
+    
+        - The pkinvoice invoice generator command line utility is now
+          included.
+          
     - 1.24alpha10 :   
     
