Class: FPDF

Inherits:
Object
  • Object
show all
Includes:
RFPDF
Defined in:
lib/plugins/rfpdf/lib/rfpdf/fpdf.rb

Constant Summary

FPDF_VERSION =
'1.53d'
Charwidths =
{
    'courier'=>[600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600],
    
    'courierB'=>[600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600],
    
    'courierI'=>[600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600],
    
    'courierBI'=>[600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600],
    
    'helvetica'=>[278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 355, 556, 556, 889, 667, 191, 333, 333, 389, 584, 278, 333, 278, 278, 556, 556, 556, 556, 556, 556, 556, 556, 556, 556, 278, 278, 584, 584, 584, 556, 1015, 667, 667, 722, 722, 667, 611, 778, 722, 278, 500, 667, 556, 833, 722, 778, 667, 778, 722, 667, 611, 722, 667, 944, 667, 667, 611, 278, 278, 278, 469, 556, 333, 556, 556, 500, 556, 556, 278, 556, 556, 222, 222, 500, 222, 833, 556, 556, 556, 556, 333, 500, 278, 556, 500, 722, 500, 500, 500, 334, 260, 334, 584, 350, 556, 350, 222, 556, 333, 1000, 556, 556, 333, 1000, 667, 333, 1000, 350, 611, 350, 350, 222, 222, 333, 333, 350, 556, 1000, 333, 1000, 500, 333, 944, 350, 500, 667, 278, 333, 556, 556, 556, 556, 260, 556, 333, 737, 370, 556, 584, 333, 737, 333, 400, 584, 333, 333, 333, 556, 537, 278, 333, 333, 365, 556, 834, 834, 834, 611, 667, 667, 667, 667, 667, 667, 1000, 722, 667, 667, 667, 667, 278, 278, 278, 278, 722, 722, 778, 778, 778, 778, 778, 584, 778, 722, 722, 722, 722, 667, 667, 611, 556, 556, 556, 556, 556, 556, 889, 500, 556, 556, 556, 556, 278, 278, 278, 278, 556, 556, 556, 556, 556, 556, 556, 584, 611, 556, 556, 556, 556, 500, 556, 500],
    
    'helveticaB'=>[278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 333, 474, 556, 556, 889, 722, 238, 333, 333, 389, 584, 278, 333, 278, 278, 556, 556, 556, 556, 556, 556, 556, 556, 556, 556, 333, 333, 584, 584, 584, 611, 975, 722, 722, 722, 722, 667, 611, 778, 722, 278, 556, 722, 611, 833, 722, 778, 667, 778, 722, 667, 611, 722, 667, 944, 667, 667, 611, 333, 278, 333, 584, 556, 333, 556, 611, 556, 611, 556, 333, 611, 611, 278, 278, 556, 278, 889, 611, 611, 611, 611, 389, 556, 333, 611, 556, 778, 556, 556, 500, 389, 280, 389, 584, 350, 556, 350, 278, 556, 500, 1000, 556, 556, 333, 1000, 667, 333, 1000, 350, 611, 350, 350, 278, 278, 500, 500, 350, 556, 1000, 333, 1000, 556, 333, 944, 350, 500, 667, 278, 333, 556, 556, 556, 556, 280, 556, 333, 737, 370, 556, 584, 333, 737, 333, 400, 584, 333, 333, 333, 611, 556, 278, 333, 333, 365, 556, 834, 834, 834, 611, 722, 722, 722, 722, 722, 722, 1000, 722, 667, 667, 667, 667, 278, 278, 278, 278, 722, 722, 778, 778, 778, 778, 778, 584, 778, 722, 722, 722, 722, 667, 667, 611, 556, 556, 556, 556, 556, 556, 889, 556, 556, 556, 556, 556, 278, 278, 278, 278, 611, 611, 611, 611, 611, 611, 611, 584, 611, 611, 611, 611, 611, 556, 611, 556],
    
    'helveticaI'=>[278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 355, 556, 556, 889, 667, 191, 333, 333, 389, 584, 278, 333, 278, 278, 556, 556, 556, 556, 556, 556, 556, 556, 556, 556, 278, 278, 584, 584, 584, 556, 1015, 667, 667, 722, 722, 667, 611, 778, 722, 278, 500, 667, 556, 833, 722, 778, 667, 778, 722, 667, 611, 722, 667, 944, 667, 667, 611, 278, 278, 278, 469, 556, 333, 556, 556, 500, 556, 556, 278, 556, 556, 222, 222, 500, 222, 833, 556, 556, 556, 556, 333, 500, 278, 556, 500, 722, 500, 500, 500, 334, 260, 334, 584, 350, 556, 350, 222, 556, 333, 1000, 556, 556, 333, 1000, 667, 333, 1000, 350, 611, 350, 350, 222, 222, 333, 333, 350, 556, 1000, 333, 1000, 500, 333, 944, 350, 500, 667, 278, 333, 556, 556, 556, 556, 260, 556, 333, 737, 370, 556, 584, 333, 737, 333, 400, 584, 333, 333, 333, 556, 537, 278, 333, 333, 365, 556, 834, 834, 834, 611, 667, 667, 667, 667, 667, 667, 1000, 722, 667, 667, 667, 667, 278, 278, 278, 278, 722, 722, 778, 778, 778, 778, 778, 584, 778, 722, 722, 722, 722, 667, 667, 611, 556, 556, 556, 556, 556, 556, 889, 500, 556, 556, 556, 556, 278, 278, 278, 278, 556, 556, 556, 556, 556, 556, 556, 584, 611, 556, 556, 556, 556, 500, 556, 500],
    
    'helveticaBI'=>[278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 333, 474, 556, 556, 889, 722, 238, 333, 333, 389, 584, 278, 333, 278, 278, 556, 556, 556, 556, 556, 556, 556, 556, 556, 556, 333, 333, 584, 584, 584, 611, 975, 722, 722, 722, 722, 667, 611, 778, 722, 278, 556, 722, 611, 833, 722, 778, 667, 778, 722, 667, 611, 722, 667, 944, 667, 667, 611, 333, 278, 333, 584, 556, 333, 556, 611, 556, 611, 556, 333, 611, 611, 278, 278, 556, 278, 889, 611, 611, 611, 611, 389, 556, 333, 611, 556, 778, 556, 556, 500, 389, 280, 389, 584, 350, 556, 350, 278, 556, 500, 1000, 556, 556, 333, 1000, 667, 333, 1000, 350, 611, 350, 350, 278, 278, 500, 500, 350, 556, 1000, 333, 1000, 556, 333, 944, 350, 500, 667, 278, 333, 556, 556, 556, 556, 280, 556, 333, 737, 370, 556, 584, 333, 737, 333, 400, 584, 333, 333, 333, 611, 556, 278, 333, 333, 365, 556, 834, 834, 834, 611, 722, 722, 722, 722, 722, 722, 1000, 722, 667, 667, 667, 667, 278, 278, 278, 278, 722, 722, 778, 778, 778, 778, 778, 584, 778, 722, 722, 722, 722, 667, 667, 611, 556, 556, 556, 556, 556, 556, 889, 556, 556, 556, 556, 556, 278, 278, 278, 278, 611, 611, 611, 611, 611, 611, 611, 584, 611, 611, 611, 611, 611, 556, 611, 556],
    
    'times'=>[250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 333, 408, 500, 500, 833, 778, 180, 333, 333, 500, 564, 250, 333, 250, 278, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 278, 278, 564, 564, 564, 444, 921, 722, 667, 667, 722, 611, 556, 722, 722, 333, 389, 722, 611, 889, 722, 722, 556, 722, 667, 556, 611, 722, 722, 944, 722, 722, 611, 333, 278, 333, 469, 500, 333, 444, 500, 444, 500, 444, 333, 500, 500, 278, 278, 500, 278, 778, 500, 500, 500, 500, 333, 389, 278, 500, 500, 722, 500, 500, 444, 480, 200, 480, 541, 350, 500, 350, 333, 500, 444, 1000, 500, 500, 333, 1000, 556, 333, 889, 350, 611, 350, 350, 333, 333, 444, 444, 350, 500, 1000, 333, 980, 389, 333, 722, 350, 444, 722, 250, 333, 500, 500, 500, 500, 200, 500, 333, 760, 276, 500, 564, 333, 760, 333, 400, 564, 300, 300, 333, 500, 453, 250, 333, 300, 310, 500, 750, 750, 750, 444, 722, 722, 722, 722, 722, 722, 889, 667, 611, 611, 611, 611, 333, 333, 333, 333, 722, 722, 722, 722, 722, 722, 722, 564, 722, 722, 722, 722, 722, 722, 556, 500, 444, 444, 444, 444, 444, 444, 667, 444, 444, 444, 444, 444, 278, 278, 278, 278, 500, 500, 500, 500, 500, 500, 500, 564, 500, 500, 500, 500, 500, 500, 500, 500],
    
    'timesB'=>[250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 333, 555, 500, 500, 1000, 833, 278, 333, 333, 500, 570, 250, 333, 250, 278, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 333, 333, 570, 570, 570, 500, 930, 722, 667, 722, 722, 667, 611, 778, 778, 389, 500, 778, 667, 944, 722, 778, 611, 778, 722, 556, 667, 722, 722, 1000, 722, 722, 667, 333, 278, 333, 581, 500, 333, 500, 556, 444, 556, 444, 333, 500, 556, 278, 333, 556, 278, 833, 556, 500, 556, 556, 444, 389, 333, 556, 500, 722, 500, 500, 444, 394, 220, 394, 520, 350, 500, 350, 333, 500, 500, 1000, 500, 500, 333, 1000, 556, 333, 1000, 350, 667, 350, 350, 333, 333, 500, 500, 350, 500, 1000, 333, 1000, 389, 333, 722, 350, 444, 722, 250, 333, 500, 500, 500, 500, 220, 500, 333, 747, 300, 500, 570, 333, 747, 333, 400, 570, 300, 300, 333, 556, 540, 250, 333, 300, 330, 500, 750, 750, 750, 500, 722, 722, 722, 722, 722, 722, 1000, 722, 667, 667, 667, 667, 389, 389, 389, 389, 722, 722, 778, 778, 778, 778, 778, 570, 778, 722, 722, 722, 722, 722, 611, 556, 500, 500, 500, 500, 500, 500, 722, 444, 444, 444, 444, 444, 278, 278, 278, 278, 500, 556, 500, 500, 500, 500, 500, 570, 500, 556, 556, 556, 556, 500, 556, 500],
    
    'timesI'=>[250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 333, 420, 500, 500, 833, 778, 214, 333, 333, 500, 675, 250, 333, 250, 278, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 333, 333, 675, 675, 675, 500, 920, 611, 611, 667, 722, 611, 611, 722, 722, 333, 444, 667, 556, 833, 667, 722, 611, 722, 611, 500, 556, 722, 611, 833, 611, 556, 556, 389, 278, 389, 422, 500, 333, 500, 500, 444, 500, 444, 278, 500, 500, 278, 278, 444, 278, 722, 500, 500, 500, 500, 389, 389, 278, 500, 444, 667, 444, 444, 389, 400, 275, 400, 541, 350, 500, 350, 333, 500, 556, 889, 500, 500, 333, 1000, 500, 333, 944, 350, 556, 350, 350, 333, 333, 556, 556, 350, 500, 889, 333, 980, 389, 333, 667, 350, 389, 556, 250, 389, 500, 500, 500, 500, 275, 500, 333, 760, 276, 500, 675, 333, 760, 333, 400, 675, 300, 300, 333, 500, 523, 250, 333, 300, 310, 500, 750, 750, 750, 500, 611, 611, 611, 611, 611, 611, 889, 667, 611, 611, 611, 611, 333, 333, 333, 333, 722, 667, 722, 722, 722, 722, 722, 675, 722, 722, 722, 722, 722, 556, 611, 500, 500, 500, 500, 500, 500, 500, 667, 444, 444, 444, 444, 444, 278, 278, 278, 278, 500, 500, 500, 500, 500, 500, 500, 675, 500, 500, 500, 500, 500, 444, 500, 444],
    
    'timesBI'=>[250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 389, 555, 500, 500, 833, 778, 278, 333, 333, 500, 570, 250, 333, 250, 278, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 333, 333, 570, 570, 570, 500, 832, 667, 667, 667, 722, 667, 667, 722, 778, 389, 500, 667, 611, 889, 722, 722, 611, 722, 667, 556, 611, 722, 667, 889, 667, 611, 611, 333, 278, 333, 570, 500, 333, 500, 500, 444, 500, 444, 333, 500, 556, 278, 278, 500, 278, 778, 556, 500, 500, 500, 389, 389, 278, 556, 444, 667, 500, 444, 389, 348, 220, 348, 570, 350, 500, 350, 333, 500, 500, 1000, 500, 500, 333, 1000, 556, 333, 944, 350, 611, 350, 350, 333, 333, 500, 500, 350, 500, 1000, 333, 1000, 389, 333, 722, 350, 389, 611, 250, 389, 500, 500, 500, 500, 220, 500, 333, 747, 266, 500, 606, 333, 747, 333, 400, 570, 300, 300, 333, 576, 500, 250, 333, 300, 300, 500, 750, 750, 750, 500, 667, 667, 667, 667, 667, 667, 944, 667, 667, 667, 667, 667, 389, 389, 389, 389, 722, 722, 722, 722, 722, 722, 722, 570, 722, 722, 722, 722, 722, 611, 611, 500, 500, 500, 500, 500, 500, 500, 722, 444, 444, 444, 444, 444, 278, 278, 278, 278, 500, 556, 500, 500, 500, 500, 500, 570, 500, 556, 556, 556, 556, 444, 500, 444],
    
    'symbol'=>[250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 333, 713, 500, 549, 833, 778, 439, 333, 333, 500, 549, 250, 549, 250, 278, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 278, 278, 549, 549, 549, 444, 549, 722, 667, 722, 612, 611, 763, 603, 722, 333, 631, 722, 686, 889, 722, 722, 768, 741, 556, 592, 611, 690, 439, 768, 645, 795, 611, 333, 863, 333, 658, 500, 500, 631, 549, 549, 494, 439, 521, 411, 603, 329, 603, 549, 549, 576, 521, 549, 549, 521, 549, 603, 439, 576, 713, 686, 493, 686, 494, 480, 200, 480, 549, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 750, 620, 247, 549, 167, 713, 500, 753, 753, 753, 753, 1042, 987, 603, 987, 603, 400, 549, 411, 549, 549, 713, 494, 460, 549, 549, 549, 549, 1000, 603, 1000, 658, 823, 686, 795, 987, 768, 768, 823, 768, 768, 713, 713, 713, 713, 713, 713, 713, 768, 713, 790, 790, 890, 823, 549, 250, 713, 603, 603, 1042, 987, 603, 987, 603, 494, 329, 790, 790, 786, 713, 384, 384, 384, 384, 384, 384, 494, 494, 494, 494, 0, 329, 274, 686, 686, 686, 384, 384, 384, 384, 384, 384, 494, 494, 494, 0],
    
    'zapfdingbats'=>[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 278, 974, 961, 974, 980, 719, 789, 790, 791, 690, 960, 939, 549, 855, 911, 933, 911, 945, 974, 755, 846, 762, 761, 571, 677, 763, 760, 759, 754, 494, 552, 537, 577, 692, 786, 788, 788, 790, 793, 794, 816, 823, 789, 841, 823, 833, 816, 831, 923, 744, 723, 749, 790, 792, 695, 776, 768, 792, 759, 707, 708, 682, 701, 826, 815, 789, 789, 707, 687, 696, 689, 786, 787, 713, 791, 785, 791, 873, 761, 762, 762, 759, 759, 892, 892, 788, 784, 438, 138, 277, 415, 392, 392, 668, 668, 0, 390, 390, 317, 317, 276, 276, 509, 509, 410, 410, 234, 234, 334, 334, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 732, 544, 544, 910, 667, 760, 760, 776, 595, 694, 626, 788, 788, 788, 788, 788, 788, 788, 788, 788, 788, 788, 788, 788, 788, 788, 788, 788, 788, 788, 788, 788, 788, 788, 788, 788, 788, 788, 788, 788, 788, 788, 788, 788, 788, 788, 788, 788, 788, 788, 788, 894, 838, 1016, 458, 748, 924, 748, 918, 927, 928, 928, 834, 873, 828, 924, 924, 917, 930, 931, 463, 883, 836, 836, 867, 867, 696, 696, 874, 0, 874, 760, 946, 771, 865, 771, 888, 967, 888, 831, 873, 927, 970, 918, 0]
}

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Methods included from RFPDF

