Ejemplo n.º 1
1
/**
 * Imports the OMR fonts
 *
 * @param string $echo
 *            if echoes the result
 */
function emarking_import_omr_fonts($echo = false)
{
    global $CFG;
    // The list of extensions a font in the tcpdf installation has
    $fontfilesextensions = array('.ctg.z', '.php', '.z');
    // The font files required for OMR
    $fonts = array('3of9_new' => '/mod/emarking/lib/omr/3OF9_NEW.TTF', 'omrbubbles' => '/mod/emarking/lib/omr/OMRBubbles.ttf', 'omrextnd' => '/mod/emarking/lib/omr/OMRextnd.ttf');
    // We delete previous fonts if any and then import it
    foreach ($fonts as $fontname => $fontfile) {
        // Deleteing the previous fonts
        foreach ($fontfilesextensions as $extension) {
            $fontfilename = $CFG->libdir . '/tcpdf/fonts/' . $fontname . $extension;
            if (file_exists($fontfilename)) {
                echo "Deleting {$fontfilename}<br/>";
                unlink($fontfilename);
            } else {
                echo "{$fontfilename} does not exist, it must be created<br/>";
            }
        }
        // Import the font
        $ttfontname = TCPDF_FONTS::addTTFfont($CFG->dirroot . $fontfile, 'TrueType', 'ansi', 32);
        // Validate if import went well
        if ($ttfontname !== $fontname) {
            echo "Fatal error importing font {$fontname}<br/>";
            return false;
        } else {
            echo "{$fontname} imported!<br/>";
        }
    }
    return true;
}
Ejemplo n.º 2
0
 public function listAction()
 {
     $receipt = new \FPDI();
     // PDFの余白(上左右)を設定
     $receipt->SetMargins(0, 0, 0);
     // ヘッダーの出力を無効化
     $receipt->setPrintHeader(false);
     // フッターの出力を無効化
     $receipt->setPrintFooter(false);
     // フォントを登録
     $fontPathRegular = $this->getLibPath() . '/tcpdf/fonts/migmix-2p-regular.ttf';
     //         $regularFont = $receipt->addTTFfont($fontPathRegular, '', '', 32);
     $font = new TCPDF_FONTS();
     $regularFont = $font->addTTFfont($fontPathRegular);
     $fontPathBold = $this->getLibPath() . '/tcpdf/fonts/migmix-2p-bold.ttf';
     //         $boldFont = $receipt->addTTFfont($fontPathBold, '', '', 32);
     $font = new TCPDF_FONTS();
     $boldFont = $font->addTTFfont($fontPathBold);
     // ページを追加
     $receipt->AddPage();
     // テンプレートを読み込み
     //         $receipt->setSourceFile($this->getLibPath() . '/tcpdf/tpl/receipt.pdf');
     //         $receipt->setSourceFile($this->getLibPath() . '/tcpdf/tpl/template.pdf');
     //         $receipt->setSourceFile($this->getLibPath() . '/tcpdf/tpl/w01_1.pdf');
     $receipt->setSourceFile($this->getLibPath() . '/tcpdf/tpl/senijiten.pdf');
     // 読み込んだPDFの1ページ目のインデックスを取得
     $tplIdx = $receipt->importPage(1);
     // 読み込んだPDFの1ページ目をテンプレートとして使用
     $receipt->useTemplate($tplIdx, null, null, null, null, true);
     // 書き込む文字列のフォントを指定
     $receipt->SetFont($regularFont, '', 11);
     // 書き込む文字列の文字色を指定
     $receipt->SetTextColor(0, 0, 255);
     // X : 42mm / Y : 108mm の位置に
     $receipt->SetXY(59, 248);
     // 文字列を書き込む
     $receipt->Write(0, isset($_POST['name']) ? $_POST['name'] . 'さん' : '名無しさん');
     /*         $response = new Response(
                 // Output関数の第一引数にはファイル名、第二引数には出力タイプを指定する
                 // 今回は文字列で返してほしいので、ファイル名はnull、出力タイプは S = String を選択する
                 $receipt->Output(null, 'S'),
                 200,
                 array('content-type' => 'application/pdf')
             );
     
             // レスポンスヘッダーにContent-Dispositionをセットし、ファイル名をreceipt.pdfに指定
             $response->headers->set('Content-Disposition', 'attachment; filename="receipt.pdf"');
     
             return $response;
      */
     //         $receipt->
     $receipt->output('newpdf.pdf', 'I');
 }
Ejemplo n.º 3
0
 /**
  * Get the list of available fonts
  *
  * @return Array of "filename" => "font name"
  **/
 public static function getFontList()
 {
     $list = array();
     $path = TCPDF_FONTS::_getfontpath();
     foreach (glob($path . '/*.php') as $font) {
         unset($name, $type);
         include $font;
         unset($cbbox, $cidinfo, $cw, $dw);
         $font = basename($font, '.php');
         // skip subfonts
         if ((substr($font, -1) == 'b' || substr($font, -1) == 'i') && isset($list[substr($font, 0, -1)])) {
             continue;
         }
         if (substr($font, -2) == 'bi' && isset($list[substr($font, 0, -2)])) {
             continue;
         }
         if (isset($name)) {
             if (isset($type) && $type == 'cidfont0') {
                 // cidfont often have the same name (ArialUnicodeMS)
                 $list[$font] = sprintf(__('%1$s (%2$s)'), $name, $font);
             } else {
                 $list[$font] = $name;
             }
         }
     }
     return $list;
 }
Ejemplo n.º 4
0
 /**
  * @param string $name
  * @return string
  * @see http://www.tcpdf.org/doc/code/classTCPDF__FONTS.html
  */
 public static function installBuiltinFont($name)
 {
     $filename = self::getBuiltinFontPath($name);
     $font_name = \TCPDF_FONTS::addTTFFont($filename, 'TrueTypeUnicode', '', 32);
     static::$installed_builtin_fonts[$name] = $font_name;
     return $font_name;
 }
Ejemplo n.º 5
0
 /**
  * process uploaded font file and convert to format for use with tcpdf
  *
  * @return void
  */
 protected function _afterSave()
 {
     if ($this->getValue()) {
         TCPDF_FONTS::addTTFfont(Mage::getBaseDir('media') . DS . 'pdf-printouts' . DS . $this->getValue());
         //Alternative if encoding of font can't be determined correctly
         //$pdf->addTTFfont(Mage::getBaseDir('media') . DS . 'pdf-printouts' . DS . $this->getValue(),'TrueType','ansi');
     }
 }
Ejemplo n.º 6
0
 public function run($fonts = null)
 {
     if (\Cli::option('help', \Cli::option('h', false)) or empty($fonts)) {
         empty($fonts) and \Cli::error(\Cli::color('No font given.', 'red'));
         return static::help();
     }
     $pdf = new \TCPDF();
     $type = \Cli::option('type', \Cli::option('t', ''));
     $enc = \Cli::option('enc', \Cli::option('e', ''));
     $flags = \Cli::option('flags', \Cli::option('f', 32));
     $outpath = \Cli::option('outpath', \Cli::option('o', K_PATH_FONTS));
     $platid = \Cli::option('platid', \Cli::option('p', 3));
     $encid = \Cli::option('encid', \Cli::option('n', 1));
     $addcbbox = \Cli::option('addcbbox', \Cli::option('b', false));
     $link = \Cli::option('link', \Cli::option('l', false));
     $path = \Cli::option('path', \Cli::option('p'));
     if (!is_null($path) and !\Str::ends_with($path, DS)) {
         $path .= DS;
     }
     $fonts = explode(',', $fonts);
     foreach ($fonts as $font) {
         if (strpos($font, DS) === false and !is_null($path)) {
             $font = $path . $font;
         }
         $fontfile = realpath($font);
         $fontname = \TCPDF_FONTS::addTTFfont($fontfile, $type, $enc, $flags, $outpath, $platid, $encid, $addcbbox, $link);
         if ($fontname == false) {
             $errors = true;
             \Cli::error(\Cli::color($font . ' cannot be added.', 'red'));
         } else {
             \Cli::write(\Cli::color($font . ' added.', 'green'));
         }
     }
     if (!empty($errors)) {
         \Cli::error(\Cli::color('Process finished with errors.', 'red'));
     } else {
         \Cli::write(\Cli::color('Process successfully finished.', 'green'));
     }
 }
Ejemplo n.º 7
0
 function init()
 {
     parent::init();
     $target_dir = DIRECTORY_SEPARATOR . 'var' . DIRECTORY_SEPARATOR . 'www' . DIRECTORY_SEPARATOR . 'html' . DIRECTORY_SEPARATOR . 'xepan2' . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . 'xepan' . DIRECTORY_SEPARATOR . 'commerce' . DIRECTORY_SEPARATOR . 'templates' . DIRECTORY_SEPARATOR . 'fonts' . DIRECTORY_SEPARATOR;
     $target_file = $target_dir . basename($_FILES["fileToUpload"]["name"]);
     $uploadOk = 1;
     $fontFileType = pathinfo($target_file, PATHINFO_EXTENSION);
     // Check if image file is a actual image or fake image
     if (isset($_POST["submit"])) {
         $font_format = explode('-', $target_file);
         if (!in_array($font_format[1], array('Regular.ttf', 'Bold.ttf', 'Italic.ttf', 'BoldItalic.ttf'))) {
             $this->api->js(true, $this->js()->reload())->univ()->errorMessage('Wrong Font name ');
             $uploadOk = 0;
             echo $font_format[1];
         }
         if (file_exists($target_file)) {
             $this->api->js(true)->univ()->errorMessage('File Already Exist');
             $uploadOk = 0;
         }
         if ($fontFileType != "ttf") {
             $this->api->js(true)->univ()->errorMessage('Only ttf file is upload');
             $uploadOk = 0;
         }
         if ($uploadOk == 1) {
             if (move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], $target_file)) {
                 $this->api->js(true, $this->js()->reload())->univ()->successMessage('Font File ' . basename($_FILES["fileToUpload"]["name"] . " has been uploded"));
                 /*TTF File To Convert & create TCPDF Font file*/
                 $pdf = new \TCPDF('l', 'pt', '', true, 'UTF-8', false);
                 $fontname = \TCPDF_FONTS::addTTFfont($target_file, 'TrueTypeUnicode', '', 32);
                 $pdf->AddFont($fontname, '', 14, '', false);
             } else {
                 $this->app->js(true)->univ()->errorMessage('Sorry, there was an error uploading your file');
             }
         }
     }
 }
