Class: FPDF

Inherits:
Object
  • Object
show all
Defined in:
lib/pdf_paradise/fpdf/fpdf.rb

Overview

#

Forked from ruby-fpdf FPDF 1.53d

FPDF 1.53 by Olivier Plathey ported to Ruby by Brian Ollenberger Copyright 2005 Brian Ollenberger Please retain this entire copyright notice. If you distribute any modifications, place an additional comment here that clearly indicates that it was modified. You may (but are not send any useful modifications that you make back to me at

http://zeropluszero.com/software/fpdf/

Bug fixes, examples, external fonts, JPEG support, and upgrade to version 1.53 contributed by Kim Shrier.

Bookmark support contributed by Sylvain Lafleur.

EPS support contributed by Thiago Jackiw, ported from the PHP version by Valentin Schmidt.

Many other bug reports and fixes contributed by many other people.

#

Constant Summary collapse

FPDF_VERSION =
#

FPDF_VERSION

#
'1.53d'
Charwidths =
#

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

Constructor Details

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

#

initialize

#


270
271
272
273
274
275
276
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
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
# File 'lib/pdf_paradise/fpdf/fpdf.rb', line 270

def initialize(
    orientation = 'P',
    unit        = 'mm',
    format      = 'A4'
  )
  reset
  # ======================================================================= #
  # === @core_fonts
  #
  # Standard fonts will be defined next.
  # ======================================================================= #
  @core_fonts = {}
  @core_fonts['courier']='Courier'
  @core_fonts['courierB']='Courier-Bold'
  @core_fonts['courierI']='Courier-Oblique'
  @core_fonts['courierBI']='Courier-BoldOblique'
  @core_fonts['helvetica']='Helvetica'
  @core_fonts['helveticaB']='Helvetica-Bold'
  @core_fonts['helveticaI']='Helvetica-Oblique'
  @core_fonts['helveticaBI']='Helvetica-BoldOblique'
  @core_fonts['times']='Times-Roman'
  @core_fonts['timesB']='Times-Bold'
  @core_fonts['timesI']='Times-Italic'
  @core_fonts['timesBI']='Times-BoldItalic'
  @core_fonts['symbol']='Symbol'
  @core_fonts['zapfdingbats']='ZapfDingbats'

  # Scale factor
  case unit
  when 'pt'
    @k = 1
  when 'mm'
    @k = 72/25.4
  when 'cm'
    @k = 72/2.54
  when 'in'
    @k = 72
  else
    raise "Incorrect unit: #{unit}"
  end

  # Page format
  if format.is_a? String
    format = format.dup if format.frozen?
    format.downcase!
    case format
    when 'a3'
      format = [841.89,1190.55]
    when 'a4'
      format = [595.28,841.89]
    when 'a5'
      format = [420.94,595.28]
    when 'letter'
      format = [612,792]
    when '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
  if orientation.frozen?
    orientation = orientation.dup
  end
  orientation.downcase!
  case orientation
  when 'p','portrait'
    @DefOrientation='P'
    @wPt=@fwPt
    @hPt=@fhPt
  when 'l','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

#AcceptPageBreakObject

#

AcceptPageBreak

#


957
958
959
960
# File 'lib/pdf_paradise/fpdf/fpdf.rb', line 957

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

#add_font(family, style = '', file = '') ⇒ Object Also known as: AddFont

#

add_font

#


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
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
# File 'lib/pdf_paradise/fpdf/fpdf.rb', line 782

def add_font(
    family,
    style = '',
    file  = ''
  )
  # Add a TrueType or Type1 font next:
  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.end_with?('/')
      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
#
#


927
928
929
930
931
# File 'lib/pdf_paradise/fpdf/fpdf.rb', line 927

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

#alias_nb_pages(i = '{nb}') ⇒ Object Also known as: AliasNbPages

#

alias_nb_pages

Define an alias for total number of pages

#


544
545
546
# File 'lib/pdf_paradise/fpdf/fpdf.rb', line 544

def alias_nb_pages(i = '{nb}')
  @AliasNbPages = i
end

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

#

Cell

#


965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
# File 'lib/pdf_paradise/fpdf/fpdf.rb', line 965

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 = @left_margin if ln==1
  else
    @x = @x+w
  end
end

#CloseObject

Close



615
616
617
618
619
620
621
622
623
624
625
626
627
# File 'lib/pdf_paradise/fpdf/fpdf.rb', line 615

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

#dounderline(x, y, txt) ⇒ Object

#

dounderline

#


407
408
409
410
411
412
413
414
415
416
# File 'lib/pdf_paradise/fpdf/fpdf.rb', line 407

def dounderline(x,y,txt)
  # Underline text
  up = @CurrentFont['up']
  ut = @CurrentFont['ut']
  w = GetStringWidth(txt)+@ws*txt.count(' ')
  sprintf(
    '%.2f %.2f %.2f %.2f re f',
    x*@k, (@h - (y - up/1000.0 * @FontSize))*@k,w*@k,-ut/1000.0 * @FontSizePt
  )
end

#error(i) ⇒ Object Also known as: Error

error



605
606
607
# File 'lib/pdf_paradise/fpdf/fpdf.rb', line 605

def error(i)
  raise "FPDF error: #{i}"
end


703
704
705
# File 'lib/pdf_paradise/fpdf/fpdf.rb', line 703

def Footer
  # To be implemented in your inherited class
end

#GetStringWidth(s) ⇒ Object



750
751
752
753
754
755
756
757
758
# File 'lib/pdf_paradise/fpdf/fpdf.rb', line 750

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

#GetXObject



1206
1207
1208
1209
# File 'lib/pdf_paradise/fpdf/fpdf.rb', line 1206

def GetX
  # Get x position
  @x
end

#GetYObject



1220
1221
1222
1223
# File 'lib/pdf_paradise/fpdf/fpdf.rb', line 1220

def GetY
  # Get y position
  @y
end

#HeaderObject



699
700
701
# File 'lib/pdf_paradise/fpdf/fpdf.rb', line 699

def Header
  # To be implemented in your inherited class
end

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

Image



1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
# File 'lib/pdf_paradise/fpdf/fpdf.rb', line 1163

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.empty?
      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

#

Draw a line

#


632
633
634
635
636
# File 'lib/pdf_paradise/fpdf/fpdf.rb', line 632

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


948
949
950
951
952
# File 'lib/pdf_paradise/fpdf/fpdf.rb', line 948

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



1196
1197
1198
1199
1200
1201
1202
1203
1204
# File 'lib/pdf_paradise/fpdf/fpdf.rb', line 1196

def Ln(h='')
  # Line feed; default value is last cell height
  @x=@left_margin
  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



1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
# File 'lib/pdf_paradise/fpdf/fpdf.rb', line 1054

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
    case border
    when 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 += 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 += 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=@left_margin
end

#new_page(orientation = '') ⇒ Object Also known as: AddPage, add_page

#

new_page

#


641
642
643
644
645
646
647
648
649
650
651
652
653
654
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
# File 'lib/pdf_paradise/fpdf/fpdf.rb', line 641

def new_page(orientation = '')
  # Start a new page
  self.Open if @state==0
  family = @font_family
  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
  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

#OpenObject



609
610
611
612
# File 'lib/pdf_paradise/fpdf/fpdf.rb', line 609

def Open
  # Begin document
  @state=1
end

#Output(file = nil) ⇒ Object

Output



1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
# File 'lib/pdf_paradise/fpdf/fpdf.rb', line 1242

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

#PageNoObject



707
708
709
710
# File 'lib/pdf_paradise/fpdf/fpdf.rb', line 707

def PageNo
  # Get current page number
  @page
end

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



767
768
769
770
771
772
773
774
775
776
777
# File 'lib/pdf_paradise/fpdf/fpdf.rb', line 767

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

#resetObject

#

reset

#


378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
# File 'lib/pdf_paradise/fpdf/fpdf.rb', line 378

def reset
  @page=0
  @n=2
  @buffer=''
  @pages=[]
  @OrientationChanges=[]
  @state=0
  @fonts = {}
  @FontFiles = {}
  @diffs=[]
  @images = {}
  @links=[]
  @PageLinks = {}
  @InFooter=false
  @font_family = ''
  @FontStyle=''
  @FontSizePt=12
  @underline= false
  @DrawColor='0 G'
  @FillColor='0 g'
  @TextColor='0 g'
  @ColorFlag=false
  @ws=0
  @offsets=[]
end

#set_fill_colour(r, g = -1,, b = -1)) ⇒ Object Also known as: SetFillColor

#

set_fill_colour

This method will set the colour for all filling operations.

#


730
731
732
733
734
735
736
737
738
# File 'lib/pdf_paradise/fpdf/fpdf.rb', line 730

def set_fill_colour(r, g = -1, b = -1)
  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

#set_left_margin(i) ⇒ Object Also known as: SetLeftMargin

#

set_left_margin

This method can be used to set the left margin of the .pdf file at hand.

#


445
446
447
448
# File 'lib/pdf_paradise/fpdf/fpdf.rb', line 445

def set_left_margin(i)
  @left_margin = i
  @x = i if @page>0 and @x < i
end

#set_margins(left, top, right = -1) ⇒ Object Also known as: SetMargins

#

set_margins

#


421
422
423
424
425
426
427
428
429
# File 'lib/pdf_paradise/fpdf/fpdf.rb', line 421

def set_margins(
    left, top, right=-1
  )
  # Set left, top and right margins
  @left_margin = left
  @top_margin = top
  right=left if right==-1
  @rMargin=right
end

#set_title(i) ⇒ Object Also known as: SetTitle

#

set_title

Set the title of the .pdf document through this method here.

#


436
437
438
# File 'lib/pdf_paradise/fpdf/fpdf.rb', line 436

def set_title(i)
  @title = i
end

#SetAuthor(author) ⇒ Object



589
590
591
592
# File 'lib/pdf_paradise/fpdf/fpdf.rb', line 589

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

#SetAutoPageBreak(auto, margin = 0) ⇒ Object

#

SetAutoPageBreak

#


551
552
553
554
555
556
# File 'lib/pdf_paradise/fpdf/fpdf.rb', line 551

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

#SetCompression(i) ⇒ Object

SetCompression



579
580
581
582
# File 'lib/pdf_paradise/fpdf/fpdf.rb', line 579

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

#SetCreator(creator) ⇒ Object



599
600
601
602
# File 'lib/pdf_paradise/fpdf/fpdf.rb', line 599

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

#SetDisplayMode(zoom, layout = 'continuous') ⇒ Object



558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
# File 'lib/pdf_paradise/fpdf/fpdf.rb', line 558

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

#
#


715
716
717
718
719
720
721
722
723
# File 'lib/pdf_paradise/fpdf/fpdf.rb', line 715

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

#SetFont(family, style = '', size = 0) ⇒ Object Also known as: set_font

SetFont



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
907
908
909
910
911
# File 'lib/pdf_paradise/fpdf/fpdf.rb', line 854

def SetFont(
    family,
    style = '',
    size  = 0
  )
  # Select a font; the size is given in points.
  if family.frozen?
    family = family.dup
  end
  family.downcase!
  family = @font_family if family.empty?
  case family
  when 'arial'
    family = 'helvetica'
  when 'symbol','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 @font_family==family and
    @FontStyle==style and @FontSizePt==size
  # Test if used for the first time
  fontkey=family+style
  unless @fonts.has_key?(fontkey)
    if @core_fonts.has_key?(fontkey)
      unless Charwidths.has_key?(fontkey)
        raise 'Font unavailable'
      end
      @fonts[fontkey]={
        'i'=>@fonts.size,
        'type'=>'core',
        'name'=>@core_fonts[fontkey],
        'up'  =>-100,
        'ut'  =>50,
        'cw'  =>Charwidths[fontkey]}
    else
      raise 'Font unavailable'
    end
  end

  # Select it
  @font_family  = 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

SetFontSize



914
915
916
917
918
919
920
921
922
# File 'lib/pdf_paradise/fpdf/fpdf.rb', line 914

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



594
595
596
597
# File 'lib/pdf_paradise/fpdf/fpdf.rb', line 594

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

#SetLineWidth(width) ⇒ Object



760
761
762
763
764
# File 'lib/pdf_paradise/fpdf/fpdf.rb', line 760

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


936
937
938
939
940
941
942
943
# File 'lib/pdf_paradise/fpdf/fpdf.rb', line 936

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

#SetRightMargin(i) ⇒ Object

#

SetRightMargin

#


534
535
536
537
# File 'lib/pdf_paradise/fpdf/fpdf.rb', line 534

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

#SetSubject(subject) ⇒ Object



584
585
586
587
# File 'lib/pdf_paradise/fpdf/fpdf.rb', line 584

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

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



740
741
742
743
744
745
746
747
748
# File 'lib/pdf_paradise/fpdf/fpdf.rb', line 740

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

#SetTopMargin(i) ⇒ Object

#

SetTopMargin

Set top margin

#


527
528
529
# File 'lib/pdf_paradise/fpdf/fpdf.rb', line 527

def SetTopMargin(i)
  @top_margin = i
end

#SetX(x) ⇒ Object



1211
1212
1213
1214
1215
1216
1217
1218
# File 'lib/pdf_paradise/fpdf/fpdf.rb', line 1211

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

#SetXY(x, y) ⇒ Object



1235
1236
1237
1238
1239
# File 'lib/pdf_paradise/fpdf/fpdf.rb', line 1235

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

#SetY(y) ⇒ Object



1225
1226
1227
1228
1229
1230
1231
1232
1233
# File 'lib/pdf_paradise/fpdf/fpdf.rb', line 1225

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

#Text(x, y, txt) ⇒ Object

#

Text

#


1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
# File 'lib/pdf_paradise/fpdf/fpdf.rb', line 1151

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

Write



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
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
# File 'lib/pdf_paradise/fpdf/fpdf.rb', line 451

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 += 1
      sep = -1
      j=i
      l=0
      if nl==1
        @x=@left_margin
        w=@w-@rMargin-@x
        wmax=(w-2*@cMargin)*1000/@FontSize
      end
      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>@left_margin
          # Move to next line
          @x=@left_margin
          @y=@y+h
          w=@w-@rMargin-@x
          wmax=(w-2*@cMargin)*1000/@FontSize
          i=i+1
          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=@left_margin
        w=@w-@rMargin-@x
        wmax=(w-2*@cMargin)*1000/@FontSize
      end
      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