#getimagesize

Constructor Details

- (FPDF) initialize(orientation = 'P', unit = 'mm', format = 'A4')

Returns a new instance of FPDF



63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
# File 'lib/plugins/rfpdf/lib/rfpdf/fpdf.rb', line 63

def initialize(orientation='P', unit='mm', format='A4')
    # Initialization of properties
    @page=0
    @n=2
    @buffer=''
    @pages=[]
    @OrientationChanges=[]
    @state=0
    @default_font = "arial"
    @fonts={}
    @FontFiles={}
    @diffs=[]
    @images={}
    @links=[]
    @PageLinks={}
    @InFooter=false
    @FontFamily=''
    @FontStyle=''
    @FontSizePt=12
    @underline= false
    @DrawColor='0 G'
    @FillColor='0 g'
    @TextColor='0 g'
    @ColorFlag=false
    @ws=0
    @offsets=[]

    # Standard fonts
    @CoreFonts={}
    @CoreFonts['courier']='Courier'
    @CoreFonts['courierB']='Courier-Bold'
    @CoreFonts['courierI']='Courier-Oblique'
    @CoreFonts['courierBI']='Courier-BoldOblique'
    @CoreFonts['helvetica']='Helvetica'
    @CoreFonts['helveticaB']='Helvetica-Bold'
    @CoreFonts['helveticaI']='Helvetica-Oblique'
    @CoreFonts['helveticaBI']='Helvetica-BoldOblique'
    @CoreFonts['times']='Times-Roman'
    @CoreFonts['timesB']='Times-Bold'
    @CoreFonts['timesI']='Times-Italic'
    @CoreFonts['timesBI']='Times-BoldItalic'
    @CoreFonts['symbol']='Symbol'
    @CoreFonts['zapfdingbats']='ZapfDingbats'

    # Scale factor
    if unit=='pt'
        @k=1
    elsif unit=='mm'
        @k=72/25.4
    elsif unit=='cm'
        @k=72/2.54;
    elsif unit=='in'
        @k=72
    else
        raise 'Incorrect unit: '+unit
    end

    # Page format
    if format.is_a? String
        format.downcase!
        if format=='a3'
            format=[841.89,1190.55]
        elsif format=='a4'
            format=[595.28,841.89]
        elsif format=='a5'
            format=[420.94,595.28]
        elsif format=='letter'
            format=[612,792]
        elsif format=='legal'
            format=[612,1008]
        else
            raise 'Unknown page format: '+format
        end
        @fwPt,@fhPt=format
    else
        @fwPt=format[0]*@k
        @fhPt=format[1]*@k
    end
    @fw=@fwPt/@k;
    @fh=@fhPt/@k;

    # Page orientation
    orientation.downcase!
    if orientation=='p' or orientation=='portrait'
        @DefOrientation='P'
        @wPt=@fwPt
        @hPt=@fhPt
    elsif orientation=='l' or orientation=='landscape'
        @DefOrientation='L'
        @wPt=@fhPt
        @hPt=@fwPt
    else
        raise 'Incorrect orientation: '+orientation
    end
    @CurOrientation=@DefOrientation
    @w=@wPt/@k
    @h=@hPt/@k

    # Page margins (1 cm)
    margin=28.35/@k
    SetMargins(margin,margin)
    # Interior cell margin (1 mm)
    @cMargin=margin/10
    # Line width (0.2 mm)
    @LineWidth=0.567/@k
    # Automatic page break
    SetAutoPageBreak(true,2*margin)
    # Full width display mode
    SetDisplayMode('fullwidth')
    # Enable compression
    SetCompression(true)
    # Set default PDF version number
    @PDFVersion='1.3'
