diff --git a/lib/prince.php b/lib/prince.php index e6f3198..3d12228 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; @@ -33,6 +35,7 @@ class Prince private $pdfCreator; private $encrypt; private $encryptInfo; + private $profile; public function __construct($exePath) { @@ -330,7 +333,19 @@ public function setEncryptInfo($keyBits, } } + /** + * Set optional optional PDF profiles + * @see https://www.princexml.com/doc/pdf-profiles + * @example $princeWrapper->setProfile(PdfProfile::createX32002()); + * @param PdfProfile $profile + * @return self + */ + public function setProfile(PdfProfile $profile) + { + $this->profile = sprintf('%s', $profile); + return $this; + } // 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 +582,11 @@ private function getCommandLine() $cmdline .= '--encrypt ' . $this->encryptInfo; } + if( $this->profile != '' ) + { + $cmdline .= '--profile="'. $this->profile .'" '; + } + return $cmdline; } diff --git a/lib/readme.html b/lib/readme.html index 95c8592..a4584d9 100644 --- a/lib/readme.html +++ b/lib/readme.html @@ -94,6 +94,7 @@
setPDFCreatorsetEncryptsetEncryptInfosetProfile+public function setProfile(PdfProfile $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. +
+ +PdfProfile $profileCopyright © 2005-2013 YesLogic Pty. Ltd.
diff --git a/src/PrinceXMLPhp/PrinceWrapper.php b/src/PrinceXMLPhp/PrinceWrapper.php index 616f918..bd26ab7 100644 --- a/src/PrinceXMLPhp/PrinceWrapper.php +++ b/src/PrinceXMLPhp/PrinceWrapper.php @@ -1,6 +1,5 @@ @@ -8,11 +7,12 @@ * 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; class PrinceWrapper extends Prince { 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 @@ +