Ejemplo n.º 8
0
$core_fonts = array('courier', 'courierB', 'courierI', 'courierBI', 'helvetica', 'helveticaB', 'helveticaI', 'helveticaBI', 'times', 'timesB', 'timesI', 'timesBI', 'symbol', 'zapfdingbats');
// set fill color
$pdf->SetFillColor(221, 238, 255);
// create one HTML table for each core font
foreach ($core_fonts as $font) {
    // add a page
    $pdf->AddPage();
    // Cell($w, $h=0, $txt='', $border=0, $ln=0, $align='', $fill=false, $link='', $stretch=0, $ignore_min_height=false, $calign='T', $valign='M')
    // set font for title
    $pdf->SetFont('helvetica', 'B', 16);
    // print font name
    $pdf->Cell(0, 10, 'FONT: ' . $font, 1, 1, 'C', true, '', 0, false, 'T', 'M');
    // set font for chars
    $pdf->SetFont($font, '', 16);
    // print each character
    for ($i = 0; $i < 256; ++$i) {
        if ($i > 0 and $i % 16 == 0) {
            $pdf->Ln();
        }
        $pdf->Cell(11.25, 11.25, TCPDF_FONTS::unichr($i), 1, 0, 'C', false, '', 0, false, 'T', 'M');
    }
    $pdf->Ln(20);
    // print a pangram
    $pdf->Cell(0, 0, 'The quick brown fox jumps over the lazy dog', 0, 1, 'C', false, '', 0, false, 'T', 'M');
}
// ---------------------------------------------------------
//Close and output PDF document
$pdf->Output('example_055.pdf', 'D');
//============================================================+
// END OF FILE
//============================================================+
Ejemplo n.º 9
0
 public function add_font()
 {
     require_once APPPATH . 'libraries/tcpdf/include/tcpdf_fonts.php';
     require APPPATH . 'libraries/tcpdf/tcpdf.php';
     error_reporting(1);
     $fontMaker = new TCPDF_FONTS();
     $font = $fontMaker->addTTFfont($_SERVER['DOCUMENT_ROOT'] . 'js/TEMPSITC_new.TTF');
     $pdfMaker = new TCPDF('L', 'mm', 'A4', true, 'utf-8');
     $pdfMaker->AddPage('L');
     $pdfMaker->SetMargins(0, 0, 0, true);
     $pdfMaker->SetFont($font);
     $pdfMaker->SetFontSize('20');
     $pdfMaker->SetTextColor(0, 0, 0);
     $pdfMaker->Text(10, 10, 'Hello!');
     echo '<pre>';
     print_r($font);
     echo ':)</pre>';
     //$pdfMaker->Output();
 }