end

Instance Attribute Details

- (Object) default_font

Returns the value of attribute default_font



29
30
31
# File 'lib/plugins/rfpdf/lib/rfpdf/fpdf.rb', line 29

def default_font
  @default_font
end

Instance Method Details

- (Object) AcceptPageBreak



651
652
653
654
# File 'lib/plugins/rfpdf/lib/rfpdf/fpdf.rb', line 651

def AcceptPageBreak
    # Accept automatic page break or not
    @AutoPageBreak
end

- (Object) AddFont(family, style = '', file = '')



500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
# File 'lib/plugins/rfpdf/lib/rfpdf/fpdf.rb', line 500

def AddFont(family, style='', file='')
     # Add a TrueType or Type1 font
     family = family.downcase
     family = 'helvetica' if family == 'arial'

     style = style.upcase
     style = 'BI' if style == 'IB'

    fontkey = family + style

    if @fonts.has_key?(fontkey)
         self.Error("Font already added: #{family} #{style}")
    end

    file = family.gsub(' ', '') + style.downcase + '.rb' if file == ''

    if self.class.const_defined? 'FPDF_FONTPATH'
        if FPDF_FONTPATH[-1,1] == '/'
            file = FPDF_FONTPATH + file
        else
            file = FPDF_FONTPATH + '/' + file
        end
    end
    
    # Changed from "require file" to fix bug reported by Hans Allis.
    load file

    if FontDef.desc.nil?
       self.Error("Could not include font definition file #{file}")
    end

    i = @fonts.length + 1

    @fonts[fontkey] = {'i'   => i,
                      'type' => FontDef.type,
                      'name' => FontDef.name,
                      'desc' => FontDef.desc,
                        'up' => FontDef.up,
                        'ut' => FontDef.ut,
                        'cw' => FontDef.cw,
                       'enc' => FontDef.enc,
                      'file' => FontDef.file
                   }

    if FontDef.diff
        # Search existing encodings
        unless @diffs.include?(FontDef.diff)
            @diffs.push(FontDef.diff)
            @fonts[fontkey]['diff'] = @diffs.length - 1
        end
    end

    if FontDef.file
         if FontDef.type == 'TrueType'
             @FontFiles[FontDef.file] = {'length1' => FontDef.originalsize}
         else
             @FontFiles[FontDef.file] = {'length1' => FontDef.size1, 'length2' => FontDef.size2}
        end
    end

    return self
