googlechartlib
8 years ago
tcpdf
7 years ago
array2xml.php
8 years ago
browser.php
8 years ago
give-pdf.php
7 years ago
wp-async-request.php
8 years ago
wp-background-process.php
8 years ago
give-pdf.php
111 lines
| 1 | <?php |
| 2 | /** |
| 3 | * PDF MultiCell Table Class. |
| 4 | * |
| 5 | * @package Give PDFs |
| 6 | * @subpackage TCPDF |
| 7 | * @since 1.8.14 |
| 8 | */ |
| 9 | |
| 10 | // Exit if accessed directly. |
| 11 | if ( ! defined( 'ABSPATH' ) ) { |
| 12 | exit; |
| 13 | } |
| 14 | |
| 15 | /** |
| 16 | * Composer's autoload.php. |
| 17 | */ |
| 18 | if ( ! class_exists( 'TCPDF' ) ) { |
| 19 | if ( file_exists( GIVE_PLUGIN_DIR . 'vendor/tecnickcom/tcpdf/tcpdf.php' ) ) { |
| 20 | require_once GIVE_PLUGIN_DIR . 'vendor/tecnickcom/tcpdf/tcpdf.php'; |
| 21 | } else { |
| 22 | // Load autoloader. |
| 23 | require_once GIVE_PLUGIN_DIR . 'includes/libraries/tcpdf/tcpdf.php'; |
| 24 | } |
| 25 | } |
| 26 | |
| 27 | /** |
| 28 | * Class Give_PDF |
| 29 | */ |
| 30 | class Give_PDF extends TCPDF { |
| 31 | |
| 32 | /** |
| 33 | * Width. |
| 34 | * |
| 35 | * @var int $widths Width. |
| 36 | */ |
| 37 | var $widths; |
| 38 | |
| 39 | /** |
| 40 | * Alignment. |
| 41 | * |
| 42 | * @var string $aligns Alignment. |
| 43 | */ |
| 44 | var $aligns; |
| 45 | |
| 46 | /** |
| 47 | * Set Header. |
| 48 | */ |
| 49 | function Header() { |
| 50 | } |
| 51 | |
| 52 | /** |
| 53 | * Set Footer. |
| 54 | */ |
| 55 | function Footer() { |
| 56 | $this->SetY( - 15 ); |
| 57 | $this->SetFont( 'Helvetica', 'I', 8 ); |
| 58 | $this->Cell( 0, 10, 'Page ' . $this->PageNo(), 0, 0, 'C' ); |
| 59 | } |
| 60 | |
| 61 | /** |
| 62 | * Set Width. |
| 63 | * |
| 64 | * @param array $w Cell Width. |
| 65 | */ |
| 66 | function SetWidths( $w ) { |
| 67 | $this->widths = $w; |
| 68 | } |
| 69 | |
| 70 | /** |
| 71 | * Set Alignment. |
| 72 | * |
| 73 | * @param string $a Cell Alignment. |
| 74 | */ |
| 75 | function SetAligns( $a ) { |
| 76 | $this->aligns = $a; |
| 77 | } |
| 78 | |
| 79 | /** |
| 80 | * Set Table Row. |
| 81 | * |
| 82 | * @param array $data Set data in a row. |
| 83 | */ |
| 84 | function Row( $data ) { |
| 85 | $nb = 0; |
| 86 | $get_height = array(); |
| 87 | for ( $i = 0; $i < count( $data ); $i ++ ) { |
| 88 | $get_height[] = max( $nb, $this->getNumLines( $data[ $i ], $this->widths[ $i ] ) ); |
| 89 | } |
| 90 | // Get max height from the all column. |
| 91 | $max_height = max( $get_height ); |
| 92 | |
| 93 | for ( $i = 0; $i < count( $data ); $i ++ ) { |
| 94 | $h = 7 * $max_height; |
| 95 | $this->checkPageBreak( $h, '', true ); |
| 96 | |
| 97 | $w = $this->widths[ $i ]; |
| 98 | $a = isset( $this->aligns[ $i ] ) ? $this->aligns[ $i ] : 'L'; |
| 99 | $x = $this->GetX(); |
| 100 | $y = $this->GetY(); |
| 101 | $this->Rect( $x, $y, $w, $h ); |
| 102 | |
| 103 | $this->MultiCell( $w, $h, $data[ $i ], 0, $a, false, 1, '', '', true, 0, false, true, 0, 'M', false ); |
| 104 | $this->SetXY( $x + $w, $y ); |
| 105 | } |
| 106 | |
| 107 | $this->Ln( $max_height * 7 ); |
| 108 | } |
| 109 | |
| 110 | } |
| 111 |