Ejemplo n.º 10
0
 /**
  * Returns the PDF string code to print a cell (rectangular area) with optional borders, background color and character string. The upper-left corner of the cell corresponds to the current position. The text can be aligned or centered. After the call, the current position moves to the right or to the next line. It is possible to put a link on the text.<br />
  * If automatic page breaking is enabled and the cell goes beyond the limit, a page break is done before outputting.
  * @param $w (float) Cell width. If 0, the cell extends up to the right margin.
  * @param $h (float) Cell height. Default value: 0.
  * @param $txt (string) String to print. Default value: empty string.
  * @param $border (mixed) Indicates if borders must be drawn around the cell. The value can be a number:<ul><li>0: no border (default)</li><li>1: frame</li></ul> or a string containing some or all of the following characters (in any order):<ul><li>L: left</li><li>T: top</li><li>R: right</li><li>B: bottom</li></ul> or an array of line styles for each border group - for example: array('LTRB' => array('width' => 2, 'cap' => 'butt', 'join' => 'miter', 'dash' => 0, 'color' => array(0, 0, 0)))
  * @param $ln (int) Indicates where the current position should go after the call. Possible values are:<ul><li>0: to the right (or left for RTL languages)</li><li>1: to the beginning of the next line</li><li>2: below</li></ul>Putting 1 is equivalent to putting 0 and calling Ln() just after. Default value: 0.
  * @param $align (string) Allows to center or align the text. Possible values are:<ul><li>L or empty string: left align (default value)</li><li>C: center</li><li>R: right align</li><li>J: justify</li></ul>
  * @param $fill (boolean) Indicates if the cell background must be painted (true) or transparent (false).
  * @param $link (mixed) URL or identifier returned by AddLink().
  * @param $stretch (int) font stretch mode: <ul><li>0 = disabled</li><li>1 = horizontal scaling only if text is larger than cell width</li><li>2 = forced horizontal scaling to fit cell width</li><li>3 = character spacing only if text is larger than cell width</li><li>4 = forced character spacing to fit cell width</li></ul> General font stretching and scaling values will be preserved when possible.
  * @param $ignore_min_height (boolean) if true ignore automatic minimum height value.
  * @param $calign (string) cell vertical alignment relative to the specified Y value. Possible values are:<ul><li>T : cell top</li><li>C : center</li><li>B : cell bottom</li><li>A : font top</li><li>L : font baseline</li><li>D : font bottom</li></ul>
  * @param $valign (string) text vertical alignment inside the cell. Possible values are:<ul><li>T : top</li><li>M : middle</li><li>B : bottom</li></ul>
  * @return string containing cell code
  * @protected
  * @since 1.0
  * @see Cell()
  */
 protected function getCellCode($w, $h = 0, $txt = '', $border = 0, $ln = 0, $align = '', $fill = false, $link = '', $stretch = 0, $ignore_min_height = false, $calign = 'T', $valign = 'M')
 {
     // replace 'NO-BREAK SPACE' (U+00A0) character with a simple space
     $txt = str_replace(TCPDF_FONTS::unichr(160, $this->isunicode), ' ', $txt);
     $prev_cell_margin = $this->cell_margin;
     $prev_cell_padding = $this->cell_padding;
     $txt = TCPDF_STATIC::removeSHY($txt, $this->isunicode);
     $rs = '';
     //string to be returned
     $this->adjustCellPadding($border);
     if (!$ignore_min_height) {
         $min_cell_height = $this->getCellHeight($this->FontSize);
         if ($h < $min_cell_height) {
             $h = $min_cell_height;
         }
     }
     $k = $this->k;
     // check page for no-write regions and adapt page margins if necessary
     list($this->x, $this->y) = $this->checkPageRegions($h, $this->x, $this->y);
     if ($this->rtl) {
         $x = $this->x - $this->cell_margin['R'];
     } else {
         $x = $this->x + $this->cell_margin['L'];
     }
     $y = $this->y + $this->cell_margin['T'];
     $prev_font_stretching = $this->font_stretching;
     $prev_font_spacing = $this->font_spacing;
     // cell vertical alignment
     switch ($calign) {
         case 'A':
             // font top
             switch ($valign) {
                 case 'T':
                     // top
                     $y -= $this->cell_padding['T'];
                     break;
                 case 'B':
                     // bottom
                     $y -= $h - $this->cell_padding['B'] - $this->FontAscent - $this->FontDescent;
                     break;
                 default:
                 case 'C':
                 case 'M':
                     // center
                     $y -= ($h - $this->FontAscent - $this->FontDescent) / 2;
                     break;
             }
             break;
         case 'L':
             // font baseline
             switch ($valign) {
                 case 'T':
                     // top
                     $y -= $this->cell_padding['T'] + $this->FontAscent;
                     break;
                 case 'B':
                     // bottom
                     $y -= $h - $this->cell_padding['B'] - $this->FontDescent;
                     break;
                 default:
                 case 'C':
                 case 'M':
                     // center
                     $y -= ($h + $this->FontAscent - $this->FontDescent) / 2;
                     break;
             }
             break;
         case 'D':
             // font bottom
             switch ($valign) {
                 case 'T':
                     // top
                     $y -= $this->cell_padding['T'] + $this->FontAscent + $this->FontDescent;
                     break;
                 case 'B':
                     // bottom
                     $y -= $h - $this->cell_padding['B'];
                     break;
                 default:
                 case 'C':
                 case 'M':
                     // center
                     $y -= ($h + $this->FontAscent + $this->FontDescent) / 2;
                     break;
             }
             break;
         case 'B':
             // cell bottom
             $y -= $h;
             break;
         case 'C':
         case 'M':
             // cell center
             $y -= $h / 2;
             break;
         default:
         case 'T':
             // cell top
             break;
     }
     // text vertical alignment
     switch ($valign) {
         case 'T':
             // top
             $yt = $y + $this->cell_padding['T'];
             break;
         case 'B':
             // bottom
             $yt = $y + $h - $this->cell_padding['B'] - $this->FontAscent - $this->FontDescent;
             break;
         default:
         case 'C':
         case 'M':
             // center
             $yt = $y + ($h - $this->FontAscent - $this->FontDescent) / 2;
             break;
     }
     $basefonty = $yt + $this->FontAscent;
     if (TCPDF_STATIC::empty_string($w) or $w <= 0) {
         if ($this->rtl) {
             $w = $x - $this->lMargin;
         } else {
             $w = $this->w - $this->rMargin - $x;
         }
     }
     $s = '';
     // fill and borders
     if (is_string($border) and strlen($border) == 4) {
         // full border
         $border = 1;
     }
     if ($fill or $border == 1) {
         if ($fill) {
             $op = $border == 1 ? 'B' : 'f';
         } else {
             $op = 'S';
         }
         if ($this->rtl) {
             $xk = ($x - $w) * $k;
         } else {
             $xk = $x * $k;
         }
         $s .= sprintf('%F %F %F %F re %s ', $xk, ($this->h - $y) * $k, $w * $k, -$h * $k, $op);
     }
     // draw borders
     $s .= $this->getCellBorder($x, $y, $w, $h, $border);
     if ($txt != '') {
         $txt2 = $txt;
         if ($this->isunicode) {
             $txt2 = $this->UTF8ToLatin2($txt2, $this->isunicode);
         }
         $txt2 = TCPDF_STATIC::_escape($txt2);
         // get current text width (considering general font stretching and spacing)
         $txwidth = $this->GetStringWidth($txt);
         $width = $txwidth;
         // check for stretch mode
         if ($stretch > 0) {
             // calculate ratio between cell width and text width
             if ($width <= 0) {
                 $ratio = 1;
             } else {
                 $ratio = ($w - $this->cell_padding['L'] - $this->cell_padding['R']) / $width;
             }
             // check if stretching is required
             if ($ratio < 1 or $ratio > 1 and $stretch % 2 == 0) {
                 // the text will be stretched to fit cell width
                 if ($stretch > 2) {
                     // set new character spacing
                     $this->font_spacing += ($w - $this->cell_padding['L'] - $this->cell_padding['R'] - $width) / (max($this->GetNumChars($txt) - 1, 1) * ($this->font_stretching / 100));
                 } else {
                     // set new horizontal stretching
                     $this->font_stretching *= $ratio;
                 }
                 // recalculate text width (the text fills the entire cell)
                 $width = $w - $this->cell_padding['L'] - $this->cell_padding['R'];
                 // reset alignment
                 $align = '';
             }
         }
         if ($this->font_stretching != 100) {
             // apply font stretching
             $rs .= sprintf('BT %F Tz ET ', $this->font_stretching);
         }
         if ($this->font_spacing != 0) {
             // increase/decrease font spacing
             $rs .= sprintf('BT %F Tc ET ', $this->font_spacing * $this->k);
         }
         if ($this->ColorFlag and $this->textrendermode < 4) {
             $s .= 'q ' . $this->TextColor . ' ';
         }
         // rendering mode
         $s .= sprintf('BT %d Tr %F w ET ', $this->textrendermode, $this->textstrokewidth * $this->k);
         // count number of spaces
         $ns = substr_count($txt, chr(32));
         // Justification
         $spacewidth = 0;
         if ($align == 'J' and $ns > 0) {
             if ($this->isUnicodeFont()) {
                 // get string width without spaces
                 $width = $this->GetStringWidth(str_replace(' ', '', $txt));
                 // calculate average space width
                 $spacewidth = -1000 * ($w - $width - $this->cell_padding['L'] - $this->cell_padding['R']) / ($ns ? $ns : 1) / ($this->FontSize ? $this->FontSize : 1);
                 if ($this->font_stretching != 100) {
                     // word spacing is affected by stretching
                     $spacewidth /= $this->font_stretching / 100;
                 }
                 // set word position to be used with TJ operator
                 $txt2 = str_replace(chr(0) . chr(32), ') ' . sprintf('%F', $spacewidth) . ' (', $txt2);
                 $unicode_justification = true;
             } else {
                 // get string width
                 $width = $txwidth;
                 // new space width
                 $spacewidth = ($w - $width - $this->cell_padding['L'] - $this->cell_padding['R']) / ($ns ? $ns : 1) * $this->k;
                 if ($this->font_stretching != 100) {
                     // word spacing (Tw) is affected by stretching
                     $spacewidth /= $this->font_stretching / 100;
                 }
                 // set word spacing
                 $rs .= sprintf('BT %F Tw ET ', $spacewidth);
             }
             $width = $w - $this->cell_padding['L'] - $this->cell_padding['R'];
         }
         // replace carriage return characters
         $txt2 = str_replace("\r", ' ', $txt2);
         switch ($align) {
             case 'C':
                 $dx = ($w - $width) / 2;
                 break;
             case 'R':
                 if ($this->rtl) {
                     $dx = $this->cell_padding['R'];
                 } else {
                     $dx = $w - $width - $this->cell_padding['R'];
                 }
                 break;
             case 'L':
                 if ($this->rtl) {
                     $dx = $w - $width - $this->cell_padding['L'];
                 } else {
                     $dx = $this->cell_padding['L'];
                 }
                 break;
             case 'J':
             default:
                 if ($this->rtl) {
                     $dx = $this->cell_padding['R'];
                 } else {
                     $dx = $this->cell_padding['L'];
                 }
                 break;
         }
         if ($this->rtl) {
             $xdx = $x - $dx - $width;
         } else {
             $xdx = $x + $dx;
         }
         $xdk = $xdx * $k;
         // print text
         $s .= sprintf('BT %F %F Td [(%s)] TJ ET', $xdk, ($this->h - $basefonty) * $k, $txt2);
         if (isset($uniblock)) {
             // print overlapping characters as separate string
             $xshift = 0;
             // horizontal shift
             $ty = ($this->h - $basefonty + 0.2 * $this->FontSize) * $k;
             $spw = ($w - $txwidth - $this->cell_padding['L'] - $this->cell_padding['R']) / ($ns ? $ns : 1);
             foreach ($uniblock as $uk => $uniarr) {
                 if ($uk % 2 == 0) {
                     // x space to skip
                     if ($spacewidth != 0) {
                         // justification shift
                         $xshift += count(array_keys($uniarr, 32)) * $spw;
                     }
                     $xshift += $this->GetArrStringWidth($uniarr);
                     // + shift justification
                 } else {
                     // character to print
                     $topchr = TCPDF_FONTS::arrUTF8ToUTF16BE($uniarr, false);
                     $topchr = TCPDF_STATIC::_escape($topchr);
                     $s .= sprintf(' BT %F %F Td [(%s)] TJ ET', $xdk + $xshift * $k, $ty, $topchr);
                 }
             }
         }
         if ($this->underline) {
             $s .= ' ' . $this->_dounderlinew($xdx, $basefonty, $width);
         }
         if ($this->linethrough) {
             $s .= ' ' . $this->_dolinethroughw($xdx, $basefonty, $width);
         }
         if ($this->overline) {
             $s .= ' ' . $this->_dooverlinew($xdx, $basefonty, $width);
         }
         if ($this->ColorFlag and $this->textrendermode < 4) {
             $s .= ' Q';
         }
         if ($link) {
             $this->Link($xdx, $yt, $width, $this->FontAscent + $this->FontDescent, $link, $ns);
         }
     }
     // output cell
     if ($s) {
         // output cell
         $rs .= $s;
         if ($this->font_spacing != 0) {
             // reset font spacing mode
             $rs .= ' BT 0 Tc ET';
         }
         if ($this->font_stretching != 100) {
             // reset font stretching mode
             $rs .= ' BT 100 Tz ET';
         }
     }
     // reset word spacing
     if (!$this->isUnicodeFont() and $align == 'J') {
         $rs .= ' BT 0 Tw ET';
     }
     // reset stretching and spacing
     $this->font_stretching = $prev_font_stretching;
     $this->font_spacing = $prev_font_spacing;
     $this->lasth = $h;
     if ($ln > 0) {
         //Go to the beginning of the next line
         $this->y = $y + $h + $this->cell_margin['B'];
         if ($ln == 1) {
             if ($this->rtl) {
                 $this->x = $this->w - $this->rMargin;
             } else {
                 $this->x = $this->lMargin;
             }
         }
     } else {
         // go left or right by case
         if ($this->rtl) {
             $this->x = $x - $w - $this->cell_margin['L'];
         } else {
             $this->x = $x + $w + $this->cell_margin['R'];
         }
     }
     $gstyles = '' . $this->linestyleWidth . ' ' . $this->linestyleCap . ' ' . $this->linestyleJoin . ' ' . $this->linestyleDash . ' ' . $this->DrawColor . ' ' . $this->FillColor . "\n";
     $rs = $gstyles . $rs;
     $this->cell_padding = $prev_cell_padding;
     $this->cell_margin = $prev_cell_margin;
     return $rs;
 }
 /**
  * Export a PDF report for a project
  *
  * @param \GIB\GradingTool\Domain\Model\Project $project
  */
 public function exportReportAction(\GIB\GradingTool\Domain\Model\Project $project)
 {
     // access check
     $this->checkOwnerOrAdministratorAndDenyIfNeeded($project);
     // The processed submission
     $submission = $this->submissionService->getProcessedSubmission($project);
     if ($submission['hasError']) {
         // Don't export the Grading if is has errors
         $message = new \TYPO3\Flow\Error\Message('The Grading has errors and therefore it cannot be exported. Review and correct the Grading.', \TYPO3\Flow\Error\Message::SEVERITY_ERROR);
         $this->flashMessageContainer->addMessage($message);
         $this->redirect('index', 'Standard');
     }
     // The flat data sheet
     $dataSheet = $this->dataSheetService->getFlatProcessedDataSheet($project);
     $pdf = new \GIB\GradingTool\Utility\TcPdf();
     // set font
     \TCPDF_FONTS::addTTFfont('resource://GIB.GradingTool/Private/Fonts/Cambria.ttf', 'TrueTypeUnicode');
     \TCPDF_FONTS::addTTFfont('resource://GIB.GradingTool/Private/Fonts/Cambria Bold.ttf', 'TrueTypeUnicode');
     \TCPDF_FONTS::addTTFfont('resource://GIB.GradingTool/Private/Fonts/Cambria Italic.ttf', 'TrueTypeUnicode');
     \TCPDF_FONTS::addTTFfont('resource://GIB.GradingTool/Private/Fonts/Cambria Bold Italic.ttf', 'TrueTypeUnicode');
     // set margins
     $pdf->SetMargins(20, 45);
     $pdf->SetHeaderMargin(20);
     $pdf->SetFooterMargin(20);
     $pdf->SetFont('Cambria', '', 10);
     $pdf->SetHeaderFont(array('Cambria', '', 10));
     $pdf->SetFooterFont(array('Cambria', '', 10));
     $pdf->setHtmlVSpace(array('h1' => array(array('h' => 0, 'n' => 0), array('h' => 0, 'n' => 0)), 'h2' => array(array('h' => 0, 'n' => 0), array('h' => 0, 'n' => 0)), 'h3' => array(array('h' => 0, 'n' => 0), array('h' => 1, 'n' => 3)), 'h6' => array(array('h' => 0, 'n' => 0), array('h' => 0, 'n' => 0)), 'p' => array(array('h' => 0, 'n' => 0), array('h' => 1, 'n' => 2.5)), 'ul' => array(array('h' => 0, 'n' => 0), array('h' => 1, 'n' => 2.5))));
     $pdf->setListIndentWidth(3);
     $pdf->SetPrintHeader(TRUE);
     $pdf->SetPrintFooter(TRUE);
     // set document information
     $pdf->SetCreator(PDF_CREATOR);
     $pdf->SetAuthor('Global Infrastructure Basel Foundation');
     $pdf->SetTitle($project->getProjectTitle());
     $pdf->projectTitle = $project->getProjectTitle();
     $pdf->exportDate = strftime('%Y-%m-%d');
     // set auto page breaks
     $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
     // set image scale factor
     $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
     // Must be an Illustrator 3 file
     $epsLogoResource = 'resource://GIB.GradingTool/Private/Images/logo_gib_print.eps';
     // one pixel png
     $onePixelResource = 'resource://GIB.GradingTool/Private/Images/one-pixel.png';
     // partners png
     $gibPartnersResource = 'resource://GIB.GradingTool/Private/Images/gib-partners.png';
     /*** FRONT PAGE ***/
     $pdf->addPage();
     $arguments = array('dataSheet' => $dataSheet, 'project' => $project, 'epsLogoResource' => $epsLogoResource, 'onePixelResource' => $onePixelResource);
     $pdf->writeHTML($this->pdfTemplateRenderer('Front', $arguments), TRUE, FALSE, TRUE);
     /*** PARTNERS PAGE ***/
     $pdf->addPage();
     $arguments = array('gibPartnersResource' => $gibPartnersResource, 'onePixelResource' => $onePixelResource);
     $pdf->writeHTML($this->pdfTemplateRenderer('Partners', $arguments), TRUE, FALSE, TRUE);
     /*** TOC PAGE IS INSERTED AT PAGE 3 ***/
     /*** DATA SHEET FRONT ***/
     $pdf->addPage();
     $pdf->SetAutoPageBreak(FALSE);
     $arguments = array('onePixelResource' => $onePixelResource);
     $pdf->writeHTML($this->pdfTemplateRenderer('DataSheetFront', $arguments), TRUE, FALSE, TRUE);
     $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
     /*** DATA SHEET ***/
     $pdf->addPage();
     $arguments = array('dataSheet' => $dataSheet, 'project' => $project, 'onePixelResource' => $onePixelResource);
     $pdf->writeHTML($this->pdfTemplateRenderer('DataSheet', $arguments), TRUE, FALSE, TRUE);
     /*** GRADING FRONT ***/
     $pdf->addPage();
     $pdf->SetAutoPageBreak(FALSE);
     $arguments = array('onePixelResource' => $onePixelResource);
     $pdf->writeHTML($this->pdfTemplateRenderer('GradingFront', $arguments), TRUE, FALSE, TRUE);
     $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
     /*** GRADING TOOL ***/
     $pdf->addPage();
     $arguments = array('submission' => $submission, 'project' => $project, 'scoreData' => $this->submissionService->getScoreData(), 'onePixelResource' => $onePixelResource);
     $pdf->writeHTML($this->pdfTemplateRenderer('Grading', $arguments), TRUE, FALSE, TRUE);
     /*** ANALYSIS FRONT ***/
     $pdf->addPage();
     $pdf->SetAutoPageBreak(FALSE);
     $arguments = array('onePixelResource' => $onePixelResource);
     $pdf->writeHTML($this->pdfTemplateRenderer('AnalysisFront', $arguments), TRUE, FALSE, TRUE);
     $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
     /*** ANALYSIS ***/
     $pdf->addPage();
     $radarChartFileName = $this->submissionService->getRadarImage($project);
     $lineGraphFileName = $this->submissionService->getLineGraphImage($project);
     $answerLevelGraphFileName = $this->submissionService->getAnswerLevelBarChartImage($project);
     $arguments = array('radarChartFileName' => $radarChartFileName, 'lineGraphFileName' => $lineGraphFileName, 'answerLevelGraphFileName' => $answerLevelGraphFileName, 'onePixelResource' => $onePixelResource, 'submission' => $submission);
     $pdf->writeHTML($this->pdfTemplateRenderer('Analysis', $arguments), TRUE, FALSE, TRUE);
     /** This was the last page */
     $pdf->lastPage();
     /*** TOC PAGE ***/
     $pdf->addTOCPage();
     $arguments = array('dataSheet' => $dataSheet, 'project' => $project, 'onePixelResource' => $onePixelResource);
     $pdf->writeHTML($this->pdfTemplateRenderer('TOCBeforeTOC', $arguments), TRUE, FALSE, TRUE);
     $arguments = array('onePixelResource' => $onePixelResource);
     $afterContent = $this->pdfTemplateRenderer('TOCAfterTOC', $arguments);
     $bookmarkTemplates = array();
     $bookmarkTemplates[0] = '<style>td.blue { color: #0f4fa2; }	td.orange { color: #f36e21; } td.red { color: #c92938; } td.black { color: #000000; } td.grey { color: #555555; }</style><table border="0" cellpadding="0" cellspacing="0"><tr><td class="#TOC_CSSCLASS#" width="12%"><strong>#TOC_CHAPTERNUMBER#</strong></td><td class="black" width="78%"><strong>#TOC_DESCRIPTION#</strong></td><td width="10%"><span style="font-weight:bold;font-size:10pt;text-align:right;" align="right">#TOC_PAGE_NUMBER#</span></td></tr></table>';
     $bookmarkTemplates[1] = '<style>td.blue { color: #0f4fa2; }	td.orange { color: #f36e21; } td.red { color: #c92938; } td.black { color: #000000; } td.grey { color: #555555; }</style><table border="0" cellpadding="0" cellspacing="0"><tr><td class="#TOC_CSSCLASS#" width="12%"><strong>#TOC_CHAPTERNUMBER#</strong></td><td class="grey" width="78%">#TOC_DESCRIPTION#</td><td width="10%"><span style="font-size:10pt;text-align:right;" align="right">#TOC_PAGE_NUMBER#</span></td></tr></table>';
     $pdf->addHTMLTOC(3, 'INDEX', $bookmarkTemplates, TRUE, 'B', array(128, 0, 0), $afterContent);
     $pdf->endTOCPage();
     $pdf->Output('export.pdf', 'I');
 }
