Skip to content

Commit

Permalink
Update dependencies and PDF/A modes
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolaasuni committed Sep 20, 2019
1 parent f4da1bc commit 6803091
Show file tree
Hide file tree
Showing 9 changed files with 68 additions and 39 deletions.
9 changes: 6 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
language: php
dist: trusty

sudo: false

Expand All @@ -13,12 +12,11 @@ branches:
- develop

php:
- 5.4
- 5.5
- 5.6
- 7.0
- 7.1
- 7.2
- 7.3
- hhvm-3.18
- hhvm-nightly
- nightly
Expand All @@ -27,6 +25,11 @@ matrix:
allow_failures:
- php: hhvm-nightly
- php: nightly
include:
- os: linux
dist: trusty
language: php
php: 5.4

addons:
apt:
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*
* SOFTWARE : tc-lib-pdf
* AUTHOR : Nicola Asuni <info@tecnick.com>
* COPYRIGHT : 2002-2018 Nicola Asuni - Tecnick.com LTD
* COPYRIGHT : 2002-2019 Nicola Asuni - Tecnick.com LTD
**********************************************************************

This is free software: you can redistribute it and/or modify it
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ BUT THE CORE LIBRARY STILL REQUIRES A SIGNIFICANT AMOUNT OF WORK TO BE COMPLETED
* **category** Library
* **package** \Com\Tecnick\Pdf
* **author** Nicola Asuni <info@tecnick.com>
* **copyright** 2002-2018 Nicola Asuni - Tecnick.com LTD
* **copyright** 2002-2019 Nicola Asuni - Tecnick.com LTD
* **license** http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
* **link** https://tcpdf.org
* **source** https://github.com/tecnickcom/tc-lib-pdf
Expand Down
20 changes: 10 additions & 10 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,16 @@
"php": ">=5.4",
"ext-date": "*",
"ext-pcre": "*",
"tecnickcom/tc-lib-barcode": "^1.15.12",
"tecnickcom/tc-lib-color": "^1.12.12",
"tecnickcom/tc-lib-pdf-image": "^1.2.8",
"tecnickcom/tc-lib-pdf-font": "^1.8.3",
"tecnickcom/tc-lib-file": "^1.6.8",
"tecnickcom/tc-lib-pdf-encrypt": "^1.5.7",
"tecnickcom/tc-lib-unicode-data": "^1.6.8",
"tecnickcom/tc-lib-unicode": "^1.3.8",
"tecnickcom/tc-lib-pdf-page": "^2.4.7",
"tecnickcom/tc-lib-pdf-graph": "^1.4.8"
"tecnickcom/tc-lib-barcode": "^1.15.15",
"tecnickcom/tc-lib-color": "^1.12.13",
"tecnickcom/tc-lib-pdf-image": "^1.2.9",
"tecnickcom/tc-lib-pdf-font": "^1.8.5",
"tecnickcom/tc-lib-file": "^1.6.12",
"tecnickcom/tc-lib-pdf-encrypt": "^1.5.8",
"tecnickcom/tc-lib-unicode-data": "^1.6.9",
"tecnickcom/tc-lib-unicode": "^1.3.9",
"tecnickcom/tc-lib-pdf-page": "^2.4.8",
"tecnickcom/tc-lib-pdf-graph": "^1.4.9"
},
"require-dev": {
"apigen/apigen": "^4.1.2",
Expand Down
2 changes: 1 addition & 1 deletion resources/debian/control
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ Vcs-Git: https://github.com/~#VENDOR#~/~#PROJECT#~.git
Package: ~#PKGNAME#~
Provides: php-~#PROJECT#~
Architecture: all
Depends: php (>= 5.4.0), php-date, php-tecnickcom-tc-lib-barcode (<< 2.0.0), php-tecnickcom-tc-lib-barcode (>=1.15.12), php-tecnickcom-tc-lib-color (<< 2.0.0), php-tecnickcom-tc-lib-color (>=1.12.12), php-tecnickcom-tc-lib-pdf-image (<< 2.0.0), php-tecnickcom-tc-lib-pdf-image (>=1.2.8), php-tecnickcom-tc-lib-pdf-font (<< 2.0.0), php-tecnickcom-tc-lib-pdf-font (>=1.8.3), php-tecnickcom-tc-lib-file (<< 2.0.0), php-tecnickcom-tc-lib-file (>=1.6.8), php-tecnickcom-tc-lib-pdf-encrypt (<< 2.0.0), php-tecnickcom-tc-lib-pdf-encrypt (>=1.5.7), php-tecnickcom-tc-lib-unicode-data (<< 2.0.0), php-tecnickcom-tc-lib-unicode-data (>=1.6.8), php-tecnickcom-tc-lib-unicode (<< 2.0.0), php-tecnickcom-tc-lib-unicode (>=1.3.8), php-tecnickcom-tc-lib-pdf-page (<< 3.0.0), php-tecnickcom-tc-lib-pdf-page (>=2.4.7), php-tecnickcom-tc-lib-pdf-graph (<< 2.0.0), php-tecnickcom-tc-lib-pdf-graph (>=1.4.8), ${misc:Depends}
Depends: php (>= 5.4.0), php-date, php-tecnickcom-tc-lib-barcode (<< 2.0.0), php-tecnickcom-tc-lib-barcode (>=1.15.15), php-tecnickcom-tc-lib-color (<< 2.0.0), php-tecnickcom-tc-lib-color (>=1.12.13), php-tecnickcom-tc-lib-pdf-image (<< 2.0.0), php-tecnickcom-tc-lib-pdf-image (>=1.2.9), php-tecnickcom-tc-lib-pdf-font (<< 2.0.0), php-tecnickcom-tc-lib-pdf-font (>=1.8.5), php-tecnickcom-tc-lib-file (<< 2.0.0), php-tecnickcom-tc-lib-file (>=1.6.12), php-tecnickcom-tc-lib-pdf-encrypt (<< 2.0.0), php-tecnickcom-tc-lib-pdf-encrypt (>=1.5.8), php-tecnickcom-tc-lib-unicode-data (<< 2.0.0), php-tecnickcom-tc-lib-unicode-data (>=1.6.9), php-tecnickcom-tc-lib-unicode (<< 2.0.0), php-tecnickcom-tc-lib-unicode (>=1.3.9), php-tecnickcom-tc-lib-pdf-page (<< 3.0.0), php-tecnickcom-tc-lib-pdf-page (>=2.4.8), php-tecnickcom-tc-lib-pdf-graph (<< 2.0.0), php-tecnickcom-tc-lib-pdf-graph (>=1.4.9), ${misc:Depends}
Description: PHP Barcode library
This library includes PHP classes to generate PDF documents.
20 changes: 10 additions & 10 deletions resources/rpm/rpm.spec
Original file line number Diff line number Diff line change
Expand Up @@ -20,25 +20,25 @@ Requires: php(language) >= 5.4.0
Requires: php-date
Requires: php-pcre
Requires: php-composer(%{c_vendor}/tc-lib-barcode) < 2.0.0
Requires: php-composer(%{c_vendor}/tc-lib-barcode >= 1.15.12
Requires: php-composer(%{c_vendor}/tc-lib-barcode >= 1.15.15
Requires: php-composer(%{c_vendor}/tc-lib-color) < 2.0.0
Requires: php-composer(%{c_vendor}/tc-lib-color) >= 1.12.12
Requires: php-composer(%{c_vendor}/tc-lib-color) >= 1.12.13
Requires: php-composer(%{c_vendor}/tc-lib-pdf-image) < 2.0.0
Requires: php-composer(%{c_vendor}/tc-lib-pdf-image >= 1.2.8
Requires: php-composer(%{c_vendor}/tc-lib-pdf-image >= 1.2.9
Requires: php-composer(%{c_vendor}/tc-lib-pdf-font) < 2.0.0
Requires: php-composer(%{c_vendor}/tc-lib-pdf-font >= 1.8.3
Requires: php-composer(%{c_vendor}/tc-lib-pdf-font >= 1.8.5
Requires: php-composer(%{c_vendor}/tc-lib-file) < 2.0.0
Requires: php-composer(%{c_vendor}/tc-lib-file >= 1.6.8
Requires: php-composer(%{c_vendor}/tc-lib-file >= 1.6.12
Requires: php-composer(%{c_vendor}/tc-lib-pdf-encrypt) < 2.0.0
Requires: php-composer(%{c_vendor}/tc-lib-pdf-encrypt >= 1.5.7
Requires: php-composer(%{c_vendor}/tc-lib-pdf-encrypt >= 1.5.8
Requires: php-composer(%{c_vendor}/tc-lib-unicode-data) < 2.0.0
Requires: php-composer(%{c_vendor}/tc-lib-unicode-data >= 1.6.8
Requires: php-composer(%{c_vendor}/tc-lib-unicode-data >= 1.6.9
Requires: php-composer(%{c_vendor}/tc-lib-unicode) < 2.0.0
Requires: php-composer(%{c_vendor}/tc-lib-unicode >= 1.3.8
Requires: php-composer(%{c_vendor}/tc-lib-unicode >= 1.3.9
Requires: php-composer(%{c_vendor}/tc-lib-pdf-page) < 3.0.0
Requires: php-composer(%{c_vendor}/tc-lib-pdf-page >= 2.4.7
Requires: php-composer(%{c_vendor}/tc-lib-pdf-page >= 2.4.8
Requires: php-composer(%{c_vendor}/tc-lib-pdf-graph) < 2.0.0
Requires: php-composer(%{c_vendor}/tc-lib-pdf-graph >= 1.4.8
Requires: php-composer(%{c_vendor}/tc-lib-pdf-graph >= 1.4.9

Provides: php-composer(%{c_vendor}/%{gh_project}) = %{version}
Provides: php-%{gh_project} = %{version}
Expand Down
33 changes: 27 additions & 6 deletions src/MetaInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* @category Library
* @package Pdf
* @author Nicola Asuni <info@tecnick.com>
* @copyright 2002-2017 Nicola Asuni - Tecnick.com LTD
* @copyright 2002-2019 Nicola Asuni - Tecnick.com LTD
* @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
* @link https://github.com/tecnickcom/tc-lib-pdf
*
Expand All @@ -24,7 +24,7 @@
* @category Library
* @package Pdf
* @author Nicola Asuni <info@tecnick.com>
* @copyright 2002-2017 Nicola Asuni - Tecnick.com LTD
* @copyright 2002-2019 Nicola Asuni - Tecnick.com LTD
* @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
* @link https://github.com/tecnickcom/tc-lib-pdf
*/
Expand Down Expand Up @@ -96,6 +96,13 @@ abstract class MetaInfo extends \Com\Tecnick\Pdf\Output
*/
protected $custom_xmp = '';

/**
* Additional XMP RDF data to be appended just before the end of "rdf:RDF" tag.
*
* @var string
*/
protected $custom_xmp_rdf = '';

/**
* Set this to TRUE to add the default sRGB ICC color profile
*
Expand Down Expand Up @@ -216,7 +223,7 @@ public function setKeywords($keywords)
*/
public function setPDFVersion($version = '1.7')
{
if ($this->pdfa) { // PDF/A mode
if ($this->pdfa == 1) { // PDF/A 1 mode
$this->pdfver = '1.4';
return $this;
}
Expand Down Expand Up @@ -358,6 +365,19 @@ public function setExtraXMP($xmp)
return $this->setNonEmptyFieldValue('custom_xmp', $xmp);
}

/**
* Set additional XMP data to be appended just before the end of "rdf:RDF" tag.
*
* IMPORTANT:
* This data is added as-is without controls, so you have to validate your data before using this method.
*
* @param string $xmp Custom XMP data.
*/
public function setExtraXMPRDF($xmp)
{
return $this->setNonEmptyFieldValue('custom_xmp_rdf', $xmp);
}

/**
* Get the PDF output string for the XMP data object
*
Expand Down Expand Up @@ -417,10 +437,10 @@ protected function getOutXMP()

if ($this->pdfa) {
$xmp .= "\t\t".'<rdf:Description rdf:about="" xmlns:pdfaid="http://www.aiim.org/pdfa/ns/id/">'."\n"
."\t\t\t".'<pdfaid:part>1</pdfaid:part>'."\n"
."\t\t\t".'<pdfaid:part>'.$this->pdfa.'</pdfaid:part>'."\n"
."\t\t\t".'<pdfaid:conformance>B</pdfaid:conformance>'."\n"
."\t\t".'</rdf:Description>'."\n";
}
}

// XMP extension schemas
$xmp .= "\t\t".'<rdf:Description rdf:about="" xmlns:pdfaExtension="http://www.aiim.org/pdfa/ns/extension/" xmlns:pdfaSchema="http://www.aiim.org/pdfa/ns/schema#" xmlns:pdfaProperty="http://www.aiim.org/pdfa/ns/property#">'."\n"
Expand Down Expand Up @@ -476,8 +496,9 @@ protected function getOutXMP()
."\t\t\t\t".'</rdf:Bag>'."\n"
."\t\t\t".'</pdfaExtension:schemas>'."\n"
."\t\t".'</rdf:Description>'."\n"
.$this->custom_xmp_rdf."\n"
."\t".'</rdf:RDF>'."\n"
.$this->custom_xmp
.$this->custom_xmp."\n"
.'</x:xmpmeta>'."\n"
.'<?xpacket end="w"?>';
// @codingStandardsIgnoreEnd
Expand Down
5 changes: 3 additions & 2 deletions src/Output.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* @category Library
* @package Pdf
* @author Nicola Asuni <info@tecnick.com>
* @copyright 2002-2017 Nicola Asuni - Tecnick.com LTD
* @copyright 2002-2019 Nicola Asuni - Tecnick.com LTD
* @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
* @link https://github.com/tecnickcom/tc-lib-pdf
*
Expand All @@ -26,7 +26,7 @@
* @category Library
* @package Pdf
* @author Nicola Asuni <info@tecnick.com>
* @copyright 2002-2017 Nicola Asuni - Tecnick.com LTD
* @copyright 2002-2019 Nicola Asuni - Tecnick.com LTD
* @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
* @link https://github.com/tecnickcom/tc-lib-pdf
*
Expand Down Expand Up @@ -58,6 +58,7 @@ public function getOutPDFString()
.$startxref."\n"
.'%%EOF'."\n";
// @TODO: sign the document ...
// ...
return $out;
}

Expand Down
14 changes: 9 additions & 5 deletions src/Tcpdf.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,11 @@ class Tcpdf extends \Com\Tecnick\Pdf\ClassObjects
protected $kunit = 1.0;

/**
* True if we are in PDF/A mode.
* Version of the PDF/A mode or 0 otherwise.
*
* @var bool
* @var int
*/
protected $pdfa = false;
protected $pdfa = 0;

/**
* True if we are in PDF/X mode.
Expand Down Expand Up @@ -116,7 +116,7 @@ class Tcpdf extends \Com\Tecnick\Pdf\ClassObjects
* @param string $unit Unit of measure ('pt', 'mm', 'cm', 'in')
* @param bool $isunicode True if the document is in Unicode mode
* @param bool $subsetfont If true subset the embedded fonts to remove the unused characters
* @param string $mode PDF mode: "pdfa", "pdfx" or empty
* @param string $mode PDF mode: "pdfa1", "pdfa2", "pdfa3", "pdfx" or empty
* @param ObjEncrypt $encobj Encryption object
*/
public function __construct(
Expand All @@ -134,8 +134,12 @@ public function __construct(
$this->unit = $unit;
$this->isunicode = $isunicode;
$this->subsetfont = $subsetfont;
$this->pdfa = ($mode == 'pdfa');
$this->pdfx = ($mode == 'pdfx');
$matches = array('', '0');
$this->pdfa = 0;
if (preg_match('/^pdfa([1-3])$/', $mode, $matches) === 1) {
$this->pdfa = (int) $matches[1];
}
$this->setPDFVersion();
$this->encrypt = $encobj;
$this->initClassObjects();
Expand Down

0 comments on commit 6803091

Please sign in to comment.