Class: FPDF
- Inherits:
-
Object
- Object
- FPDF
- Defined in:
- lib/fpdf.rb
Constant Summary collapse
- 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 Method Summary collapse
- #AcceptPageBreak ⇒ Object
- #AddFont(family, style = '', file = '') ⇒ Object
- #AddLink ⇒ Object
- #AddPage(orientation = '') ⇒ Object
- #AliasNbPages(aliasnb = '{nb}') ⇒ Object
- #Cell(w, h = 0, txt = '', border = 0, ln = 0, align = '', fill = 0, link = '') ⇒ Object
- #Close ⇒ Object
- #Error(msg) ⇒ Object
- #Footer ⇒ Object
- #GetStringWidth(s) ⇒ Object
- #GetX ⇒ Object
- #GetY ⇒ Object
- #Header ⇒ Object
- #Image(file, x, y, w, h = 0, type = '', link = '') ⇒ Object
-
#initialize(orientation = 'P', unit = 'mm', format = 'A4') ⇒ FPDF
constructor
A new instance of FPDF.
- #Line(x1, y1, x2, y2) ⇒ Object
- #Link(x, y, w, h, link) ⇒ Object
- #Ln(h = '') ⇒ Object
- #MultiCell(w, h, txt, border = 0, align = 'J', fill = 0) ⇒ Object
- #Open ⇒ Object
- #Output(file = nil) ⇒ Object
- #PageNo ⇒ Object
- #Rect(x, y, w, h, style = '') ⇒ Object
- #SetAuthor(author) ⇒ Object
- #SetAutoPageBreak(auto, margin = 0) ⇒ Object
- #SetCompression(compress) ⇒ Object
- #SetCreator(creator) ⇒ Object
- #SetDisplayMode(zoom, layout = 'continuous') ⇒ Object
- #SetDrawColor(r, g = -1,, b = -1)) ⇒ Object
- #SetFillColor(r, g = -1,, b = -1)) ⇒ Object
- #SetFont(family, style = '', size = 0) ⇒ Object
- #SetFontSize(size) ⇒ Object
- #SetKeywords(keywords) ⇒ Object
- #SetLeftMargin(margin) ⇒ Object
- #SetLineWidth(width) ⇒ Object
- #SetLink(link, y = 0, page = -1)) ⇒ Object
- #SetMargins(left, top, right = -1)) ⇒ Object
- #SetRightMargin(margin) ⇒ Object
- #SetSubject(subject) ⇒ Object
- #SetTextColor(r, g = -1,, b = -1)) ⇒ Object
- #SetTitle(title) ⇒ Object
- #SetTopMargin(margin) ⇒ Object
- #SetX(x) ⇒ Object
- #SetXY(x, y) ⇒ Object
- #SetY(y) ⇒ Object
- #Text(x, y, txt) ⇒ Object
- #Write(h, txt, link = '') ⇒ Object
Constructor Details
#initialize(orientation = 'P', unit = 'mm', format = 'A4') ⇒ FPDF
Returns a new instance of FPDF.
54 55 56 57 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 |
# File 'lib/fpdf.rb', line 54 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
#AcceptPageBreak ⇒ Object
570 571 572 573 |
# File 'lib/fpdf.rb', line 570 def AcceptPageBreak # Accept automatic page break or not @AutoPageBreak end |
#AddFont(family, style = '', file = '') ⇒ Object
412 413 414 415 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 'lib/fpdf.rb', line 412 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 idx = @diffs.index(FontDef.diff) unless idx @diffs.push(FontDef.diff) @fonts[fontkey]['diff'] = @diffs.length else @fonts[fontkey]['diff'] = idx + 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 |
#AddLink ⇒ Object
540 541 542 543 544 |
# File 'lib/fpdf.rb', line 540 def AddLink # Create a new internal link @links.push([0, 0]) @links.size end |
#AddPage(orientation = '') ⇒ Object
277 278 279 280 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 |
# File 'lib/fpdf.rb', line 277 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 |
#AliasNbPages(aliasnb = '{nb}') ⇒ Object
249 250 251 252 |
# File 'lib/fpdf.rb', line 249 def AliasNbPages(aliasnb='{nb}') # Define an alias for total number of pages @AliasNbPages=aliasnb end |
#Cell(w, h = 0, txt = '', border = 0, ln = 0, align = '', fill = 0, link = '') ⇒ Object
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 'lib/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 |
#Close ⇒ Object
263 264 265 266 267 268 269 270 271 272 273 274 275 |
# File 'lib/fpdf.rb', line 263 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 |
#Error(msg) ⇒ Object
254 255 256 |
# File 'lib/fpdf.rb', line 254 def Error(msg) raise 'FPDF error: '+msg end |
#Footer ⇒ Object
338 339 340 |
# File 'lib/fpdf.rb', line 338 def Footer # To be implemented in your inherited class end |
#GetStringWidth(s) ⇒ Object
378 379 380 381 382 383 384 385 386 |
# File 'lib/fpdf.rb', line 378 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 |
#GetX ⇒ Object
862 863 864 865 |
# File 'lib/fpdf.rb', line 862 def GetX # Get x position @x end |
#GetY ⇒ Object
876 877 878 879 |
# File 'lib/fpdf.rb', line 876 def GetY # Get y position @y end |
#Header ⇒ Object
334 335 336 |
# File 'lib/fpdf.rb', line 334 def Header # To be implemented in your inherited class end |
#Image(file, x, y, w, h = 0, type = '', link = '') ⇒ Object
819 820 821 822 823 824 825 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 |
# File 'lib/fpdf.rb', line 819 def Image(file,x,y,w,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 # 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 |
#Line(x1, y1, x2, y2) ⇒ Object
394 395 396 397 398 |
# File 'lib/fpdf.rb', line 394 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 |
#Link(x, y, w, h, link) ⇒ Object
553 554 555 556 557 |
# File 'lib/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 |
#Ln(h = '') ⇒ Object
852 853 854 855 856 857 858 859 860 |
# File 'lib/fpdf.rb', line 852 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 |
#MultiCell(w, h, txt, border = 0, align = 'J', fill = 0) ⇒ Object
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 |
# File 'lib/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 # Changed from s[j..i] to fix bug reported by Hans Allis. self.Cell(w,h,s[j..i-1],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) 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 |
#Open ⇒ Object
258 259 260 261 |
# File 'lib/fpdf.rb', line 258 def Open # Begin document @state=1 end |
#Output(file = nil) ⇒ Object
897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 |
# File 'lib/fpdf.rb', line 897 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 |
#PageNo ⇒ Object
342 343 344 345 |
# File 'lib/fpdf.rb', line 342 def PageNo # Get current page number @page end |
#Rect(x, y, w, h, style = '') ⇒ Object
400 401 402 403 404 405 406 407 408 409 410 |
# File 'lib/fpdf.rb', line 400 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 |
#SetAuthor(author) ⇒ Object
234 235 236 237 |
# File 'lib/fpdf.rb', line 234 def SetAuthor() # Author of document @author= end |
#SetAutoPageBreak(auto, margin = 0) ⇒ Object
192 193 194 195 196 197 |
# File 'lib/fpdf.rb', line 192 def SetAutoPageBreak(auto, margin=0) # Set auto page break mode and triggering margin @AutoPageBreak=auto @bMargin=margin @PageBreakTrigger=@h-margin end |
#SetCompression(compress) ⇒ Object
219 220 221 222 |
# File 'lib/fpdf.rb', line 219 def SetCompression(compress) # Set page compression @compress = compress end |
#SetCreator(creator) ⇒ Object
244 245 246 247 |
# File 'lib/fpdf.rb', line 244 def SetCreator(creator) # Creator of document @creator=creator end |
#SetDisplayMode(zoom, layout = 'continuous') ⇒ Object
199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 |
# File 'lib/fpdf.rb', line 199 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 |
#SetDrawColor(r, g = -1,, b = -1)) ⇒ Object
347 348 349 350 351 352 353 354 355 |
# File 'lib/fpdf.rb', line 347 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 |
#SetFillColor(r, g = -1,, b = -1)) ⇒ Object
357 358 359 360 361 362 363 364 365 366 |
# File 'lib/fpdf.rb', line 357 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 |
#SetFont(family, style = '', size = 0) ⇒ Object
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 'lib/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 |
#SetFontSize(size) ⇒ Object
530 531 532 533 534 535 536 537 538 |
# File 'lib/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 |
#SetKeywords(keywords) ⇒ Object
239 240 241 242 |
# File 'lib/fpdf.rb', line 239 def SetKeywords(keywords) # Keywords of document @keywords=keywords end |
#SetLeftMargin(margin) ⇒ Object
176 177 178 179 180 |
# File 'lib/fpdf.rb', line 176 def SetLeftMargin(margin) # Set left margin @lMargin=margin @x=margin if @page>0 and @x<margin end |
#SetLineWidth(width) ⇒ Object
388 389 390 391 392 |
# File 'lib/fpdf.rb', line 388 def SetLineWidth(width) # Set line width @LineWidth=width out(sprintf('%.2f w',width*@k)) if @page>0 end |
#SetLink(link, y = 0, page = -1)) ⇒ Object
546 547 548 549 550 551 |
# File 'lib/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 |
#SetMargins(left, top, right = -1)) ⇒ Object
168 169 170 171 172 173 174 |
# File 'lib/fpdf.rb', line 168 def SetMargins(left, top, right=-1) # Set left, top and right margins @lMargin=left @tMargin=top right=left if right==-1 @rMargin=right end |
#SetRightMargin(margin) ⇒ Object
187 188 189 190 |
# File 'lib/fpdf.rb', line 187 def SetRightMargin(margin) #Set right margin @rMargin=margin end |
#SetSubject(subject) ⇒ Object
229 230 231 232 |
# File 'lib/fpdf.rb', line 229 def SetSubject(subject) # Subject of document @subject=subject end |
#SetTextColor(r, g = -1,, b = -1)) ⇒ Object
368 369 370 371 372 373 374 375 376 |
# File 'lib/fpdf.rb', line 368 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 |
#SetTitle(title) ⇒ Object
224 225 226 227 |
# File 'lib/fpdf.rb', line 224 def SetTitle(title) # Title of document @title=title end |
#SetTopMargin(margin) ⇒ Object
182 183 184 185 |
# File 'lib/fpdf.rb', line 182 def SetTopMargin(margin) # Set top margin @tMargin=margin end |
#SetX(x) ⇒ Object
867 868 869 870 871 872 873 874 |
# File 'lib/fpdf.rb', line 867 def SetX(x) # Set x position if x>=0 @x=x else @x=@w+x end end |
#SetXY(x, y) ⇒ Object
891 892 893 894 895 |
# File 'lib/fpdf.rb', line 891 def SetXY(x,y) # Set x and y positions SetY(y) SetX(x) end |
#SetY(y) ⇒ Object
881 882 883 884 885 886 887 888 889 |
# File 'lib/fpdf.rb', line 881 def SetY(y) # Set y position and reset x @x=@lMargin if y>=0 @y=y else @y=@h+y end end |
#Text(x, y, txt) ⇒ Object
559 560 561 562 563 564 565 566 567 568 |
# File 'lib/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 |
#Write(h, txt, link = '') ⇒ Object
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 |
# File 'lib/fpdf.rb', line 748 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 |