Ejemplo n.º 12
0
 protected function init()
 {
     //set image scale factor
     $this->setImageScale(PDF_IMAGE_SCALE_RATIO);
     $this->SetDrawColor(125, 165, 65);
     $this->SetFillColor(248, 248, 248);
     $this->SetTextColor(0, 0, 0);
     $this->getAliasNbPages();
     $this->setJPEGQuality(100);
     $this->SetMargins(30, 60, 30);
     if (!empty(\GO::config()->tcpdf_font)) {
         $this->font = \GO::config()->tcpdf_font;
     }
     if (!empty(\GO::config()->tcpdf_ttf_font)) {
         $this->font = \TCPDF_FONTS::addTTFfont(\GO::config()->tcpdf_ttf_font);
         //$this->font=  TCPDF_FONTS::addTTFfont(\GO::config()->tcpdf_ttf_font,'TrueType'); // 2nd parameter is normally autodetected but sometimes this goes wrong.
     }
     if (!empty(\GO::config()->tcpdf_font_size)) {
         $this->font_size = \GO::config()->tcpdf_font_size;
     }
     $this->SetFont($this->font, '', $this->font_size);
     $this->pageWidth = $this->getPageWidth() - $this->lMargin - $this->rMargin;
     $this->SetAutoPageBreak(true, 30);
     // set font
     $this->SetFont($this->font, '', $this->font_size);
 }