end


624
625
626
627
628
# File 'lib/plugins/rfpdf/lib/rfpdf/fpdf.rb', line 624

def AddLink
    # Create a new internal link
    @links.push([0, 0])
    @links.size
end

- (Object) AddPage(orientation = '') Also known as: add_page



291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
# File 'lib/plugins/rfpdf/lib/rfpdf/fpdf.rb', line 291

def AddPage(orientation='')
    # Start a new page
    self.Open if @state==0
    family=@FontFamily
    style=@FontStyle+(@underline ? 'U' : '')
    size=@FontSizePt
    lw=@LineWidth
    dc=@DrawColor
    fc=@FillColor
    tc=@TextColor
    cf=@ColorFlag
    if @page>0
        # Page footer
        @InFooter=true
        self.Footer
        @InFooter=false
        # Close page
        endpage
    end
    # Start new page
    beginpage(orientation)
    # Set line cap style to square
    out('2 J')
    # Set line width
    @LineWidth=lw
    out(sprintf('%.2f w',lw*@k))
    # Set font
    SetFont(family,style,size) if family
    # Set colors
    @DrawColor=dc
    out(dc) if dc!='0 G'
    @FillColor=fc
    out(fc) if fc!='0 g'
    @TextColor=tc
    @ColorFlag=cf
    # Page header
    self.Header
    # Restore line width
    if @LineWidth!=lw
        @LineWidth=lw
        out(sprintf('%.2f w',lw*@k))
    end
    # Restore font
    self.SetFont(family,style,size) if family
    # Restore colors
    if @DrawColor!=dc
        @DrawColor=dc
        out(dc)
    end
    if @FillColor!=fc
        @FillColor=fc
        out(fc)
    end
    @TextColor=tc
    @ColorFlag=cf
end

- (Object) AliasNbPages(aliasnb = '{nb}')



263
264
265
266
# File 'lib/plugins/rfpdf/lib/rfpdf/fpdf.rb', line 263

def AliasNbPages(aliasnb='{nb}')
    # Define an alias for total number of pages
    @AliasNbPages=aliasnb
end

- (Boolean) BreakThePage?(h)

Returns:

  • (Boolean)


656
657
658
659
660
661
662
# File 'lib/plugins/rfpdf/lib/rfpdf/fpdf.rb', line 656

def BreakThePage?(h)
  if (@y + h) > @PageBreakTrigger and !@InFooter and self.AcceptPageBreak
    true
  else
    false
  end
end

- (Object) Cell(w, h = 0, txt = '', border = 0, ln = 0, align = '', fill = 0, link = '')



664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
# File 'lib/plugins/rfpdf/lib/rfpdf/fpdf.rb', line 664

