Class: FPDF

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

Direct Known Subclasses

Redmine::Export::PDF::IFPDF

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]
}
M_SOF0 =

jpeg marker codes

0xc0
M_SOF1 =
0xc1
M_SOF2 =
0xc2
M_SOF3 =
0xc3
M_SOF5 =
0xc5
M_SOF6 =
0xc6
M_SOF7 =
0xc7
M_SOF9 =
0xc9
M_SOF10 =
0xca
M_SOF11 =
0xcb
M_SOF13 =
0xcd
M_SOF14 =
0xce
M_SOF15 =
0xcf
M_SOI =
0xd8
M_EOI =
0xd9
M_SOS =
0xda

Instance Method Summary

Constructor Details

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

A new instance of FPDF



58
59
60
61
62
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
# File 'vendor/plugins/rfpdf/lib/rfpdf/fpdf.rb', line 58

def initialize(orientation='P', unit='mm', format='A4')
    # Initialization of properties
    @page=0
    @n=2
    @buffer=''
    @pages=[]
    @OrientationChanges=[]
    @state=0
    @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 Method Details

- (Object) AcceptPageBreak



570
571
572
573
# File 'vendor/plugins/rfpdf/lib/rfpdf/fpdf.rb', line 570

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

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



416
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
# File 'vendor/plugins/rfpdf/lib/rfpdf/fpdf.rb', line 416

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


540
541
542
543
544
# File 'vendor/plugins/rfpdf/lib/rfpdf/fpdf.rb', line 540

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

- (Object) AddPage(orientation = '')



281
282
283
284
285
286
287
288
289
290
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
# File 'vendor/plugins/rfpdf/lib/rfpdf/fpdf.rb', line 281

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}')



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

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

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



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
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
# File 'vendor/plugins/rfpdf/lib/rfpdf/fpdf.rb', line 575

def Cell(w,h=0,txt='',border=0,ln=0,align='',fill=0,link='')
    # Output a cell
    if @y+h>@PageBreakTrigger and !@InFooter and self.AcceptPageBreak
        # 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
        txt = txt.gsub(')', '\\)')
        txt.gsub!('(', '\\(')
        txt.gsub!('\\', '\\\\')
        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,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) Close



267
268
269
270
271
272
273
274
275
276
277
278
279
# File 'vendor/plugins/rfpdf/lib/rfpdf/fpdf.rb', line 267

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)



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

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


342
343
344
# File 'vendor/plugins/rfpdf/lib/rfpdf/fpdf.rb', line 342

def Footer
    # To be implemented in your inherited class
end

- (Object) GetStringWidth(s)



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

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

- (Object) GetX



876
877
878
879
# File 'vendor/plugins/rfpdf/lib/rfpdf/fpdf.rb', line 876

def GetX
    # Get x position
    @x
end

- (Object) GetY



890
891
892
893
# File 'vendor/plugins/rfpdf/lib/rfpdf/fpdf.rb', line 890

def GetY
    # Get y position
    @y
end

- (Object) Header



338
339
340
# File 'vendor/plugins/rfpdf/lib/rfpdf/fpdf.rb', line 338

def Header
    # To be implemented in your inherited class
end

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



826
827
828
829
830
831
832
833
834
835
836
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
# File 'vendor/plugins/rfpdf/lib/rfpdf/fpdf.rb', line 826

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)



398
399
400
401
402
# File 'vendor/plugins/rfpdf/lib/rfpdf/fpdf.rb', line 398

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


553
554
555
556
557
# File 'vendor/plugins/rfpdf/lib/rfpdf/fpdf.rb', line 553

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 = '')



866
867
868
869
870
871
872
873
874
# File 'vendor/plugins/rfpdf/lib/rfpdf/fpdf.rb', line 866

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)



655
656
657
658
659
660
661
662
663
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
740
741
742
743
744
745
746
747
748
749
750
751
752
753
# File 'vendor/plugins/rfpdf/lib/rfpdf/fpdf.rb', line 655

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
    i=0
    j=0
    l=0
    ns=0
    nl=1
    while i<nb
        # Get next character
        c=s[i].chr
        if c=="\n"
            # Explicit line break
            if @ws>0
                @ws=0
                out('0 Tw')
            end
#Ed Moss               
# Don't let i go negative
            end_i = i == 0 ? 0 : i - 1
            # Changed from s[j..i] to fix bug reported by Hans Allis.
            self.Cell(w,h,s[j..end_i],b,2,align,fill) 