Ejemplo n.º 13
0
 /**
  * Scans K_PATH_MAIN.'fonts/' folder and moves all files to $this->_getfontpath() folder
  * Added ablity to use TTF fonts (functionality taken from newer version of TCPDF)
  * @uses TCPDF_FONTS::addTTFfont()
  * @uses wp_cache_get()
  * @uses wp_cache_set()
  * @return type
  * @author odokienko@UD
  * @since 1.37.6
  */
 protected function getFontsList()
 {
     $fontlist = wp_cache_get('fontlist', 'wpi_pdf_data');
     if (!empty($fontlist)) {
         $this->fontlist = $fontlist;
         return;
     }
     $uploads_fontsdir_name = $this->_getfontpath();
     if (!is_dir($uploads_fontsdir_name)) {
         @mkdir($uploads_fontsdir_name, 0777, true);
     }
     if (is_dir(K_PATH_MAIN . 'fonts/')) {
         $base_fontsdir = opendir(K_PATH_MAIN . 'fonts/');
         while (($file = readdir($base_fontsdir)) !== false) {
             if ($file == '.' || $file == '..' || file_exists($uploads_fontsdir_name . '/' . $file)) {
                 continue;
             }
             copy(K_PATH_MAIN . 'fonts/' . $file, $uploads_fontsdir_name . '/' . $file);
         }
         closedir($base_fontsdir);
     }
     $uploads_fontsdir = opendir($uploads_fontsdir_name);
     while (($file = readdir($uploads_fontsdir)) !== false) {
         if (strtolower(substr($file, -4)) == '.ttf') {
             include_once 'tcpdf_fonts.php';
             include_once 'tcpdf_static.php';
             $fontname = TCPDF_FONTS::addTTFfont($uploads_fontsdir_name . '/' . $file, '', '', 96, $uploads_fontsdir_name);
             if ($fontname) {
                 array_push($this->fontlist, $fontname);
                 unlink($uploads_fontsdir_name . '/' . $file);
             }
         }
         if (substr($file, -4) == '.php') {
             array_push($this->fontlist, strtolower(basename($file, '.php')));
         }
     }
     wp_cache_add('fontlist', $this->fontlist, 'wpi_pdf_data');
 }
Ejemplo n.º 14
0
/**
 * [getPdfFile generate and save PDF file]
 * @param  int $idSpec
 * @return str or false
 */