def Cell(w,h=0,txt='',border=0,ln=0,align='',fill=0,link='')
    # Output a cell
    if self.BreakThePage?(h)
        # Automatic page break
        x=@x
        ws=@ws
        if ws>0
            @ws=0
            out('0 Tw')
        end
        self.AddPage(@CurOrientation)
        @x=x
        if ws>0
            @ws=ws
            out(sprintf('%.3f Tw',ws*@k))
        end
    end
    w=@w-@rMargin-@x if w==0
    s=''
    if fill==1 or border==1
        if fill==1
            op=(border==1) ? 'B' : 'f'
        else
            op='S'
        end
        s=sprintf('%.2f %.2f %.2f %.2f re %s ',@x*@k,(@h-@y)*@k,w*@k,-h*@k,op)
    end
    if border.is_a? String
        x=@x
        y=@y
        unless border.index('L').nil?
            s=s+sprintf('%.2f %.2f m %.2f %.2f l S ',
                x*@k,(@h-y)*@k,x*@k,(@h-(y+h))*@k)
        end
        unless border.index('T').nil?
            s=s+sprintf('%.2f %.2f m %.2f %.2f l S ',
                x*@k,(@h-y)*@k,(x+w)*@k,(@h-y)*@k)
        end
        unless border.index('R').nil?
            s=s+sprintf('%.2f %.2f m %.2f %.2f l S ',
                (x+w)*@k,(@h-y)*@k,(x+w)*@k,(@h-(y+h))*@k)
        end
        unless border.index('B').nil?
            s=s+sprintf('%.2f %.2f m %.2f %.2f l S ',
                x*@k,(@h-(y+h))*@k,(x+w)*@k,(@h-(y+h))*@k)
        end
    end
    if txt!=''
        if align=='R'
            dx=w-@cMargin-self.GetStringWidth(txt)
        elsif align=='C'
            dx=(w-self.GetStringWidth(txt))/2
        else
            dx=@cMargin
        end
        if @ColorFlag
            s=s+'q '+@TextColor+' '
        end
        s=s+sprintf('BT %.2f %.2f Td (%s) Tj ET',
            (@x+dx)*@k,(@h-(@y+0.5*h+0.3*@FontSize))*@k,escape(txt))
        s=s+' '+dounderline(@x+dx,@y+0.5*h+0.3*@FontSize,txt) if @underline
        s=s+' Q' if @ColorFlag
        if link and link != ''
            Link(@x+dx,@y+0.5*h-0.5*@FontSize,GetStringWidth(txt),@FontSize,link)
        end
    end
    out(s) if s
    @lasth=h
    if ln>0
        # Go to next line
        @y=@y+h
        @x=@lMargin if ln==1
    else
        @x=@x+w
    end
end

- (Object) Circle(mid_x, mid_y, radius, style = '')



417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
# File 'lib/plugins/rfpdf/lib/rfpdf/fpdf.rb', line 417

def Circle(mid_x, mid_y, radius, style='')
  mid_y = (@h-mid_y)*@k
  out(sprintf("q\n")) # postscript content in pdf
  # init line type etc. with /GSD gs G g (grey) RG rg (RGB) w=line witdh etc. 
  out(sprintf("1 j\n")) # line join
  # translate ("move") circle to mid_y, mid_y
  out(sprintf("1 0 0 1 %f %f cm", mid_x, mid_y))
  kappa = 0.5522847498307933984022516322796
  # Quadrant 1 
  x_s = 0.0 # 12 o'clock 
  y_s = 0.0 + radius
  x_e = 0.0 + radius # 3 o'clock 
  y_e = 0.0
  out(sprintf("%f %f m\n", x_s, y_s)) # move to 12 o'clock 
  # cubic bezier control point 1, start height and kappa * radius to the right 
  bx_e1 = x_s + (radius * kappa)
  by_e1 = y_s
  # cubic bezier control point 2, end and kappa * radius above 
  bx_e2 = x_e
  by_e2 = y_e + (radius * kappa)
  # draw cubic bezier from current point to x_e/y_e with bx_e1/by_e1 and bx_e2/by_e2 as bezier control points
  out(sprintf("%f %f %f %f %f %f c\n", bx_e1, by_e1, bx_e2, by_e2, x_e, y_e))
  # Quadrant 2 
  x_s = x_e 
  y_s = y_e # 3 o'clock 
  x_e = 0.0 
  y_e = 0.0 - radius # 6 o'clock 
  bx_e1 = x_s # cubic bezier point 1 
  by_e1 = y_s - (radius * kappa)
  bx_e2 = x_e + (radius * kappa) # cubic bezier point 2 
  by_e2 = y_e
  out(sprintf("%f %f %f %f %f %f c\n", bx_e1, by_e1, bx_e2, by_e2, x_e, y_e))
  # Quadrant 3 
  x_s = x_e 
  y_s = y_e # 6 o'clock 
  x_e = 0.0 - radius
  y_e = 0.0 # 9 o'clock 
  bx_e1 = x_s - (radius * kappa) # cubic bezier point 1 
  by_e1 = y_s
  bx_e2 = x_e # cubic bezier point 2 
  by_e2 = y_e - (radius * kappa)
  out(sprintf("%f %f %f %f %f %f c\n", bx_e1, by_e1, bx_e2, by_e2, x_e, y_e))
  # Quadrant 4 
  x_s = x_e 
  y_s = y_e # 9 o'clock 
  x_e = 0.0 
  y_e = 0.0 + radius # 12 o'clock 
  bx_e1 = x_s # cubic bezier point 1 
  by_e1 = y_s + (radius * kappa)
  bx_e2 = x_e - (radius * kappa) # cubic bezier point 2 
  by_e2 = y_e
  out(sprintf("%f %f %f %f %f %f c\n", bx_e1, by_e1, bx_e2, by_e2, x_e, y_e))
  if style=='F'
      op='f'
  elsif style=='FD' or style=='DF'
      op='b'
  else
      op='s'
  end
  out(sprintf("#{op}\n")) # stroke circle, do not fill and close path 
  # for filling etc. b, b*, f, f*
  out(sprintf("Q\n")) # finish postscript in PDF
end

- (Object) Close



277
278
279
280
281
282
283
284
285
286
287
288
289
# File 'lib/plugins/rfpdf/lib/rfpdf/fpdf.rb', line 277

def Close
    # Terminate document
    return if @state==3
    self.AddPage if @page==0
    # Page footer
    @InFooter=true
    self.Footer
    @InFooter=false
    # Close page
    endpage
    # Close document
    enddoc
end

- (Object) Error(msg)



268
269
270
# File 'lib/plugins/rfpdf/lib/rfpdf/fpdf.rb', line 268

def Error(msg)
    raise 'FPDF error: '+msg
end


353
354
355
# File 'lib/plugins/rfpdf/lib/rfpdf/fpdf.rb', line 353

def Footer
    # To be implemented in your inherited class
end

- (Object) GetCharWidth(widths, index)



