N°2435.8 Manage TCPDF lib using composer

This commit is contained in:
Molkobain
2019-08-16 10:37:39 +02:00
parent af9c45849e
commit fb1b730bd5
87 changed files with 436 additions and 322 deletions

View File

@@ -0,0 +1,84 @@
# TCPDF
*PHP PDF Library*
[![Donate via PayPal](https://img.shields.io/badge/donate-paypal-87ceeb.svg)](https://www.paypal.com/cgi-bin/webscr?cmd=_donations&currency_code=GBP&business=paypal@tecnick.com&item_name=donation%20for%20TCPDF%20project)
*Please consider supporting this project by making a donation via [PayPal](https://www.paypal.com/cgi-bin/webscr?cmd=_donations&currency_code=GBP&business=paypal@tecnick.com&item_name=donation%20for%20TCPDF%20project)*
* **category** Library
* **author** Nicola Asuni <info@tecnick.com>
* **copyright** 2002-2018 Nicola Asuni - Tecnick.com LTD
* **license** http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
* **link** http://www.tcpdf.org
* **source** https://github.com/tecnickcom/TCPDF
## IMPORTANT
A new version of this library is under development at https://github.com/tecnickcom/tc-lib-pdf and as a consequence this version will not receive any additional development or support.
This version should be considered obsolete, new projects should use the new version as soon it will become stable.
## Description
PHP library for generating PDF documents on-the-fly.
### Main Features:
* no external libraries are required for the basic functions;
* all standard page formats, custom page formats, custom margins and units of measure;
* UTF-8 Unicode and Right-To-Left languages;
* TrueTypeUnicode, OpenTypeUnicode v1, TrueType, OpenType v1, Type1 and CID-0 fonts;
* font subsetting;
* methods to publish some XHTML + CSS code, Javascript and Forms;
* images, graphic (geometric figures) and transformation methods;
* supports JPEG, PNG and SVG images natively, all images supported by GD (GD, GD2, GD2PART, GIF, JPEG, PNG, BMP, XBM, XPM) and all images supported via ImagMagick (http://www.imagemagick.org/script/formats.php)
* 1D and 2D barcodes: CODE 39, ANSI MH10.8M-1983, USD-3, 3 of 9, CODE 93, USS-93, Standard 2 of 5, Interleaved 2 of 5, CODE 128 A/B/C, 2 and 5 Digits UPC-Based Extension, EAN 8, EAN 13, UPC-A, UPC-E, MSI, POSTNET, PLANET, RMS4CC (Royal Mail 4-state Customer Code), CBC (Customer Bar Code), KIX (Klant index - Customer index), Intelligent Mail Barcode, Onecode, USPS-B-3200, CODABAR, CODE 11, PHARMACODE, PHARMACODE TWO-TRACKS, Datamatrix, QR-Code, PDF417;
* JPEG and PNG ICC profiles, Grayscale, RGB, CMYK, Spot Colors and Transparencies;
* automatic page header and footer management;
* document encryption up to 256 bit and digital signature certifications;
* transactions to UNDO commands;
* PDF annotations, including links, text and file attachments;
* text rendering modes (fill, stroke and clipping);
* multiple columns mode;
* no-write page regions;
* bookmarks, named destinations and table of content;
* text hyphenation;
* text stretching and spacing (tracking);
* automatic page break, line break and text alignments including justification;
* automatic page numbering and page groups;
* move and delete pages;
* page compression (requires php-zlib extension);
* XOBject Templates;
* Layers and object visibility.
* PDF/A-1b support.
### Third party fonts:
This library may include third party font files released with different licenses.
All the PHP files on the fonts directory are subject to the general TCPDF license (GNU-LGPLv3),
they do not contain any binary data but just a description of the general properties of a particular font.
These files can be also generated on the fly using the font utilities and TCPDF methods.
All the original binary TTF font files have been renamed for compatibility with TCPDF and compressed using the gzcompress PHP function that uses the ZLIB data format (.z files).
The binary files (.z) that begins with the prefix "free" have been extracted from the GNU FreeFont collection (GNU-GPLv3).
The binary files (.z) that begins with the prefix "pdfa" have been derived from the GNU FreeFont, so they are subject to the same license.
For the details of Copyright, License and other information, please check the files inside the directory fonts/freefont-20120503
Link : http://www.gnu.org/software/freefont/
The binary files (.z) that begins with the prefix "dejavu" have been extracted from the DejaVu fonts 2.33 (Bitstream) collection.
For the details of Copyright, License and other information, please check the files inside the directory fonts/dejavu-fonts-ttf-2.33
Link : http://dejavu-fonts.org
The binary files (.z) that begins with the prefix "ae" have been extracted from the Arabeyes.org collection (GNU-GPLv2).
Link : http://projects.arabeyes.org/
### ICC profile:
TCPDF includes the sRGB.icc profile from the icc-profiles-free Debian package:
https://packages.debian.org/source/stable/icc-profiles-free
## Developer(s) Contact
* Nicola Asuni <info@tecnick.com>

View File

@@ -1,24 +1,16 @@
{
"name": "tecnickcom/tcpdf",
"version": "6.2.26",
"homepage": "http://www.tcpdf.org/",
"name": "combodo/tcpdf",
"replace": {
"tecnickcom/tcpdf": "self.version"
},
"homepage": "https://github.com/combodo-itop-libs/TCPDF",
"type": "library",
"description": "TCPDF is a PHP class for generating PDF documents and barcodes.",
"keywords": [
"PDF",
"tcpdf",
"PDFD32000-2008",
"qrcode",
"datamatrix",
"pdf417",
"barcodes"
],
"description": "TCPDF fork adding requirements for iTop: Specific fonts.",
"license": "LGPL-3.0",
"authors": [
{
"name": "Nicola Asuni",
"email": "info@tecnick.com",
"role": "lead"
"name": "Combodo",
"email": "contact@combodo.com"
}
],
"require": {

Binary file not shown.

File diff suppressed because one or more lines are too long

Binary file not shown.

Binary file not shown.

File diff suppressed because one or more lines are too long

Binary file not shown.

Binary file not shown.

File diff suppressed because one or more lines are too long

Binary file not shown.

Binary file not shown.

File diff suppressed because one or more lines are too long

Binary file not shown.

Binary file not shown.

File diff suppressed because one or more lines are too long

Binary file not shown.

Binary file not shown.

File diff suppressed because one or more lines are too long

Binary file not shown.

Binary file not shown.

File diff suppressed because one or more lines are too long

Binary file not shown.

Binary file not shown.

File diff suppressed because one or more lines are too long

Binary file not shown.

Binary file not shown.

File diff suppressed because one or more lines are too long

Binary file not shown.

Binary file not shown.

File diff suppressed because one or more lines are too long

Binary file not shown.

View File

@@ -1,4 +1,22 @@
<?php
/**
* Copyright (C) 2013-2019 Combodo SARL
*
* This file is part of iTop.
*
* iTop is free software; you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* iTop is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
*/
$type='TrueTypeUnicode';
$name='DroidSansFallback';
$desc=array('Ascent'=>1043,'Descent'=>-266,'CapHeight'=>0,'Flags'=>96,'FontBBox'=>'[-90 -266 1121 1043]','ItalicAngle'=>-6.5,'StemV'=>70,'MissingWidth'=>600);

Binary file not shown.

View File

@@ -358,7 +358,7 @@ class TCPDF_COLORS {
$color_code = self::$webcolor[$color];
} else {
// spot color
$returncolor = self::getSpotColor($color, $spotc);
$returncolor = self::getSpotColor($hcolor, $spotc);
if ($returncolor === false) {
$returncolor = $defcol;
}

View File

@@ -1926,7 +1926,7 @@ class TCPDF_STATIC {
$alt = array_unique($alt);
foreach ($alt as $path) {
if (!self::file_exists($path)) {
return false;
continue;
}
$ret = @file_get_contents($path);
if ($ret !== false) {

View File

@@ -18686,7 +18686,7 @@ Putting 1 is equivalent to putting 0 and calling Ln() just after. Default value:
$hbz = 0; // distance from y to line bottom
$hb = 0; // vertical space between block tags
// calculate vertical space for block tags
if (isset($this->tagvspaces[$tag['value']][0]['h']) AND ($this->tagvspaces[$tag['value']][0]['h'] >= 0)) {
if (isset($this->tagvspaces[$tag['value']][0]['h']) && !empty($this->tagvspaces[$tag['value']][0]['h']) && ($this->tagvspaces[$tag['value']][0]['h'] >= 0)) {
$cur_h = $this->tagvspaces[$tag['value']][0]['h'];
} elseif (isset($tag['fontsize'])) {
$cur_h = $this->getCellHeight($tag['fontsize'] / $this->k);
@@ -18718,7 +18718,7 @@ Putting 1 is equivalent to putting 0 and calling Ln() just after. Default value:
}
// closing vertical space
$hbc = 0;
if (isset($this->tagvspaces[$tag['value']][1]['h']) AND ($this->tagvspaces[$tag['value']][1]['h'] >= 0)) {
if (isset($this->tagvspaces[$tag['value']][1]['h']) && !empty($this->tagvspaces[$tag['value']][1]['h']) && ($this->tagvspaces[$tag['value']][1]['h'] >= 0)) {
$pre_h = $this->tagvspaces[$tag['value']][1]['h'];
} elseif (isset($parent['fontsize'])) {
$pre_h = $this->getCellHeight($parent['fontsize'] / $this->k);
@@ -19379,7 +19379,7 @@ Putting 1 is equivalent to putting 0 and calling Ln() just after. Default value:
$hbz = 0; // distance from y to line bottom
$hb = 0; // vertical space between block tags
// calculate vertical space for block tags
if (isset($this->tagvspaces[$tag['value']][1]['h']) AND ($this->tagvspaces[$tag['value']][1]['h'] >= 0)) {
if (isset($this->tagvspaces[$tag['value']][1]['h']) && !empty($this->tagvspaces[$tag['value']][1]['h']) && ($this->tagvspaces[$tag['value']][1]['h'] >= 0)) {
$pre_h = $this->tagvspaces[$tag['value']][1]['h'];
} elseif (isset($parent['fontsize'])) {
$pre_h = $this->getCellHeight($parent['fontsize'] / $this->k);

View File

@@ -173,6 +173,7 @@ return array(
'DashletUnknown' => $baseDir . '/application/dashlet.class.inc.php',
'DataTable' => $baseDir . '/application/datatable.class.inc.php',
'DataTableSettings' => $baseDir . '/application/datatable.class.inc.php',
'Datamatrix' => $vendorDir . '/combodo/tcpdf/include/barcodes/datamatrix.php',
'DateTimeFormat' => $baseDir . '/core/datetimeformat.class.inc.php',
'DefaultMetricComputer' => $baseDir . '/core/computing.inc.php',
'DefaultWorkingTimeComputer' => $baseDir . '/core/computing.inc.php',
@@ -301,6 +302,7 @@ return array(
'OqlObjectQuery' => $baseDir . '/core/oql/oqlquery.class.inc.php',
'OqlQuery' => $baseDir . '/core/oql/oqlquery.class.inc.php',
'OqlUnionQuery' => $baseDir . '/core/oql/oqlquery.class.inc.php',
'PDF417' => $vendorDir . '/combodo/tcpdf/include/barcodes/pdf417.php',
'PDFBulkExport' => $baseDir . '/core/pdfbulkexport.class.inc.php',
'PDFPage' => $baseDir . '/application/pdfpage.class.inc.php',
'PEAR' => $vendorDir . '/pear/pear-core-minimal/src/PEAR.php',
@@ -365,6 +367,7 @@ return array(
'Psr\\SimpleCache\\CacheException' => $vendorDir . '/psr/simple-cache/src/CacheException.php',
'Psr\\SimpleCache\\CacheInterface' => $vendorDir . '/psr/simple-cache/src/CacheInterface.php',
'Psr\\SimpleCache\\InvalidArgumentException' => $vendorDir . '/psr/simple-cache/src/InvalidArgumentException.php',
'QRcode' => $vendorDir . '/combodo/tcpdf/include/barcodes/qrcode.php',
'Query' => $baseDir . '/application/query.class.inc.php',
'QueryBuilderContext' => $baseDir . '/core/querybuildercontext.class.inc.php',
'QueryBuilderExpressions' => $baseDir . '/core/oql/expression.class.inc.php',
@@ -1434,6 +1437,17 @@ return array(
'Symfony\\Polyfill\\Mbstring\\Mbstring' => $vendorDir . '/symfony/polyfill-mbstring/Mbstring.php',
'Symfony\\Polyfill\\Php70\\Php70' => $vendorDir . '/symfony/polyfill-php70/Php70.php',
'System' => $vendorDir . '/pear/pear-core-minimal/src/System.php',
'TCPDF' => $vendorDir . '/combodo/tcpdf/tcpdf.php',
'TCPDF2DBarcode' => $vendorDir . '/combodo/tcpdf/tcpdf_barcodes_2d.php',
'TCPDFBarcode' => $vendorDir . '/combodo/tcpdf/tcpdf_barcodes_1d.php',
'TCPDF_COLORS' => $vendorDir . '/combodo/tcpdf/include/tcpdf_colors.php',
'TCPDF_FILTERS' => $vendorDir . '/combodo/tcpdf/include/tcpdf_filters.php',
'TCPDF_FONTS' => $vendorDir . '/combodo/tcpdf/include/tcpdf_fonts.php',
'TCPDF_FONT_DATA' => $vendorDir . '/combodo/tcpdf/include/tcpdf_font_data.php',
'TCPDF_IMAGES' => $vendorDir . '/combodo/tcpdf/include/tcpdf_images.php',
'TCPDF_IMPORT' => $vendorDir . '/combodo/tcpdf/tcpdf_import.php',
'TCPDF_PARSER' => $vendorDir . '/combodo/tcpdf/tcpdf_parser.php',
'TCPDF_STATIC' => $vendorDir . '/combodo/tcpdf/include/tcpdf_static.php',
'TabManager' => $baseDir . '/application/webpage.class.inc.php',
'TabularBulkExport' => $baseDir . '/core/tabularbulkexport.class.inc.php',
'TagSetFieldData' => $baseDir . '/core/tagsetfield.class.inc.php',

View File

@@ -394,6 +394,7 @@ class ComposerStaticInit0018331147de7601e7552f7da8e3bb8b
'DashletUnknown' => __DIR__ . '/../..' . '/application/dashlet.class.inc.php',
'DataTable' => __DIR__ . '/../..' . '/application/datatable.class.inc.php',
'DataTableSettings' => __DIR__ . '/../..' . '/application/datatable.class.inc.php',
'Datamatrix' => __DIR__ . '/..' . '/combodo/tcpdf/include/barcodes/datamatrix.php',
'DateTimeFormat' => __DIR__ . '/../..' . '/core/datetimeformat.class.inc.php',
'DefaultMetricComputer' => __DIR__ . '/../..' . '/core/computing.inc.php',
'DefaultWorkingTimeComputer' => __DIR__ . '/../..' . '/core/computing.inc.php',
@@ -522,6 +523,7 @@ class ComposerStaticInit0018331147de7601e7552f7da8e3bb8b
'OqlObjectQuery' => __DIR__ . '/../..' . '/core/oql/oqlquery.class.inc.php',
'OqlQuery' => __DIR__ . '/../..' . '/core/oql/oqlquery.class.inc.php',
'OqlUnionQuery' => __DIR__ . '/../..' . '/core/oql/oqlquery.class.inc.php',
'PDF417' => __DIR__ . '/..' . '/combodo/tcpdf/include/barcodes/pdf417.php',
'PDFBulkExport' => __DIR__ . '/../..' . '/core/pdfbulkexport.class.inc.php',
'PDFPage' => __DIR__ . '/../..' . '/application/pdfpage.class.inc.php',
'PEAR' => __DIR__ . '/..' . '/pear/pear-core-minimal/src/PEAR.php',
@@ -586,6 +588,7 @@ class ComposerStaticInit0018331147de7601e7552f7da8e3bb8b
'Psr\\SimpleCache\\CacheException' => __DIR__ . '/..' . '/psr/simple-cache/src/CacheException.php',
'Psr\\SimpleCache\\CacheInterface' => __DIR__ . '/..' . '/psr/simple-cache/src/CacheInterface.php',
'Psr\\SimpleCache\\InvalidArgumentException' => __DIR__ . '/..' . '/psr/simple-cache/src/InvalidArgumentException.php',
'QRcode' => __DIR__ . '/..' . '/combodo/tcpdf/include/barcodes/qrcode.php',
'Query' => __DIR__ . '/../..' . '/application/query.class.inc.php',
'QueryBuilderContext' => __DIR__ . '/../..' . '/core/querybuildercontext.class.inc.php',
'QueryBuilderExpressions' => __DIR__ . '/../..' . '/core/oql/expression.class.inc.php',
@@ -1655,6 +1658,17 @@ class ComposerStaticInit0018331147de7601e7552f7da8e3bb8b
'Symfony\\Polyfill\\Mbstring\\Mbstring' => __DIR__ . '/..' . '/symfony/polyfill-mbstring/Mbstring.php',
'Symfony\\Polyfill\\Php70\\Php70' => __DIR__ . '/..' . '/symfony/polyfill-php70/Php70.php',
'System' => __DIR__ . '/..' . '/pear/pear-core-minimal/src/System.php',
'TCPDF' => __DIR__ . '/..' . '/combodo/tcpdf/tcpdf.php',
'TCPDF2DBarcode' => __DIR__ . '/..' . '/combodo/tcpdf/tcpdf_barcodes_2d.php',
'TCPDFBarcode' => __DIR__ . '/..' . '/combodo/tcpdf/tcpdf_barcodes_1d.php',
'TCPDF_COLORS' => __DIR__ . '/..' . '/combodo/tcpdf/include/tcpdf_colors.php',
'TCPDF_FILTERS' => __DIR__ . '/..' . '/combodo/tcpdf/include/tcpdf_filters.php',
'TCPDF_FONTS' => __DIR__ . '/..' . '/combodo/tcpdf/include/tcpdf_fonts.php',
'TCPDF_FONT_DATA' => __DIR__ . '/..' . '/combodo/tcpdf/include/tcpdf_font_data.php',
'TCPDF_IMAGES' => __DIR__ . '/..' . '/combodo/tcpdf/include/tcpdf_images.php',
'TCPDF_IMPORT' => __DIR__ . '/..' . '/combodo/tcpdf/tcpdf_import.php',
'TCPDF_PARSER' => __DIR__ . '/..' . '/combodo/tcpdf/tcpdf_parser.php',
'TCPDF_STATIC' => __DIR__ . '/..' . '/combodo/tcpdf/include/tcpdf_static.php',
'TabManager' => __DIR__ . '/../..' . '/application/webpage.class.inc.php',
'TabularBulkExport' => __DIR__ . '/../..' . '/core/tabularbulkexport.class.inc.php',
'TagSetFieldData' => __DIR__ . '/../..' . '/core/tagsetfield.class.inc.php',

View File

@@ -1,4 +1,61 @@
[
{
"name": "combodo/tcpdf",
"version": "6.3.0",
"version_normalized": "6.3.0.0",
"source": {
"type": "git",
"url": "https://github.com/combodo-itop-libs/TCPDF.git",
"reference": "d645f9438b757499ac4cb39c10c41ded0f9f0326"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/combodo-itop-libs/TCPDF/zipball/d645f9438b757499ac4cb39c10c41ded0f9f0326",
"reference": "d645f9438b757499ac4cb39c10c41ded0f9f0326",
"shasum": ""
},
"require": {
"php": ">=5.3.0"
},
"replace": {
"tecnickcom/tcpdf": "self.version"
},
"time": "2019-08-16T08:14:13+00:00",
"type": "library",
"installation-source": "dist",
"autoload": {
"classmap": [
"config",
"include",
"tcpdf.php",
"tcpdf_parser.php",
"tcpdf_import.php",
"tcpdf_barcodes_1d.php",
"tcpdf_barcodes_2d.php",
"include/tcpdf_colors.php",
"include/tcpdf_filters.php",
"include/tcpdf_font_data.php",
"include/tcpdf_fonts.php",
"include/tcpdf_images.php",
"include/tcpdf_static.php",
"include/barcodes/datamatrix.php",
"include/barcodes/pdf417.php",
"include/barcodes/qrcode.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"LGPL-3.0"
],
"authors": [
{
"name": "Combodo",
"email": "contact@combodo.com"
}
],
"description": "TCPDF fork adding requirements for iTop: Specific fonts.",
"homepage": "https://github.com/combodo-itop-libs/TCPDF"
},
{
"name": "paragonie/random_compat",
"version": "v2.0.18",

Binary file not shown.

View File

@@ -1 +0,0 @@
deny from all

View File

@@ -1,28 +0,0 @@
./tcpdf_addfont.php -b -t Type1 -f 4 -e symbol -i pdfasymbol.pfb
./tcpdf_addfont.php -b -t Type1 -f 4 -i pdfazapfdingbats.pfb
./tcpdf_addfont.php -b -t Type1 -f 32 -e cp1252 -i pdfatimes.pfb,pdfatimesb.pfb,pdfahelvetica.pfb,pdfahelveticab.pfb
./tcpdf_addfont.php -b -t Type1 -f 33 -e cp1252 -i pdfacourier.pfb,pdfacourierb.pfb
./tcpdf_addfont.php -b -t Type1 -f 96 -e cp1252 -i pdfahelveticabi.pfb,pdfahelveticai.pfb,pdfatimesi.pfb,pdfatimesbi.pfb
./tcpdf_addfont.php -b -t Type1 -f 97 -e cp1252 -i pdfacourieri.pfb,pdfacourierbi.pfb
./tcpdf_addfont.php -b -t TrueTypeUnicode -f 32 -i DejaVuSans.ttf,DejaVuSans-Bold.ttf,DejaVuSansCondensed.ttf,DejaVuSansCondensed-Bold.ttf,DejaVuSans-ExtraLight.ttf,DejaVuSerif.ttf,DejaVuSerif-Bold.ttf,DejaVuSerifCondensed.ttf,DejaVuSerifCondensed-Bold.ttf
./tcpdf_addfont.php -b -t TrueTypeUnicode -f 33 -i DejaVuSansMono.ttf,DejaVuSansMono-Bold.ttf
./tcpdf_addfont.php -b -t TrueTypeUnicode -f 96 -i DejaVuSans-BoldOblique.ttf,DejaVuSansCondensed-BoldOblique.ttf,DejaVuSansCondensed-Oblique.ttf,DejaVuSerifCondensed-BoldItalic.ttf,DejaVuSerifCondensed-Italic.ttf,DejaVuSerif-Italic.ttf,DejaVuSerif-BoldItalic.ttf,DejaVuSans-Oblique.ttf
./tcpdf_addfont.php -b -t TrueTypeUnicode -f 97 -i DejaVuSansMono-BoldOblique.ttf,DejaVuSansMono-Oblique.ttf
./tcpdf_addfont.php -b -t TrueTypeUnicode -f 32 -i FreeSans.ttf,FreeSansBold.ttf,FreeSerif.ttf,FreeSerifBold.ttf
./tcpdf_addfont.php -b -t TrueTypeUnicode -f 33 -i FreeMono.ttf,FreeMonoBold.ttf
./tcpdf_addfont.php -b -t TrueTypeUnicode -f 96 -i FreeSansBoldOblique.ttf,FreeSansOblique.ttf,FreeSerifBoldItalic.ttf,FreeSerifItalic.ttf
./tcpdf_addfont.php -b -t TrueTypeUnicode -f 97 -i FreeMonoBoldOblique.ttf,FreeMonoOblique.ttf
./tcpdf_addfont.php -b -t TrueTypeUnicode -i aeAlArabiya.ttf,aeFurat.ttf
./tcpdf_addfont.php -b -t CID0JP -f 32 -i cid0jp.ttf
./tcpdf_addfont.php -b -t CID0KR -f 32 -i cid0kr.ttf
./tcpdf_addfont.php -b -t CID0CS -f 32 -i cid0cs.ttf
./tcpdf_addfont.php -b -t CID0CT -f 32 -i cid0ct.ttf

View File

@@ -1,269 +0,0 @@
#!/usr/bin/env php
<?php
//============================================================+
// File name : tcpdf_addfont.php
// Version : 1.0.002
// Begin : 2013-05-13
// Last Update : 2013-08-05
// Authors : Nicola Asuni - Tecnick.com LTD - www.tecnick.com - info@tecnick.com
// Remi Collet
// License : GNU-LGPL v3 (http://www.gnu.org/copyleft/lesser.html)
// -------------------------------------------------------------------
// Copyright (C) 2011-2013 Nicola Asuni - Tecnick.com LTD
//
// This file is part of TCPDF software library.
//
// TCPDF is free software: you can redistribute it and/or modify it
// under the terms of the GNU Lesser General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// TCPDF is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
// See the GNU Lesser General Public License for more details.
//
// You should have received a copy of the License
// along with TCPDF. If not, see
// <http://www.tecnick.com/pagefiles/tcpdf/LICENSE.TXT>.
//
// See LICENSE.TXT file for more information.
// -------------------------------------------------------------------
//
// Description : This is a command line script to generate TCPDF fonts.
//
//============================================================+
/**
* @file
* This is a command line script to generate TCPDF fonts.<br>
* @package com.tecnick.tcpdf
* @version 1.0.000
*/
if (php_sapi_name() != 'cli') {
echo 'You need to run this command from console.';
exit(1);
}
$tcpdf_include_dirs = array(realpath(dirname(__FILE__).'/../tcpdf.php'), '/usr/share/php/tcpdf/tcpdf.php', '/usr/share/tcpdf/tcpdf.php', '/usr/share/php-tcpdf/tcpdf.php', '/var/www/tcpdf/tcpdf.php', '/var/www/html/tcpdf/tcpdf.php', '/usr/local/apache2/htdocs/tcpdf/tcpdf.php');
foreach ($tcpdf_include_dirs as $tcpdf_include_path) {
if (@file_exists($tcpdf_include_path)) {
require_once($tcpdf_include_path);
break;
}
}
/**
* Display help guide for this command.
*/
function showHelp() {
$help = <<<EOD
tcpdf_addfont - command line tool to convert fonts for the TCPDF library.
Usage: tcpdf_addfont.php [ options ] -i fontfile[,fontfile]...
Options:
-t
--type Font type. Leave empty for autodetect mode.
Valid values are:
TrueTypeUnicode
TrueType
Type1
CID0JP = CID-0 Japanese
CID0KR = CID-0 Korean
CID0CS = CID-0 Chinese Simplified
CID0CT = CID-0 Chinese Traditional
-e
--enc Name of the encoding table to use. Leave empty for
default mode. Omit this parameter for TrueType Unicode
and symbolic fonts like Symbol or ZapfDingBats.
-f
--flags Unsigned 32-bit integer containing flags specifying
various characteristics of the font (PDF32000:2008 -
9.8.2 Font Descriptor Flags): +1 for fixed font; +4 for
symbol or +32 for non-symbol; +64 for italic. Fixed and
Italic mode are generally autodetected so you have to
set it to 32 = non-symbolic font (default) or 4 =
symbolic font.
-o
--outpath Output path for generated font files (must be writeable
by the web server). Leave empty for default font folder.
-p
--platid Platform ID for CMAP table to extract (when building a
Unicode font for Windows this value should be 3, for
Macintosh should be 1).
-n
--encid Encoding ID for CMAP table to extract (when building a
Unicode font for Windows this value should be 1, for
Macintosh should be 0). When Platform ID is 3, legal
values for Encoding ID are: 0=Symbol, 1=Unicode,
2=ShiftJIS, 3=PRC, 4=Big5, 5=Wansung, 6=Johab,
7=Reserved, 8=Reserved, 9=Reserved, 10=UCS-4.
-b
--addcbbox Includes the character bounding box information on the
php font file.
-l
--link Link to system font instead of copying the font data #
(not transportable) - Note: do not work with Type1 fonts.
-i
--fonts Comma-separated list of input font files.
-h
--help Display this help and exit.
EOD;
echo $help."\n\n";
exit(0);
}
// remove the name of the executing script
array_shift($argv);
// no options chosen
if (!is_array($argv)) {
showHelp();
}
// initialize the array of options
$options = array('type'=>'', 'enc'=>'', 'flags'=>32, 'outpath'=>K_PATH_FONTS, 'platid'=>3, 'encid'=>1, 'addcbbox'=>false, 'link'=>false);
// short input options
$sopt = '';
$sopt .= 't:';
$sopt .= 'e:';
$sopt .= 'f:';
$sopt .= 'o:';
$sopt .= 'p:';
$sopt .= 'n:';
$sopt .= 'b';
$sopt .= 'l';
$sopt .= 'i:';
$sopt .= 'h';
// long input options
$lopt = array();
$lopt[] = 'type:';
$lopt[] = 'enc:';
$lopt[] = 'flags:';
$lopt[] = 'outpath:';
$lopt[] = 'platid:';
$lopt[] = 'encid:';
$lopt[] = 'addcbbox';
$lopt[] = 'link';
$lopt[] = 'fonts:';
$lopt[] = 'help';
// parse input options
$inopt = getopt($sopt, $lopt);
// import options (with some sanitization)
foreach ($inopt as $opt => $val) {
switch ($opt) {
case 't':
case 'type': {
if (in_array($val, array('TrueTypeUnicode', 'TrueType', 'Type1', 'CID0JP', 'CID0KR', 'CID0CS', 'CID0CT'))) {
$options['type'] = $val;
}
break;
}
case 'e':
case 'enc': {
$options['enc'] = $val;
break;
}
case 'f':
case 'flags': {
$options['flags'] = intval($val);
break;
}
case 'o':
case 'outpath': {
$options['outpath'] = realpath($val);
if (substr($options['outpath'], -1) != '/') {
$options['outpath'] .= '/';
}
break;
}
case 'p':
case 'platid': {
$options['platid'] = min(max(1, intval($val)), 3);
break;
}
case 'n':
case 'encid': {
$options['encid'] = min(max(0, intval($val)), 10);
break;
}
case 'b':
case 'addcbbox': {
$options['addcbbox'] = true;
break;
}
case 'l':
case 'link': {
$options['link'] = true;
break;
}
case 'i':
case 'fonts': {
$options['fonts'] = explode(',', $val);
break;
}
case 'h':
case 'help':
default: {
showHelp();
break;
}
} // end of switch
} // end of while loop
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
//============================================================+