function getPdfFile($idSpec)
{
    $arSpecification = getSpecification($idSpec);
    if ($arSpecification) {
        $allSumSpec = "";
        foreach ($arSpecification["ITEMS"] as $key => $arItems) {
            $allSumSpec += $arItems["DISCOUNT"]["PRICE"] * $arItems["PROPERTY_COUNT_VALUE"];
            $totalPrice += $arItems["DISCOUNT"]["DISCOUNT_PRICE"] * $arItems["PROPERTY_COUNT_VALUE"];
            $allDisSpec += $arItems["DISCOUNT"]["PRICE"] - $arItems["DISCOUNT"]["DISCOUNT_PRICE"];
            $allSumminDisSpec += $arItems["DISCOUNT"]["DISCOUNT_PRICE"] * $arItems["PROPERTY_COUNT_VALUE"];
        }
        include_once $_SERVER["DOCUMENT_ROOT"] . "/bitrix/php_interface/include/tcpdf/tcpdf.php";
        $curDate = date("d.m.Y H:i:s");
        global $USER;
        $name = $USER->GetFirstName() . "_" . $USER->GetLastName() . "_" . str_replace(" ", "_", $arSpecification["NAME"]) . "_" . $curDate;
        $nameFile = CUtil::translit($name, "ru", translitParams());
        // create new PDF document
        $pdf = new TCPDF('P', 'mm', 'A4', true, 'UTF-8', false);
        $fontname = TCPDF_FONTS::addTTFfont($_SERVER["DOCUMENT_ROOT"] . "/bitrix/php_interface/include/tcpdf/font_arial/arial.ttf", '', '', 32);
        // set document information
        $pdf->SetAuthor($USER->GetFirstName() . " " . $USER->GetLastName());
        $pdf->SetTitle("Спецификация " . $arSpecification["NAME"]);
        // set font
        $pdf->SetFont($fontname, 'BI', 12);
        // add a page
        $pdf->AddPage();
        $text = "Спецификация: №" . $arSpecification["ID"];
        $pdf->Write(0, $text, '', 0, 'L', true, 0, false, false, 0);
        $text = "Дизайнер: " . $USER->GetFirstName() . " " . $USER->GetLastName();
        $pdf->Write(0, $text, '', 0, 'L', true, 0, false, false, 0);
        $text = "Название спецификации: " . $arSpecification["NAME"];
        $pdf->Write(0, $text, '', 0, 'L', true, 0, false, false, 0);
        $text = "Стоимость товаров: " . number_format($allSumSpec, 0, 0, " ") . " руб.";
        $pdf->Write(0, $text, '', 0, 'L', true, 0, false, false, 0);
        $text = "Со скидкой: " . number_format($allSumminDisSpec, 0, 0, " ") . " руб.";
        $pdf->Write(0, $text, '', 0, 'L', true, 0, false, false, 0);
        $text = "Экономия: " . number_format($allDisSpec, 0, 0, " ") . " руб.";
        $pdf->Write(0, $text, '', 0, 'L', true, 0, false, false, 0);
        $text = "ИТОГО: " . number_format($totalPrice, 0, 0, " ") . " руб.";
        $pdf->Write(0, $text, '', 0, 'L', true, 0, false, false, 0);
        $text = "Продукты:";
        $pdf->Write(0, $text, '', 0, 'L', true, 0, false, false, 0);
        foreach ($arSpecification["ITEMS"] as $key => $arItems) {
            $text = $key + 1 . ". Артикул: " . $arItems["PRODUCT"]["PROPERTY_ARTIKUL_VALUE"];
            $pdf->Write(0, $text, '', 0, 'L', true, 0, false, false, 0);
            $text = "    Идентификатор продукта: " . $arItems["PRODUCT"]["ID"];
            $pdf->Write(0, $text, '', 0, 'L', true, 0, false, false, 0);
            $text = "    Название: " . $arItems["PRODUCT"]["NAME"];
            $pdf->Write(0, $text, '', 0, 'L', true, 0, false, false, 0);
            $text = "    Цена: " . number_format($arItems["DISCOUNT"]["DISCOUNT_PRICE"], 0, 0, " ") . " руб.";
            $pdf->Write(0, $text, '', 0, 'L', true, 0, false, false, 0);
            $text = "    Количество: " . $arItems["PROPERTY_COUNT_VALUE"];
            $pdf->Write(0, $text, '', 0, 'L', true, 0, false, false, 0);
        }
        $filePath = $_SERVER["DOCUMENT_ROOT"] . "/upload/spec_files/" . $nameFile . ".pdf";
        $path = "/upload/spec_files/" . $nameFile . ".pdf";
        //Close and save PDF document
        $pdf->Output($filePath, 'F');
        return $path;
    }
    return false;
}
Ejemplo n.º 15
0
 public function save_design()
 {
     if ($this->input->post('mode') == 'edit') {
         $this->db->delete('designs', array('id' => $this->input->post('design_id')));
     }
     $faceMacket = str_replace('http://klever.media/', '', $this->input->post('faceMacket'));
     $backMacket = str_replace('http://klever.media/', '', $this->input->post('backMacket'));
     $face = $this->input->post('face');
     $back = $this->input->post('back');
     // get all fonts
     $query = $this->db->get('fonts');
     $fonts = array();
     foreach ($query->result() as $font) {
         $fonts[$font->family] = $font->source;
     }
     // generate pdf face template name and preview name
     $face_pdf = 'uploads/redactor/face_' . md5(microtime(true)) . '.pdf';
     $face_preview = 'uploads/redactor/face_' . md5(microtime(true)) . '.jpg';
     // convert face image to pdf
     $img = new Imagick($faceMacket);
     $img->setresolution(300, 300);
     $img->setcolorspace(Imagick::COLORSPACE_CMYK);
     $img->resizeimage(1076, 720, Imagick::FILTER_LANCZOS, 1);
     $img->setimageformat('pdf');
     $img->writeimage($face_pdf);
     // include TCPDF ana FPDI
     include_once APPPATH . 'libraries/tcpdf/tcpdf.php';
     include_once APPPATH . 'libraries/tcpdf/fpdi.php';
     include_once APPPATH . 'libraries/tcpdf/include/tcpdf_fonts.php';
     $fontMaker = new TCPDF_FONTS();
     // создаём лист
     $pdf = new FPDI('L', 'mm', array(91, 61), true, 'UTF-8', false);
     $pdf->SetMargins(0, 0, 0, true);
     $pdf->AddPage('L');
     // загрузим ранее сохранённый шаблон
     $pdf->setSourceFile($face_pdf);
     $pdf->SetMargins(0, 0, 0, true);
     $tplIdx = $pdf->importPage(1);
     $pdf->useTemplate($tplIdx, null, null, 0, 0, true);
     // установим опции для pdf
     $pdf->setCellHeightRatio(1);
     $pdf->setCellPaddings(0, 0, 0, 0);
     $pdf->setCellMargins(0, 0, 0, 0);
     $pdf->SetAutoPageBreak(false, 0);
     $pdf->SetPrintHeader(false);
     $pdf->SetPrintFooter(false);
     if (!empty($face)) {
         // отрисуем сначала изображения лица
         foreach ($face as $item) {
             if ($item['type'] == 'image') {
                 $pdf->Image($_SERVER['DOCUMENT_ROOT'] . '/' . str_replace('http://klever.media/', '', $item['content']), $this->px_to_mm($item['left']), $this->px_to_mm($item['top']), $this->px_to_mm($item['width']), '', '', '', '', false, 300);
             }
         }
         // потом текст на лице
         foreach ($face as $item) {
             if ($item['type'] == 'text') {
                 $cmyk = $this->rgbToCmyk($item['color']);
                 $pdf->SetTextColor($cmyk['c'] * 100, $cmyk['m'] * 100, $cmyk['y'] * 100, $cmyk['k'] * 100);
                 // set font
                 $tcpdfFont = $fontMaker->addTTFfont(realpath('fonts/redactor/' . $fonts[$item['font']]));
                 $pdf->SetFont($tcpdfFont, '', $item['size'] / 2, '', 'false');
                 $pdf->Text($this->px_to_mm($item['left']), $this->px_to_mm($item['top']), $item['content'], false, false, true, 0, 0, 'L', false, '', 0, false, 'T', 'L', false);
             }
         }
     }
     // сохраним пдф лица
     $pdf->Output($_SERVER['DOCUMENT_ROOT'] . '/' . $face_pdf, 'F');
     // сделаем превью для пользователя
     $im = new Imagick();
     $im->setResolution(300, 300);
     $im->readimage($face_pdf . '[0]');
     $im->flattenimages();
     $im->setImageFormat('jpg');
     $im->resizeimage(1076, 720, Imagick::FILTER_LANCZOS, 1);
     $im->writeImage($face_preview);
     $im->clear();
     $im->destroy();
     //exec('$ convert ' . $_SERVER['DOCUMENT_ROOT'] . '/' . $face_pdf . ' ' . $_SERVER['DOCUMENT_ROOT'] . '/' . $face_preview);
     // есть ли оборот
     if (!empty($backMacket)) {
         // generate pdf back template name and preview name
         $back_pdf = 'uploads/redactor/back_' . md5(microtime(true)) . '.pdf';
         $back_preview = 'uploads/redactor/back_' . md5(microtime(true)) . '.jpg';
         // convert back image to pdf
         $img = new Imagick($backMacket);
         $img->setresolution(300, 300);
         $img->setcolorspace(Imagick::COLORSPACE_CMYK);
         $img->resizeimage(1076, 720, Imagick::FILTER_LANCZOS, 1);
         $img->setimageformat('pdf');
         $img->writeimage($back_pdf);
         // создаём лист
         $pdf = new FPDI('L', 'mm', array(91, 61), true, 'UTF-8', false);
         $pdf->AddPage('L');
         // загрузим ранее сохранённый шаблон
         $pdf->setSourceFile($_SERVER['DOCUMENT_ROOT'] . '/' . $back_pdf);
         $pdf->SetMargins(0, 0, 0, true);
         $tplIdx = $pdf->importPage(1);
         $pdf->useTemplate($tplIdx, null, null, 0, 0, true);
         // установим опции для pdf
         $pdf->SetMargins(0, 0, 0, true);
         $pdf->setCellHeightRatio(1);
         $pdf->setCellPaddings(0, 0, 0, 0);
         $pdf->setCellMargins(1, 1, 1, 1);
         $pdf->SetAutoPageBreak(false);
         $pdf->SetPrintHeader(false);
         $pdf->SetPrintFooter(false);
         if (!empty($back)) {
             // отрисуем сначала изображения оборота
             foreach ($back as $item) {
                 if ($item['type'] == 'image') {
                     $pdf->Image($_SERVER['DOCUMENT_ROOT'] . '/' . str_replace('http://klever.media/', '', $item['content']), $this->px_to_mm($item['left']), $this->px_to_mm($item['top']), $this->px_to_mm($item['width']), '', '', '', '', false, 300);
                 }
             }
             // потом текст на обороте
             foreach ($back as $item) {
                 if ($item['type'] == 'text') {
                     $cmyk = $this->rgbToCmyk($item['color']);
                     $pdf->SetTextColor($cmyk['c'] * 100, $cmyk['m'] * 100, $cmyk['y'] * 100, $cmyk['k'] * 100);
                     // set font
                     $tcpdfFont = $fontMaker->addTTFfont($_SERVER['DOCUMENT_ROOT'] . '/fonts/redactor/' . $fonts[$item['font']]);
                     $pdf->SetFont($tcpdfFont, '', $item['size'] / 2, '', 'false');
                     $pdf->Text($this->px_to_mm($item['left']), $this->px_to_mm($item['top']), $item['content'], false, false, true, 0, 0, 'L', false, '', 0, false, 'T', 'L', false);
                 }
             }
         }
         // сохраним пдф оборота
         $pdf->Output($_SERVER['DOCUMENT_ROOT'] . '/' . $back_pdf, 'F');
         // сделаем превью для пользователя
         $im = new Imagick();
         $im->setResolution(300, 300);
         $im->readimage($back_pdf . '[0]');
         $im->setImageFormat('jpg');
         $im->flattenimages();
         $im->resizeimage(1076, 720, Imagick::FILTER_LANCZOS, 1);
         $im->writeImage($back_preview);
         $im->clear();
         $im->destroy();
     }
     $this->db->insert('products', array('name' => 'cards_pvc', 'tiraj' => 100, 'weight' => 0.5, 'price' => 0.49, 'cost' => 49, 'macket' => 'my_macket'));
     $product_id = $this->db->insert_id();
     $this->db->insert('designs', array('product_id' => $product_id, 'theme_id' => $this->input->post('theme'), 'face_background' => $faceMacket, 'back_background' => empty($backMacket) ? NULL : $backMacket, 'face' => $face_preview, 'back' => empty($back_preview) ? '' : $back_preview, 'type' => 'system'));
     $design_id = $this->db->insert_id();
     $options = array();
     if (!empty($face)) {
         foreach ($face as $item) {
             if ($item['type'] == 'text') {
                 $options[] = array('design_id' => $design_id, 'type' => 'text', 'front' => 'face', 'top' => $item['top'], 'left' => $item['left'], 'width' => NULL, 'height' => NULL, 'content' => $item['content'], 'font' => $item['font'], 'color' => $item['color'], 'size' => $item['size']);
             } else {
                 $options[] = array('design_id' => $design_id, 'type' => 'image', 'front' => 'face', 'top' => $item['top'], 'left' => $item['left'], 'width' => $item['width'], 'height' => $item['height'], 'content' => $item['content'], 'font' => NULL, 'color' => NULL, 'size' => NULL);
             }
         }
     }
     if (!empty($back)) {
         foreach ($back as $item) {
             if ($item['type'] == 'text') {
                 $options[] = array('design_id' => $design_id, 'type' => 'text', 'front' => 'back', 'top' => $item['top'], 'left' => $item['left'], 'width' => NULL, 'height' => NULL, 'content' => $item['content'], 'font' => $item['font'], 'color' => $item['color'], 'size' => $item['size']);
             } else {
                 $options[] = array('design_id' => $design_id, 'type' => 'image', 'front' => 'back', 'top' => $item['top'], 'left' => $item['left'], 'width' => $item['width'], 'height' => $item['height'], 'content' => $item['content'], 'font' => NULL, 'color' => NULL, 'size' => NULL);
             }
         }
     }
     if (count($options) > 0) {
         $this->db->insert_batch('design_options', $options);
     }
     echo 'OK';
 }
Ejemplo n.º 16
0
 /**
  * Function to set alias which will be expanded on page rendering.
  *
  * @param string $name  name of the alias
  * @param string $value value of the alias
  *
  * @return void
  */
 function SetAlias($name, $value)
 {
     $name = TCPDF_FONTS::UTF8ToUTF16BE($name, false, true, $this->CurrentFont);
     $this->Alias[$name] = TCPDF_FONTS::UTF8ToUTF16BE($value, false, true, $this->CurrentFont);
 }
Ejemplo n.º 17
0
 /**
  * Returns text with soft hyphens.
  * @param $text (string) text to process
  * @param $patterns (mixed) Array of hypenation patterns or a TEX file containing hypenation patterns. TEX patterns can be downloaded from http://www.ctan.org/tex-archive/language/hyph-utf8/tex/generic/hyph-utf8/patterns/
  * @param $dictionary (array) Array of words to be returned without applying the hyphenation algoritm.
  * @param $leftmin (int) Minimum number of character to leave on the left of the word without applying the hyphens.
  * @param $rightmin (int) Minimum number of character to leave on the right of the word without applying the hyphens.
  * @param $charmin (int) Minimum word length to apply the hyphenation algoritm.
  * @param $charmax (int) Maximum length of broken piece of word.
  * @return array text with soft hyphens
  * @author Nicola Asuni
  * @since 4.9.012 (2010-04-12)
  * @public
  */
 public function hyphenateText($text, $patterns, $dictionary = array(), $leftmin = 1, $rightmin = 2, $charmin = 1, $charmax = 8)
 {
     $text = $this->unhtmlentities($text);
     $word = array();
     // last word
     $txtarr = array();
     // text to be returned
     $intag = false;
     // true if we are inside an HTML tag
     if (!is_array($patterns)) {
         $patterns = TCPDF_STATIC::getHyphenPatternsFromTEX($patterns);
     }
     // get array of characters
     $unichars = TCPDF_FONTS::UTF8StringToArray($text, $this->isunicode, $this->CurrentFont);
     // for each char
     foreach ($unichars as $char) {
         if (!$intag and TCPDF_FONT_DATA::$uni_type[$char] == 'L') {
             // letter character
             $word[] = $char;
         } else {
             // other type of character
             if (!TCPDF_STATIC::empty_string($word)) {
                 // hypenate the word
                 $txtarr = array_merge($txtarr, $this->hyphenateWord($word, $patterns, $dictionary, $leftmin, $rightmin, $charmin, $charmax));
                 $word = array();
             }
             $txtarr[] = $char;
             if (chr($char) == '<') {
                 // we are inside an HTML tag
                 $intag = true;
             } elseif ($intag and chr($char) == '>') {
                 // end of HTML tag
                 $intag = false;
             }
         }
     }
     if (!TCPDF_STATIC::empty_string($word)) {
         // hypenate the word
         $txtarr = array_merge($txtarr, $this->hyphenateWord($word, $patterns, $dictionary, $leftmin, $rightmin, $charmin, $charmax));
     }
     // convert char array to string and return
     return TCPDF_FONTS::UTF8ArrSubString($txtarr, '', '', $this->isunicode);
 }