393
394
395
396
397
398
399
# File 'lib/plugins/rfpdf/lib/rfpdf/fpdf.rb', line 393

def GetCharWidth(widths, index)
  if index.is_a?(String)
    widths[index.ord]
  else
    widths[index]
  end
end

- (Object) GetMargins



178
179
180
# File 'lib/plugins/rfpdf/lib/rfpdf/fpdf.rb', line 178

def GetMargins()
    return @lMargin, @tMargin, @rMargin
end

- (Object) GetStringWidth(s)



401
402
403
404
405
406
407
408
409
# File 'lib/plugins/rfpdf/lib/rfpdf/fpdf.rb', line 401

def GetStringWidth(s)
    # Get width of a string in the current font
    cw=@CurrentFont['cw']
    w=0
    s.each_byte do |c|
        w=w+GetCharWidth(cw, c)
    end
    w*@FontSize/1000.0
end

- (Object) GetX



958
959
960
961
# File 'lib/plugins/rfpdf/lib/rfpdf/fpdf.rb', line 958

def GetX
    # Get x position
    @x
end

- (Object) GetY



972
973
974
975
# File 'lib/plugins/rfpdf/lib/rfpdf/fpdf.rb', line 972

def GetY
    # Get y position
    @y
end

- (Object) Header



349
350
351
# File 'lib/plugins/rfpdf/lib/rfpdf/fpdf.rb', line 349

def Header
    # To be implemented in your inherited class
end

- (Object) Image(file, x, y, w = 0, h = 0, type = '', link = '')



908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
# File 'lib/plugins/rfpdf/lib/rfpdf/fpdf.rb', line 908

def Image(file,x,y,w=0,h=0,type='',link='')
    # Put an image on the page
    unless @images.has_key?(file)
        # First use of image, get info
        if type==''
            pos=file.rindex('.')
            if pos.nil?
                self.Error('Image file has no extension and no type was '+
                    'specified: '+file)
            end
            type=file[pos+1..-1]
        end
        type.downcase!
        if type=='jpg' or type=='jpeg'
            info=parsejpg(file)
        elsif type=='png'
            info=parsepng(file)
        else
            self.Error('Unsupported image file type: '+type)
        end
        info['i']=@images.length+1
        @images[file]=info
    else
        info=@images[file]
    end
#Ed Moss
    if(w==0 && h==0)
  		#Put image at 72 dpi
  		w=info['w']/@k;
  		h=info['h']/@k;
  	end
#
    # Automatic width or height calculation
    w=h*info['w']/info['h'] if w==0
    h=w*info['h']/info['w'] if h==0
    out(sprintf('q %.2f 0 0 %.2f %.2f %.2f cm /I%d Do Q',
        w*@k,h*@k,x*@k,(@h-(y+h))*@k,info['i']))
    Link(x,y,w,h,link) if link and link != ''
end

- (Object) Line(x1, y1, x2, y2)



481
482
483
484
485
# File 'lib/plugins/rfpdf/lib/rfpdf/fpdf.rb', line 481

def Line(x1, y1, x2, y2)
    # Draw a line
    out(sprintf('%.2f %.2f m %.2f %.2f l S',
        x1*@k,(@h-y1)*@k,x2*@k,(@h-y2)*@k))
end


637
638
639
640
641
# File 'lib/plugins/rfpdf/lib/rfpdf/fpdf.rb', line 637

def Link(x, y, w, h, link)
    # Put a link on the page
    @PageLinks[@page]=Array.new unless @PageLinks.has_key?(@Page)
    @PageLinks[@page].push([x*@k,@hPt-y*@k,w*@k,h*@k,link])
end

- (Object) Ln(h = '')



948
949
950
951
952
953
954
955
956
# File 'lib/plugins/rfpdf/lib/rfpdf/fpdf.rb', line 948

def Ln(h='')
    # Line feed; default value is last cell height
    @x=@lMargin
    if h.kind_of?(String)
        @y=@y+@lasth
    else
        @y=@y+h
    end
end

- (Object) MultiCell(w, h, txt, border = 0, align = 'J', fill = 0)



741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
# File 'lib/plugins/rfpdf/lib/rfpdf/fpdf.rb', line 741

def MultiCell(w,h,txt,border=0,align='J',fill=0)
    # Output text with automatic or explicit line breaks
    cw=@CurrentFont['cw']
    w=@w-@rMargin-@x if w==0
    wmax=(w-2*@cMargin)*1000/@FontSize
    s=txt.gsub("\r",'')
    nb=s.length
    nb=nb-1 if nb>0 and s[nb-1].chr=="\n"
    b=0
    if border!=0
        if border==1
            border='LTRB'
            b='LRT'
            b2='LR'
        else
            b2=''
            b2='L' unless border.index('L').nil?
            b2=b2+'R' unless border.index('R').nil?
            b=(not border.index('T').nil?) ? (b2+'T') : b2
        end
    end
    sep=-1
    to_index=0
    from_j=0
    l=0
    ns=0
    nl=1
    while to_index<nb
        # Get next character
        char=s[to_index]
        if char=="\n"[0]
            # Explicit line break
            if @ws>0
                @ws=0
                out('0 Tw')
            end
#Ed Moss               
            end_i = to_index == 0 ? 0 : to_index - 1
            # Changed from s[from_j..to_index] to fix bug reported by Hans Allis.
            self.Cell(w,h,s[from_j..end_i],b,2,align,fill) 
#                
            to_index=to_index+1
            sep=-1
            from_j=to_index
            l=0
            ns=0
            nl=nl+1
            b=b2 if border and nl==2
        else
            if char==' '[0]
                sep=to_index
                ls=l
                ns=ns+1
            end
            l=l+GetCharWidth(cw, char)
            if l>wmax
                # Automatic line break
                if sep==-1
                    to_index=to_index+1 if to_index==from_j
                    if @ws>0
                        @ws=0
                        out('0 Tw')
                    end
#Ed Moss
                    self.Cell(w,h,s[from_j..to_index-1],b,2,align,fill)
#
                else
                    if align=='J'
                        @ws=(ns>1) ? (wmax-ls)/1000.0*@FontSize/(ns-1) : 0
                        out(sprintf('%.3f Tw',@ws*@k))
                    end
                    self.Cell(w,h,s[from_j..sep],b,2,align,fill)
                    to_index=sep+1
                end
                sep=-1
                from_j=to_index
                l=0
                ns=0
                nl=nl+1
                b=b2 if border and nl==2
            else
                to_index=to_index+1
            end
        end
    end

    # Last chunk
    if @ws>0
        @ws=0
        out('0 Tw')
    end
    b=b+'B' if border!=0 and not border.index('B').nil?
    self.Cell(w,h,s[from_j..to_index],b,2,align,fill)
    @x=@lMargin