#                
            i=i+1
            sep=-1
            j=i
            l=0
            ns=0
            nl=nl+1
            b=b2 if border and nl==2
        else
            if c==' '
                sep=i
                ls=l
                ns=ns+1
            end
            l=l+cw[c[0]]
            if l>wmax
                # Automatic line break
                if sep==-1
                    i=i+1 if i==j
                    if @ws>0
                        @ws=0
                        out('0 Tw')
                    end
                    self.Cell(w,h,s[j..i],b,2,align,fill)
#Ed Moss
# Added so that it wouldn't print the last character of the string if it got close
#FIXME 2006-07-18 Level=0 - but it still puts out an extra new line
                    i += 1
#
                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[j..sep],b,2,align,fill)
                    i=sep+1
                end
                sep=-1
                j=i
                l=0
                ns=0
                nl=nl+1
                b=b2 if border and nl==2
            else
                i=i+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[j..i],b,2,align,fill)
    @x=@lMargin
end

- (Object) Open



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

def Open
    # Begin document
    @state=1
end

- (Object) Output(file = nil)



911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
# File 'vendor/plugins/rfpdf/lib/rfpdf/fpdf.rb', line 911

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



346
347
348
349
# File 'vendor/plugins/rfpdf/lib/rfpdf/fpdf.rb', line 346

def PageNo
    # Get current page number
    @page
end

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



404
405
406
407
408
409
410
411
412
413
414
# File 'vendor/plugins/rfpdf/lib/rfpdf/fpdf.rb', line 404

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
    out(sprintf('%.2f %.2f %.2f %.2f re %s', x*@k,(@h-y)*@k,w*@k,-h*@k,op))
end

- (Object) SetAuthor(author)



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

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

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



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

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

- (Object) SetCompression(compress)



223
224
225
226
# File 'vendor/plugins/rfpdf/lib/rfpdf/fpdf.rb', line 223

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

- (Object) SetCreator(creator)



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

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

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



203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
# File 'vendor/plugins/rfpdf/lib/rfpdf/fpdf.rb', line 203

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)



351
352
353
354
355
356
357
358
359
# File 'vendor/plugins/rfpdf/lib/rfpdf/fpdf.rb', line 351

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)



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

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)



479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
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
# File 'vendor/plugins/rfpdf/lib/rfpdf/fpdf.rb', line 479

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)



530
531
532
533
534
535
536
537
538
# File 'vendor/plugins/rfpdf/lib/rfpdf/fpdf.rb', line 530

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)



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

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

- (Object) SetLeftMargin(margin)



180
181
182
183
184
# File 'vendor/plugins/rfpdf/lib/rfpdf/fpdf.rb', line 180

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

- (Object) SetLineWidth(width)



392
393
394
395
396
# File 'vendor/plugins/rfpdf/lib/rfpdf/fpdf.rb', line 392

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


546
547
548
549
550
551
# File 'vendor/plugins/rfpdf/lib/rfpdf/fpdf.rb', line 546

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)



172
173
174
175
176
177
178
# File 'vendor/plugins/rfpdf/lib/rfpdf/fpdf.rb', line 172

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)



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

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

- (Object) SetSubject(subject)



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

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

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



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

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)



228
229
230
231
# File 'vendor/plugins/rfpdf/lib/rfpdf/fpdf.rb', line 228

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

- (Object) SetTopMargin(margin)



186
187
188
189
# File 'vendor/plugins/rfpdf/lib/rfpdf/fpdf.rb', line 186

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

- (Object) SetX(x)



881
882
883
884
885
886
887
888
# File 'vendor/plugins/rfpdf/lib/rfpdf/fpdf.rb', line 881

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

- (Object) SetXY(x, y)



905
906
907
908
909
# File 'vendor/plugins/rfpdf/lib/rfpdf/fpdf.rb', line 905

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

- (Object) SetY(y)



895
896
897
898
899
900
901
902
903
# File 'vendor/plugins/rfpdf/lib/rfpdf/fpdf.rb', line 895

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)



559
560
561
562
563
564
565
566
567
568
# File 'vendor/plugins/rfpdf/lib/rfpdf/fpdf.rb', line 559

def Text(x, y, txt)
    # Output a string
    txt.gsub!(')', '\\)')
    txt.gsub!('(', '\\(')
    txt.gsub!('\\', '\\\\')
    s=sprintf('BT %.2f %.2f Td (%s) Tj ET',x*@k,(@h-y)*@k,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 = '')



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
# File 'vendor/plugins/rfpdf/lib/rfpdf/fpdf.rb', line 755

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+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