Ejemplo n.º 18
0
 /**
  * Returns text with soft hyphens.
  * @param $text (string) text to process
  * @param $patterns (mixed) Array of hypenation patterns or a TEX file containing hypenation patterns. TEX patterns can be downloaded from http://www.ctan.org/tex-archive/language/hyph-utf8/tex/generic/hyph-utf8/patterns/
  * @param $dictionary (array) Array of words to be returned without applying the hyphenation algorithm.
  * @param $leftmin (int) Minimum number of character to leave on the left of the word without applying the hyphens.
  * @param $rightmin (int) Minimum number of character to leave on the right of the word without applying the hyphens.
  * @param $charmin (int) Minimum word length to apply the hyphenation algorithm.
  * @param $charmax (int) Maximum length of broken piece of word.
  * @return array text with soft hyphens
  * @author Nicola Asuni
  * @since 4.9.012 (2010-04-12)
  * @public
  */
 public function hyphenateText($text, $patterns, $dictionary = array(), $leftmin = 1, $rightmin = 2, $charmin = 1, $charmax = 8)
 {
     $text = $this->unhtmlentities($text);
     $word = array();
     // last word
     $txtarr = array();
     // text to be returned
     $intag = false;
     // true if we are inside an HTML tag
     $skip = false;
     // true to skip hyphenation
     if (!is_array($patterns)) {
         $patterns = TCPDF_STATIC::getHyphenPatternsFromTEX($patterns);
     }
     // get array of characters
     $unichars = TCPDF_FONTS::UTF8StringToArray($text, $this->isunicode, $this->CurrentFont);
     // for each char
     foreach ($unichars as $char) {
         if (!$intag and !$skip and TCPDF_FONT_DATA::$uni_type[$char] == 'L') {
             // letter character
             $word[] = $char;
         } else {
             // other type of character
             if (!TCPDF_STATIC::empty_string($word)) {
                 // hypenate the word
                 $txtarr = array_merge($txtarr, $this->hyphenateWord($word, $patterns, $dictionary, $leftmin, $rightmin, $charmin, $charmax));
                 $word = array();
             }
             $txtarr[] = $char;
             if (chr($char) == '<') {
                 // we are inside an HTML tag
                 $intag = true;
             } elseif ($intag and chr($char) == '>') {
                 // end of HTML tag
                 $intag = false;
                 // check for style tag
                 $expected = array(115, 116, 121, 108, 101);
                 // = 'style'
                 $current = array_slice($txtarr, -6, 5);
                 // last 5 chars
                 $compare = array_diff($expected, $current);
                 if (empty($compare)) {
                     // check if it is a closing tag
                     $expected = array(47);
                     // = '/'
                     $current = array_slice($txtarr, -7, 1);
                     $compare = array_diff($expected, $current);
                     if (empty($compare)) {
                         // closing style tag
                         $skip = false;
                     } else {
                         // opening style tag
                         $skip = true;
                     }
                 }
             }
         }
     }
     if (!TCPDF_STATIC::empty_string($word)) {
         // hypenate the word
         $txtarr = array_merge($txtarr, $this->hyphenateWord($word, $patterns, $dictionary, $leftmin, $rightmin, $charmin, $charmax));
     }
     // convert char array to string and return
     return TCPDF_FONTS::UTF8ArrSubString($txtarr, '', '', $this->isunicode);
 }
Ejemplo n.º 19
0
 /**
  * Output a Table Of Content Index (TOC) using HTML templates.
  * This method must be called after all Bookmarks were set.
  * Before calling this method you have to open the page using the addTOCPage() method.
  * After calling this method you have to call endTOCPage() to close the TOC page.
  * @param $page (int) page number where this TOC should be inserted (leave empty for current page).
  * @param $toc_name (string) name to use for TOC bookmark.
  * @param $templates (array) array of html templates. Use: "#TOC_DESCRIPTION#" for bookmark title, "#TOC_PAGE_NUMBER#" for page number.
  * @param $correct_align (boolean) if true correct the number alignment (numbers must be in monospaced font like courier and right aligned on LTR, or left aligned on RTL)
  * @param $style (string) Font style for title: B = Bold, I = Italic, BI = Bold + Italic.
  * @param $color (array) RGB color array for title (values from 0 to 255).
  * @param $afterContent (string) Content to add after the TOC
  * @public
  * @author Nicola Asuni
  * @since 5.0.001 (2010-05-06)
  * @see addTOCPage(), endTOCPage(), addTOC()
  */
 public function addHTMLTOC($page = '', $toc_name = 'TOC', $templates = array(), $correct_align = true, $style = '', $color = array(0, 0, 0), $afterContent = '')
 {
     $filler = ' ';
     $prev_htmlLinkColorArray = $this->htmlLinkColorArray;
     $prev_htmlLinkFontStyle = $this->htmlLinkFontStyle;
     // set new style for link
     $this->htmlLinkColorArray = array();
     $this->htmlLinkFontStyle = '';
     $page_first = $this->getPage();
     $page_fill_start = false;
     $page_fill_end = false;
     // get the font type used for numbers in each template
     $current_font = $this->FontFamily;
     foreach ($templates as $level => $html) {
         $dom = $this->getHtmlDomArray($html);
         foreach ($dom as $key => $value) {
             if ($value['value'] == '#TOC_PAGE_NUMBER#') {
                 $this->SetFont($dom[$key - 1]['fontname']);
                 $templates['F' . $level] = $this->isUnicodeFont();
             }
         }
     }
     $this->SetFont($current_font);
     $maxpage = 0;
     //used for pages on attached documents
     foreach ($this->outlines as $key => $outline) {
         // get HTML template
         $row = $templates[$outline['l']];
         if (\TCPDF_STATIC::empty_string($page)) {
             $pagenum = $outline['p'];
         } else {
             // placemark to be replaced with the correct number
             $pagenum = '{#' . $outline['p'] . '}';
             if ($templates['F' . $outline['l']]) {
                 $pagenum = '{' . $pagenum . '}';
             }
             $maxpage = max($maxpage, $outline['p']);
         }
         // replace templates with current values
         $row = str_replace('#TOC_DESCRIPTION#', $outline['t'], $row);
         $row = str_replace('#TOC_DESCRIPTION#', $outline['t'], $row);
         $row = str_replace('#TOC_CHAPTERNUMBER#', $outline['cn'], $row);
         $row = str_replace('#TOC_CSSCLASS#', $outline['cssClass'], $row);
         $row = str_replace('#TOC_PAGE_NUMBER#', $pagenum, $row);
         // add link to page
         $row = '<a href="#' . $outline['p'] . ',' . $outline['y'] . '">' . $row . '</a>';
         // write bookmark entry
         $this->writeHTML($row, false, false, true, false, '');
     }
     // restore link styles
     $this->htmlLinkColorArray = $prev_htmlLinkColorArray;
     $this->htmlLinkFontStyle = $prev_htmlLinkFontStyle;
     // move TOC page and replace numbers
     $page_last = $this->getPage();
     $numpages = $page_last - $page_first + 1;
     // account for booklet mode
     if ($this->booklet) {
         // check if a blank page is required before TOC
         $page_fill_start = ($page_first % 2 == 0 xor $page % 2 == 0);
         $page_fill_end = !($numpages % 2 == 0 xor $page_fill_start);
         if ($page_fill_start) {
             // add a page at the end (to be moved before TOC)
             $this->addPage();
             ++$page_last;
             ++$numpages;
         }
         if ($page_fill_end) {
             // add a page at the end
             $this->addPage();
             ++$page_last;
             ++$numpages;
         }
     }
     $maxpage = max($maxpage, $page_last);
     if (!\TCPDF_STATIC::empty_string($page)) {
         for ($p = $page_first; $p <= $page_last; ++$p) {
             // get page data
             $temppage = $this->getPageBuffer($p);
             for ($n = 1; $n <= $maxpage; ++$n) {
                 // update page numbers
                 $a = '{#' . $n . '}';
                 // get page number aliases
                 $pnalias = $this->getInternalPageNumberAliases($a);
                 // calculate replacement number
                 if ($n >= $page) {
                     $np = $n + $numpages;
                 } else {
                     $np = $n;
                 }
                 $na = \TCPDF_STATIC::formatTOCPageNumber($this->starting_page_number + $np - 1);
                 $nu = \TCPDF_FONTS::UTF8ToUTF16BE($na, false, $this->isunicode, $this->CurrentFont);
                 // replace aliases with numbers
                 foreach ($pnalias['u'] as $u) {
                     if ($correct_align) {
                         $sfill = str_repeat($filler, strlen($u) - strlen($nu . ' '));
                         if ($this->rtl) {
                             $nr = $nu . \TCPDF_FONTS::UTF8ToUTF16BE(' ' . $sfill, false, $this->isunicode, $this->CurrentFont);
                         } else {
                             $nr = \TCPDF_FONTS::UTF8ToUTF16BE($sfill . ' ', false, $this->isunicode, $this->CurrentFont) . $nu;
                         }
                     } else {
                         $nr = $nu;
                     }
                     $temppage = str_replace($u, $nr, $temppage);
                 }
                 foreach ($pnalias['a'] as $a) {
                     if ($correct_align) {
                         $sfill = str_repeat($filler, strlen($a) - strlen($na . ' '));
                         if ($this->rtl) {
                             $nr = $na . ' ' . $sfill;
                         } else {
                             $nr = $sfill . ' ' . $na;
                         }
                     } else {
                         $nr = $na;
                     }
                     $temppage = str_replace($a, $nr, $temppage);
                 }
             }
             // save changes
             $this->setPageBuffer($p, $temppage);
         }
         // append afterContent if set
         if (!empty($afterContent)) {
             $this->writeHTML($afterContent, TRUE, FALSE, TRUE);
         }
         // move pages
         $this->Bookmark($toc_name, 0, 0, $page_first, $style, $color);
         if ($page_fill_start) {
             $this->movePage($page_last, $page_first);
         }
         for ($i = 0; $i < $numpages; ++$i) {
             $this->movePage($page_last, $page);
         }
     }
 }