end

- (Object) Open



272
273
274
275
# File 'lib/plugins/rfpdf/lib/rfpdf/fpdf.rb', line 272

def Open
    # Begin document
    @state=1
end

- (Object) Output(file = nil)



993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
# File 'lib/plugins/rfpdf/lib/rfpdf/fpdf.rb', line 993

def Output(file=nil)
    # Output PDF to file or return as a string
    
    # Finish document if necessary
    self.Close if(@state<3)
    
    if file.nil?
        # Return as a string
        return @buffer
    else
        # Save file locally
        open(file,'wb') do |f|
            f.write(@buffer)
        end
    end
end

- (Object) PageNo



357
358
359
360
# File 'lib/plugins/rfpdf/lib/rfpdf/fpdf.rb', line 357

def PageNo
    # Get current page number
    @page
end

- (Object) Rect(x, y, w, h, style = '')



487
488
489
490
491
492
493
494
495
496
497
498
# File 'lib/plugins/rfpdf/lib/rfpdf/fpdf.rb', line 487

def Rect(x, y, w, h, style='')
    # Draw a rectangle
    if style=='F'
        op='f'
    elsif style=='FD' or style=='DF'
        op='B'
    else
        op='S'
    end
    # x y width height re
    out(sprintf('%.2f %.2f %.2f %.2f re %s', x*@k,(@h-y)*@k,w*@k,-h*@k,op))
end

- (Object) SetAuthor(author)



248
249
250
251
# File 'lib/plugins/rfpdf/lib/rfpdf/fpdf.rb', line 248

def SetAuthor(author)
    # Author of document
    @author=author
end

- (Object) SetAutoPageBreak(auto, margin = 0)



206
207
208
209
210
211
# File 'lib/plugins/rfpdf/lib/rfpdf/fpdf.rb', line 206

def SetAutoPageBreak(auto, margin=0)
    # Set auto page break mode and triggering margin
    @AutoPageBreak=auto
    @bMargin=margin
    @PageBreakTrigger=@h-margin
end

- (Object) SetCompression(compress)



233
234
235
236
# File 'lib/plugins/rfpdf/lib/rfpdf/fpdf.rb', line 233

def SetCompression(compress)
    # Set page compression
    @compress = compress
end

- (Object) SetCreator(creator)



258
259
260
261
# File 'lib/plugins/rfpdf/lib/rfpdf/fpdf.rb', line 258

def SetCreator(creator)
    # Creator of document
    @creator=creator
end

- (Object) SetDisplayMode(zoom, layout = 'continuous')



213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
# File 'lib/plugins/rfpdf/lib/rfpdf/fpdf.rb', line 213

def SetDisplayMode(zoom, layout='continuous')
    # Set display mode in viewer
    if zoom=='fullpage' or zoom=='fullwidth' or zoom=='real' or
        zoom=='default' or not zoom.kind_of? String

        @ZoomMode=zoom;
    elsif zoom=='zoom'
        @ZoomMode=layout
    else
        raise 'Incorrect zoom display mode: '+zoom
    end
    if layout=='single' or layout=='continuous' or layout=='two' or
        layout=='default'

        @LayoutMode=layout
    elsif zoom!='zoom'
        raise 'Incorrect layout display mode: '+layout
    end
end

- (Object) SetDrawColor(r, g = -1,, b = -1))



362
363
364
365
366
367
368
369
370
# File 'lib/plugins/rfpdf/lib/rfpdf/fpdf.rb', line 362

def SetDrawColor(r,g=-1,b=-1)
    # Set color for all stroking operations
    if (r==0 and g==0 and b==0) or g==-1
        @DrawColor=sprintf('%.3f G',r/255.0)
    else
        @DrawColor=sprintf('%.3f %.3f %.3f RG',r/255.0,g/255.0,b/255.0)
    end
    out(@DrawColor) if(@page>0)
end

- (Object) SetFillColor(r, g = -1,, b = -1))



372
373
374
375
376
377
378
379
380
381
# File 'lib/plugins/rfpdf/lib/rfpdf/fpdf.rb', line 372

def SetFillColor(r,g=-1,b=-1)
    # Set color for all filling operations
    if (r==0 and g==0 and b==0) or g==-1
        @FillColor=sprintf('%.3f g',r/255.0)
    else
        @FillColor=sprintf('%.3f %.3f %.3f rg',r/255.0,g/255.0,b/255.0)
    end
    @ColorFlag=(@FillColor!=@TextColor)
    out(@FillColor) if(@page>0)
end

- (Object) SetFont(family, style = '', size = 0)



563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
# File 'lib/plugins/rfpdf/lib/rfpdf/fpdf.rb', line 563

def SetFont(family, style='', size=0)
    # Select a font; size given in points
    family.downcase!
    family=@FontFamily if family==''
    if family=='arial'
        family='helvetica'
    elsif family=='symbol' or family=='zapfdingbats'
        style=''
    end
    style.upcase!
    unless style.index('U').nil?
        @underline=true
        style.gsub!('U','')
    else
        @underline=false;
    end
    style='BI' if style=='IB'
    size=@FontSizePt if size==0
    # Test if font is already selected
    return if @FontFamily==family and
        @FontStyle==style and @FontSizePt==size
    # Test if used for the first time
    fontkey=family+style
    unless @fonts.has_key?(fontkey)
        if @CoreFonts.has_key?(fontkey)
            unless Charwidths.has_key?(fontkey)
                raise 'Font unavailable'
            end
            @fonts[fontkey]={
                'i'=>@fonts.size,
                'type'=>'core',
                'name'=>@CoreFonts[fontkey],
                'up'=>-100,
                'ut'=>50,
                'cw'=>Charwidths[fontkey]}
        else
            raise 'Font unavailable'
        end
    end

    #Select it
    @FontFamily=family
    @FontStyle=style;
    @FontSizePt=size
    @FontSize=size/@k;
    @CurrentFont=@fonts[fontkey]
    if @page>0
        out(sprintf('BT /F%d %.2f Tf ET', @CurrentFont['i'], @FontSizePt))
    end
end

- (Object) SetFontSize(size)



614
615
616
617
618
619
620
621
622
# File 'lib/plugins/rfpdf/lib/rfpdf/fpdf.rb', line 614

