From 271701f0ddac9350336e46206d42e0af2147127a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Steffen=20J=C3=A4ckel?=
Date: Tue, 28 Mar 2017 11:29:32 +0200
Subject: [PATCH 1/9] Switch to vrsmedia namespace
---
composer.json | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/composer.json b/composer.json
index 7657e76..e6d1ac3 100644
--- a/composer.json
+++ b/composer.json
@@ -1,5 +1,5 @@
{
- "name": "gridonic/princexml-php",
+ "name": "vrsmedia/princexml-php",
"description": "PrinceXML PHP5 wrapper converted to follow the PSR-0 standard.",
"keywords": ["princexml", "xml"],
"license": "MIT",
From 2fc022ad9c9d26d289b9bd34bc131d9ecdc7c508 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Steffen=20J=C3=A4ckel?=
Date: Tue, 28 Mar 2017 14:19:10 +0200
Subject: [PATCH 2/9] Enable setProfile to library
---
lib/prince.php | 16 +++++++++++++++-
1 file changed, 15 insertions(+), 1 deletion(-)
diff --git a/lib/prince.php b/lib/prince.php
index e6f3198..f6308b3 100644
--- a/lib/prince.php
+++ b/lib/prince.php
@@ -33,6 +33,7 @@ class Prince
private $pdfCreator;
private $encrypt;
private $encryptInfo;
+ private $profile;
public function __construct($exePath)
{
@@ -330,7 +331,15 @@ public function setEncryptInfo($keyBits,
}
}
-
+ /**
+ * Set optional optional PDF profiles, which can be selected
+ * @see https://www.princexml.com/doc/pdf-profiles
+ * @param String $profile
+ */
+ public function setProfile($profile)
+ {
+ $this->profile = $profile;
+ }
// Convert an XML or HTML file to a PDF file.
// The name of the output PDF file will be the same as the name of the
@@ -567,6 +576,11 @@ private function getCommandLine()
$cmdline .= '--encrypt ' . $this->encryptInfo;
}
+ if( $this->profile != '' )
+ {
+ $cmdline .= '--profile="'. $this->profile .'" ';
+ }
+
return $cmdline;
}
From 9dd5c7969e5328df9d389b635955b02a16224081 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Steffen=20J=C3=A4ckel?=
Date: Tue, 28 Mar 2017 14:19:38 +0200
Subject: [PATCH 3/9] Ensure type-safe usage of setting available optional
PdfProfiles
---
src/PrinceXMLPhp/PrinceWrapper.php | 20 +++-
src/PrinceXMLPhp/Types/AbstractEnumType.php | 95 +++++++++++++++++++
.../Exceptions/InvalidEnumTypeException.php | 14 +++
src/PrinceXMLPhp/Types/PdfProfile.php | 92 ++++++++++++++++++
4 files changed, 218 insertions(+), 3 deletions(-)
create mode 100644 src/PrinceXMLPhp/Types/AbstractEnumType.php
create mode 100644 src/PrinceXMLPhp/Types/Exceptions/InvalidEnumTypeException.php
create mode 100644 src/PrinceXMLPhp/Types/PdfProfile.php
diff --git a/src/PrinceXMLPhp/PrinceWrapper.php b/src/PrinceXMLPhp/PrinceWrapper.php
index 616f918..0dabe21 100644
--- a/src/PrinceXMLPhp/PrinceWrapper.php
+++ b/src/PrinceXMLPhp/PrinceWrapper.php
@@ -1,6 +1,5 @@
@@ -8,13 +7,28 @@
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
+
namespace PrinceXMLPhp;
require_once __DIR__.'/../../lib/prince.php';
-use \Prince;
+use Prince;
+use PrinceXMLPhp\Types\PdfProfile;
class PrinceWrapper extends Prince
{
+ /**
+ * Set optional optional PDF profiles, which can be selected
+ * @see https://www.princexml.com/doc/pdf-profiles
+ * @example $princeWrapper->setProfile(Profile::createX32002());
+ * @param PdfProfile $profile
+ * @return PrinceWrapper
+ */
+ public function setProfile(PdfProfile $profile)
+ {
+ parent::setProfile(sprintf('%s', $profile));
+
+ return $this;
+ }
}
\ No newline at end of file
diff --git a/src/PrinceXMLPhp/Types/AbstractEnumType.php b/src/PrinceXMLPhp/Types/AbstractEnumType.php
new file mode 100644
index 0000000..251bfd8
--- /dev/null
+++ b/src/PrinceXMLPhp/Types/AbstractEnumType.php
@@ -0,0 +1,95 @@
+setValue($value);
+ }
+
+ /**
+ * Provides the data suitable for selecting correct enum value,
+ * e.g. list-based HTML elements.
+ * @return array
+ */
+ public function getListData()
+ {
+ return $this->getAllowedValues();
+ }
+
+ /**
+ * Must return the allowed values for this type.
+ *
+ * @return array
+ */
+ abstract protected function getAllowedValues();
+
+ /**
+ * Checks if the passed value is allowed.
+ *
+ * @param $value
+ * @return bool
+ */
+ final protected function isAllowed($value)
+ {
+ return in_array($value, $this->getAllowedValues(), true);
+ }
+
+ /**
+ * Returns the current value.
+ *
+ * @return mixed
+ */
+ final public function getValue()
+ {
+ return $this->value;
+ }
+
+ /**
+ * Sets the current value.
+ * @throws InvalidEnumTypeException If given value does not match
+ * @param mixed $value
+ */
+ final public function setValue($value)
+ {
+ if (!$this->isAllowed($value))
+ {
+ throw new InvalidEnumTypeException(
+ sprintf(
+ '"%s" is not allowed as a value for %s.',
+ $value,
+ get_class($this)
+ )
+ );
+ }
+ $this->value = $value;
+ }
+
+ /**
+ * @inheritdoc
+ */
+ final public function __toString()
+ {
+ return $this->value;
+ }
+
+}
\ No newline at end of file
diff --git a/src/PrinceXMLPhp/Types/Exceptions/InvalidEnumTypeException.php b/src/PrinceXMLPhp/Types/Exceptions/InvalidEnumTypeException.php
new file mode 100644
index 0000000..9a29240
--- /dev/null
+++ b/src/PrinceXMLPhp/Types/Exceptions/InvalidEnumTypeException.php
@@ -0,0 +1,14 @@
+
Date: Tue, 28 Mar 2017 14:19:54 +0200
Subject: [PATCH 4/9] Update Documentation
---
lib/readme.html | 27 +++++++++++++++++++++++++++
1 file changed, 27 insertions(+)
diff --git a/lib/readme.html b/lib/readme.html
index 95c8592..3b6a87e 100644
--- a/lib/readme.html
+++ b/lib/readme.html
@@ -94,6 +94,7 @@ Configuration methods
setPDFCreator
setEncrypt
setEncryptInfo
+setProfile
@@ -818,6 +819,32 @@ Configuration methods
+
+
+
+public function setProfile($profile)
+
+
+
+ Set optional pdf profile
+ Prince supports optional PDF profiles, which can be selected. Available profiles are:
+ PDF/A-1b,
+ PDF/A-3b,
+ PDF/X-1a:2001,
+ PDF/X-1a:2003,
+ PDF/X-3:2002,
+ PDF/X-3:2003,
+ PDF/X-4
+ More information here.
+
+
+
+ profile
+ - Pass a string to set one of the specific profiles.
+
+
+
+
Copyright © 2005-2013 YesLogic Pty. Ltd.
From 6600c15397ff6dfd334c1cc83e849e0b6e0102e2 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Steffen=20J=C3=A4ckel?=
Date: Tue, 28 Mar 2017 14:38:53 +0200
Subject: [PATCH 5/9] Fix Law of Demeter break (to fullfill Travis CI tests)
---
lib/prince.php | 10 ++++++++--
src/PrinceXMLPhp/PrinceWrapper.php | 14 --------------
2 files changed, 8 insertions(+), 16 deletions(-)
diff --git a/lib/prince.php b/lib/prince.php
index f6308b3..15c0b93 100644
--- a/lib/prince.php
+++ b/lib/prince.php
@@ -4,6 +4,8 @@
// Copyright 2005-2014 YesLogic Pty. Ltd.
// http://www.princexml.com
+use PrinceXMLPhp\Types\PdfProfile;
+
class Prince
{
private $exePath;
@@ -334,11 +336,15 @@ public function setEncryptInfo($keyBits,
/**
* Set optional optional PDF profiles, which can be selected
* @see https://www.princexml.com/doc/pdf-profiles
+ * @example $princeWrapper->setProfile(Profile::createX32002());
* @param String $profile
+ * @return self
*/
- public function setProfile($profile)
+ public function setProfile(PdfProfile $profile)
{
- $this->profile = $profile;
+ $this->profile = sprintf('%s', $profile);
+
+ return $this;
}
// Convert an XML or HTML file to a PDF file.
diff --git a/src/PrinceXMLPhp/PrinceWrapper.php b/src/PrinceXMLPhp/PrinceWrapper.php
index 0dabe21..bd26ab7 100644
--- a/src/PrinceXMLPhp/PrinceWrapper.php
+++ b/src/PrinceXMLPhp/PrinceWrapper.php
@@ -13,22 +13,8 @@
require_once __DIR__.'/../../lib/prince.php';
use Prince;
-use PrinceXMLPhp\Types\PdfProfile;
class PrinceWrapper extends Prince
{
- /**
- * Set optional optional PDF profiles, which can be selected
- * @see https://www.princexml.com/doc/pdf-profiles
- * @example $princeWrapper->setProfile(Profile::createX32002());
- * @param PdfProfile $profile
- * @return PrinceWrapper
- */
- public function setProfile(PdfProfile $profile)
- {
- parent::setProfile(sprintf('%s', $profile));
-
- return $this;
- }
}
\ No newline at end of file
From 270509f4722ecaa9843b55d5cffc490030b17758 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Steffen=20J=C3=A4ckel?=
Date: Tue, 28 Mar 2017 14:40:16 +0200
Subject: [PATCH 6/9] Update Documentation
---
lib/prince.php | 2 +-
lib/readme.html | 6 +++---
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/lib/prince.php b/lib/prince.php
index 15c0b93..de1cfd3 100644
--- a/lib/prince.php
+++ b/lib/prince.php
@@ -337,7 +337,7 @@ public function setEncryptInfo($keyBits,
* Set optional optional PDF profiles, which can be selected
* @see https://www.princexml.com/doc/pdf-profiles
* @example $princeWrapper->setProfile(Profile::createX32002());
- * @param String $profile
+ * @param PdfProfile $profile
* @return self
*/
public function setProfile(PdfProfile $profile)
diff --git a/lib/readme.html b/lib/readme.html
index 3b6a87e..a4584d9 100644
--- a/lib/readme.html
+++ b/lib/readme.html
@@ -822,7 +822,7 @@ Configuration methods
-public function setProfile($profile)
+public function setProfile(PdfProfile $profile)
@@ -839,8 +839,8 @@
Configuration methods
- profile
- - Pass a string to set one of the specific profiles.
+ PdfProfile $profile
+ - Pass a PdfProfile object to set one of the specific profiles.
From b5662b3491201c0a06b1069252756486b5456ed6 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Steffen=20J=C3=A4ckel?=
Date: Tue, 28 Mar 2017 14:44:57 +0200
Subject: [PATCH 7/9] Get back to original name
---
composer.json | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/composer.json b/composer.json
index e6d1ac3..7657e76 100644
--- a/composer.json
+++ b/composer.json
@@ -1,5 +1,5 @@
{
- "name": "vrsmedia/princexml-php",
+ "name": "gridonic/princexml-php",
"description": "PrinceXML PHP5 wrapper converted to follow the PSR-0 standard.",
"keywords": ["princexml", "xml"],
"license": "MIT",
From d20a8c5f41bf202feabaa264c665587613f89989 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Steffen=20J=C3=A4ckel?=
Date: Tue, 28 Mar 2017 15:00:31 +0200
Subject: [PATCH 8/9] Fix Typo
---
lib/prince.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/prince.php b/lib/prince.php
index de1cfd3..8608482 100644
--- a/lib/prince.php
+++ b/lib/prince.php
@@ -336,7 +336,7 @@ public function setEncryptInfo($keyBits,
/**
* Set optional optional PDF profiles, which can be selected
* @see https://www.princexml.com/doc/pdf-profiles
- * @example $princeWrapper->setProfile(Profile::createX32002());
+ * @example $princeWrapper->setProfile(PdfProfile::createX32002());
* @param PdfProfile $profile
* @return self
*/
From ae7132ab164f9b084a51c8616c064b99b839c29d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Steffen=20J=C3=A4ckel?=
Date: Tue, 28 Mar 2017 15:01:01 +0200
Subject: [PATCH 9/9] Fix Documentation
---
lib/prince.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/prince.php b/lib/prince.php
index 8608482..3d12228 100644
--- a/lib/prince.php
+++ b/lib/prince.php
@@ -334,7 +334,7 @@ public function setEncryptInfo($keyBits,
}
/**
- * Set optional optional PDF profiles, which can be selected
+ * Set optional optional PDF profiles
* @see https://www.princexml.com/doc/pdf-profiles
* @example $princeWrapper->setProfile(PdfProfile::createX32002());
* @param PdfProfile $profile