Ejemplo n.º 20
0
<?php

tcpdf();
$fontnama = TCPDF_FONTS::addTTFfont('certificatebold.ttf', 'TrueTypeUnicode', '', 96);
$font = TCPDF_FONTS::addTTFfont('Chocolate Covered Raindrops BOLD.ttf', 'TrueTypeUnicode', '', 100);
$obj_pdf = new TCPDF('P', PDF_UNIT, "LEGAL", true, 'UTF-8', true);
$obj_pdf->SetCreator("Hendy Andrianto S.Kom (www.facebook.com/opchaky.it)");
$toko = "LEMBAGA PENDIDIKAN KETERAMPILAN";
$hal = "GITA PERTIWI";
$alamat = "PUSAT : JL. KEBON TIWU I NO. 10 TASIKMALAYA";
$tlp = "(0265) 323445 HP. 085295168608";
$cabang = "CABANG : JL. RAYA TIMUR BOROLONG CILAMPUNG HILIR SINGAPARNA" . "\n" . "HP. 085353292292";
$judul = $alamat . "\n" . "TELP. " . $tlp;
$foto = "profile.jpg";
$cknama = $this->db->get_where('view_member', array('kode' => $kode))->result();
foreach ($cknama as $row) {
    $nama = $row->nama;
    $tgl = date('d-m-Y', strtotime($row->tgl_lahir));
    $tempat = $row->tempat_lahir;
    $jns = strtoupper($row->nama_tipe);
}
$ckhasil = $this->db->get_where('tbl_status_izajah', array('id' => $status))->result();
foreach ($ckhasil as $key) {
    $hasil = $key->status;
}
$obj_pdf->SetTitle($toko);
$obj_pdf->SetHeaderData("", "", "", "");
$obj_pdf->SetPrintHeader(FALSE);
$obj_pdf->SetPrintFooter(FALSE);
$obj_pdf->setHeaderFont(array(PDF_FONT_NAME_MAIN, '', 9));
$obj_pdf->setFooterFont(array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));
Ejemplo n.º 21
0
if (empty($options['fonts'])) {
    echo "ERROR: missing input fonts (try --help for usage)\n\n";
    exit(2);
}
// check the output path
if (!is_dir($options['outpath']) or !is_writable($options['outpath'])) {
    echo "ERROR: Can't write to " . $options['outpath'] . "\n\n";
    exit(3);
}
echo "\n>>> Converting fonts for TCPDF:\n";
echo '*** Output dir set to ' . $options['outpath'] . "\n";
// check if there are conversion errors
$errors = false;
foreach ($options['fonts'] as $font) {
    $fontfile = realpath($font);
    $fontname = TCPDF_FONTS::addTTFfont($fontfile, $options['type'], $options['enc'], $options['flags'], $options['outpath'], $options['platid'], $options['encid'], $options['addcbbox'], $options['link']);
    if ($fontname === false) {
        $errors = true;
        echo "--- ERROR: can't add " . $font . "\n";
    } else {
        echo "+++ OK   : " . $fontfile . ' added as ' . $fontname . "\n";
    }
}
if ($errors) {
    echo "--- Process completed with ERRORS!\n\n";
    exit(4);
}
echo ">>> Process successfully completed!\n\n";
exit(0);
//============================================================+
// END OF FILE
Ejemplo n.º 22
0
 // unique id for this fax
 $fax_instance_uuid = uuid();
 //generate cover page, merge with pdf
 if ($fax_subject != '' || $fax_message != '') {
     //load pdf libraries
     require_once "resources/tcpdf/tcpdf.php";
     require_once "resources/fpdi/fpdi.php";
     // initialize pdf
     $pdf = new FPDI('P', 'in');
     $pdf->SetAutoPageBreak(false);
     $pdf->setPrintHeader(false);
     $pdf->setPrintFooter(false);
     $pdf->SetMargins(0, 0, 0, true);
     if (strlen($fax_cover_font) > 0) {
         if (substr($fax_cover_font, -4) == '.ttf') {
             $pdf_font = TCPDF_FONTS::addTTFfont($fax_cover_font);
         } else {
             $pdf_font = $fax_cover_font;
         }
     }
     if (!$pdf_font) {
         $pdf_font = 'times';
     }
     //add blank page
     $pdf->AddPage('P', array($page_width, $page_height));
     // content offset, if necessary
     $x = 0;
     $y = 0;
     //logo
     $display_logo = false;
     if (!isset($_SESSION['fax']['cover_logo']['text'])) {
Ejemplo n.º 23
0
 protected function addCustomFontsToPDF(\TCPDF &$pdf, array $arrFonts)
 {
     $objModels = \FilesModel::findMultipleByUuids($arrFonts);
     if ($objModels === null) {
         return false;
     }
     while ($objModels->next()) {
         if (!file_exists(TL_ROOT . '/' . $objModels->path)) {
             continue;
         }
         $font = \TCPDF_FONTS::addTTFfont(TL_ROOT . '/' . $objModels->path, 'TrueTypeUnicode', '', 96);
         $pdf->SetFont($font, '', $this->objModel->share_pdfFontSize ? $this->objModel->share_pdfFontSize : 13, false);
     }
 }
Ejemplo n.º 24
-4
 public function testPdfOutput()
 {
     // create new PDF document
     $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
     // set document information
     $pdf->SetCreator(PDF_CREATOR);
     $pdf->SetAuthor('Nicola Asuni');
     $pdf->SetTitle('TCPDF Example 055');
     $pdf->SetSubject('TCPDF Tutorial');
     $pdf->SetKeywords('TCPDF, PDF, example, test, guide');
     // set default header data
     $pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE . ' 055', PDF_HEADER_STRING);
     // set header and footer fonts
     $pdf->setHeaderFont(array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
     $pdf->setFooterFont(array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));
     // set default monospaced font
     $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
     // set margins
     $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
     $pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
     $pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
     // set auto page breaks
     $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
     // set image scale factor
     $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
     // set some language-dependent strings (optional)
     $pdf->setLanguageArray($this->langSettings);
     // ---------------------------------------------------------
     // set font
     $pdf->SetFont('helvetica', '', 14);
     // array of font names
     $core_fonts = array('courier', 'courierB', 'courierI', 'courierBI', 'helvetica', 'helveticaB', 'helveticaI', 'helveticaBI', 'times', 'timesB', 'timesI', 'timesBI', 'symbol', 'zapfdingbats');
     // set fill color
     $pdf->SetFillColor(221, 238, 255);
     // create one HTML table for each core font
     foreach ($core_fonts as $font) {
         // add a page
         $pdf->AddPage();
         // Cell($w, $h=0, $txt='', $border=0, $ln=0, $align='', $fill=false, $link='', $stretch=0, $ignore_min_height=false, $calign='T', $valign='M')
         // set font for title
         $pdf->SetFont('helvetica', 'B', 16);
         // print font name
         $pdf->Cell(0, 10, 'FONT: ' . $font, 1, 1, 'C', true, '', 0, false, 'T', 'M');
         // set font for chars
         $pdf->SetFont($font, '', 16);
         // print each character
         for ($i = 0; $i < 256; ++$i) {
             if ($i > 0 and $i % 16 == 0) {
                 $pdf->Ln();
             }
             $pdf->Cell(11.25, 11.25, TCPDF_FONTS::unichr($i), 1, 0, 'C', false, '', 0, false, 'T', 'M');
         }
         $pdf->Ln(20);
         // print a pangram
         $pdf->Cell(0, 0, 'The quick brown fox jumps over the lazy dog', 0, 1, 'C', false, '', 0, false, 'T', 'M');
     }
     // ---------------------------------------------------------
     $this->comparePdfs($pdf);
 }