def SetFontSize(size)
    # Set font size in points
    return if @FontSizePt==size
    @FontSizePt=size
    @FontSize=size/@k
    if @page>0
        out(sprintf('BT /F%d %.2f Tf ET',@CurrentFont['i'],@FontSizePt))
    end
end

- (Object) SetKeywords(keywords)



253
254
255
256
# File 'lib/plugins/rfpdf/lib/rfpdf/fpdf.rb', line 253

def SetKeywords(keywords)
    # Keywords of document
    @keywords=keywords
end

- (Object) SetLeftMargin(margin)



190
191
192
193
194
# File 'lib/plugins/rfpdf/lib/rfpdf/fpdf.rb', line 190

def SetLeftMargin(margin)
    # Set left margin
    @lMargin=margin
    @x=margin if @page>0 and @x<margin
end

- (Object) SetLineWidth(width)



411
412
413
414
415
# File 'lib/plugins/rfpdf/lib/rfpdf/fpdf.rb', line 411

def SetLineWidth(width)
    # Set line width
    @LineWidth=width
    out(sprintf('%.2f w',width*@k)) if @page>0
end


630
631
632
633
634
635
# File 'lib/plugins/rfpdf/lib/rfpdf/fpdf.rb', line 630

def SetLink(link, y=0, page=-1)
    # Set destination of internal link
    y=@y if y==-1
    page=@page if page==-1
    @links[link]=[page, y]
end

- (Object) SetMargins(left, top, right = -1))



182
183
184
185
186
187
188
# File 'lib/plugins/rfpdf/lib/rfpdf/fpdf.rb', line 182

def SetMargins(left, top, right=-1)
    # Set left, top and right margins
    @lMargin=left
    @tMargin=top
    right=left if right==-1
    @rMargin=right
end

- (Object) SetRightMargin(margin)



201
202
203
204
# File 'lib/plugins/rfpdf/lib/rfpdf/fpdf.rb', line 201

def SetRightMargin(margin)
    #Set right margin
    @rMargin=margin
end

- (Object) SetSubject(subject)



243
244
245
246
# File 'lib/plugins/rfpdf/lib/rfpdf/fpdf.rb', line 243

def SetSubject(subject)
    # Subject of document
    @subject=subject
end

- (Object) SetTextColor(r, g = -1,, b = -1))



383
384
385
386
387
388
389
390
391
# File 'lib/plugins/rfpdf/lib/rfpdf/fpdf.rb', line 383

def SetTextColor(r,g=-1,b=-1)
    # Set color for text
    if (r==0 and g==0 and b==0) or g==-1
        @TextColor=sprintf('%.3f g',r/255.0)
    else
        @TextColor=sprintf('%.3f %.3f %.3f rg',r/255.0,g/255.0,b/255.0)
    end
    @ColorFlag=(@FillColor!=@TextColor)
end

- (Object) SetTitle(title)



238
239
240
241
# File 'lib/plugins/rfpdf/lib/rfpdf/fpdf.rb', line 238

def SetTitle(title)
    # Title of document
    @title=title
end

- (Object) SetTopMargin(margin)



196
197
198
199
# File 'lib/plugins/rfpdf/lib/rfpdf/fpdf.rb', line 196

def SetTopMargin(margin)
    # Set top margin
    @tMargin=margin
end

- (Object) SetX(x)



963
964
965
966
967
968
969
970
# File 'lib/plugins/rfpdf/lib/rfpdf/fpdf.rb', line 963

def SetX(x)
    # Set x position
    if x>=0
        @x=x
    else
        @x=@w+x
    end
end

- (Object) SetXY(x, y)



987
988
989
990
991
# File 'lib/plugins/rfpdf/lib/rfpdf/fpdf.rb', line 987

def SetXY(x,y)
    # Set x and y positions
    SetY(y)
    SetX(x)
end

- (Object) SetY(y)



977
978
979
980
981
982
983
984
985
# File 'lib/plugins/rfpdf/lib/rfpdf/fpdf.rb', line 977

def SetY(y)
    # Set y position and reset x
    @x=@lMargin
    if y>=0
        @y=y
    else
        @y=@h+y
    end
end

- (Object) Text(x, y, txt)



643
644
645
646
647
648
649
# File 'lib/plugins/rfpdf/lib/rfpdf/fpdf.rb', line 643

def Text(x, y, txt)
    # Output a string
    s=sprintf('BT %.2f %.2f Td (%s) Tj ET',x*@k,(@h-y)*@k, escape(txt));
    s=s+' '+dounderline(x,y,txt) if @underline and txt!=''
    s='q '+@TextColor+' '+s+' Q' if @ColorFlag
    out(s)
end

- (Object) Write(h, txt, link = '')



837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
# File 'lib/plugins/rfpdf/lib/rfpdf/fpdf.rb', line 837

def Write(h,txt,link='')
    # Output text in flowing mode
    cw=@CurrentFont['cw']
    w=@w-@rMargin-@x
    wmax=(w-2*@cMargin)*1000/@FontSize
    s=txt.gsub("\r",'')
    nb=s.length
    sep=-1
    i=0
    j=0
    l=0
    nl=1
    while i<nb
        # Get next character
        c=s[i]
        if c=="\n"[0]
            # Explicit line break
            self.Cell(w,h,s[j,i-j],0,2,'',0,link)
            i=i+1
            sep=-1
            j=i
            l=0
            if nl==1
                @x=@lMargin
                w=@w-@rMargin-@x
                wmax=(w-2*@cMargin)*1000/@FontSize
            end
            nl=nl+1
            next
        end
        if c==' '[0]
            sep=i
            ls=l
        end
        l=l+GetCharWidth(cw, c);
        if l>wmax
            # Automatic line break
            if sep==-1
                if @x>@lMargin
                    # Move to next line
                    @x=@lMargin
                    @y=@y+h
                    w=@w-@rMargin-@x
                    wmax=(w-2*@cMargin)*1000/@FontSize
                    i=i+1
                    nl=nl+1
                    next
                end
                i=i+1 if i==j
                self.Cell(w,h,s[j,i-j],0,2,'',0,link)
            else
                self.Cell(w,h,s[j,sep-j],0,2,'',0,link)
                i=sep+1
            end
            sep=-1
            j=i
            l=0
            if nl==1
                @x=@lMargin
                w=@w-@rMargin-@x
                wmax=(w-2*@cMargin)*1000/@FontSize
            end
            nl=nl+1
        else
            i=i+1
        end
    end
    # Last chunk
    self.Cell(l/1000.0*@FontSize,h,s[j,i],0,0,'',0,link) if i!=j
end