From e3327694abb3a823a9666737f6fbabdc535b0121 Mon Sep 17 00:00:00 2001
From: Aleksander Grinin
- * Decodes HIBC LIC codetext.
- *
- * Decodes HIBC PAS codetext.
- *
- * Interface for complex codetext used with ComplexBarcodeGenerator.
- *
- * Base class for encoding and decoding the text embedded in the HIBC LIC code.
- *
- * This sample shows how to decode raw HIBC LIC codetext to HIBCLICComplexCodetext instance.
- *
- * $reader = new BarCodeReader("c:\\test.png", null, DecodeType::HIBC_AZTEC_LIC);
- * {
- * foreach($reader->readBarCodes() as $result)
- * {
- * $resultHIBCLICComplexCodetext = ComplexCodetextReader::tryDecodeHIBCLIC($result->getCodeText());
- * print("BarCode Type: " . $resultMaxiCodeCodetext->getBarcodeType());
- * print("BarCode CodeText: " . $resultMaxiCodeCodetext->getConstructedCodetext());
- * }
- * }
- *
- *
- * Constructs codetext - *
- * @return string Constructed codetext - */ - public abstract function getConstructedCodetext() : string; - - /** - *- * Initializes instance from constructed codetext. - *
- * @param string constructedCodetext Constructed codetext. - */ - public abstract function initFromString(string $constructedCodetext) : void; - - /** - *- * Gets or sets barcode type. HIBC LIC codetext can be encoded using HIBCCode39LIC, HIBCCode128LIC, HIBCAztecLIC, HIBCDataMatrixLIC and HIBCQRLIC encode types. - * Default value: HIBCCode39LIC. - *
- * @return int Barcode type. - */ - public function getBarcodeType() : int - { - return $this->getIComplexCodetextDTO()->barcodeType; - } - /** - *- * Gets or sets barcode type. HIBC LIC codetext can be encoded using HIBCCode39LIC, HIBCCode128LIC, HIBCAztecLIC, HIBCDataMatrixLIC and HIBCQRLIC encode types. - * Default value: HIBCCode39LIC. - *
- * @return int Barcode type. - */ - public function setBarcodeType(int $value) : void - { - $this->getIComplexCodetextDTO()->barcodeType = $value; - } -} - - -/** - *- * Class for encoding and decoding the text embedded in the HIBC LIC code which stores primary and secodary data. - *
- */ -class HIBCLICCombinedCodetext extends HIBCLICComplexCodetext -{ - function __construct() - { - $this->setIComplexCodetextDTO($this->obtainDto()); - $this->getIComplexCodetextDTO()->complexCodetextType = ComplexCodetextType::HIBCLICCombinedCodetext; - $this->initFieldsFromDto(); - } - - static function construct($javaClass) : HIBCLICCombinedCodetext - { - $obj = new HIBCLICCombinedCodetext(); - $obj->setIComplexCodetextDTO($javaClass); - $obj->initFieldsFromDto(); - return $obj; - } - - public function obtainDto(...$args) - { - $thriftConnection = new ThriftConnection(); - $client = $thriftConnection->openConnection(); - $complexCodetextDTO = $client->HIBCLICCombinedCodetext_ctor(); - $thriftConnection->closeConnection(); - return $complexCodetextDTO; - } - - public function initFieldsFromDto() - { - $this->auto_PrimaryData = PrimaryData::construct($this->getIComplexCodetextDTO()->primaryData); - $this->auto_SecondaryAndAdditionalData = SecondaryAndAdditionalData::construct($this->getIComplexCodetextDTO()->secondaryAndAdditionalData); - } - - /** - *- * This sample shows how to encode and decode HIBC LIC using HIBCLICCombinedCodetext. - *- * - * $combinedCodetext = new HIBCLICCombinedCodetext(); - * $combinedCodetext->setBarcodeType(EncodeTypes::HIBCQRLIC); - * $combinedCodetext->setPrimaryData(new PrimaryData()); - * $combinedCodetext->getPrimaryData()->setProductOrCatalogNumber("12345"); - * $combinedCodetext->getPrimaryData()->setLabelerIdentificationCode("A999"); - * $combinedCodetext->getPrimaryData()->setUnitOfMeasureID(1); - * $combinedCodetext->setSecondaryAndAdditionalData(new SecondaryAndAdditionalData()); - * $combinedCodetext->getSecondaryAndAdditionalData()->setExpiryDate(new Date()); - * $combinedCodetext->getSecondaryAndAdditionalData()->setExpiryDateFormat(HIBCLICDateFormat.MMDDYY); - * $combinedCodetext->getSecondaryAndAdditionalData()->setQuantity(30); - * $combinedCodetext->getSecondaryAndAdditionalData()->setLotNumber("LOT123"); - * $combinedCodetext->getSecondaryAndAdditionalData()->setSerialNumber("SERIAL123"); - * $combinedCodetext->getSecondaryAndAdditionalData()->setDateOfManufacture(new Date()); - * ComplexBarcodeGenerator generator = new ComplexBarcodeGenerator(combinedCodetext); - * { - * $image = $generator->generateBarCodeImage(BarCodeImageFormat::PNG); - * $reader = new BarCodeReader($image, null, DecodeType::HIBCQRLIC); - * { - * $reader->readBarCodes(); - * $codetext = $reader->getFoundBarCodes()[0]->getCodeText(); - * $result = ComplexCodetextReader::tryDecodeHIBCLIC($codetext) ; - * print("Product or catalog number: " . $result->getPrimaryData()->getProductOrCatalogNumber()); - * print("Labeler identification code: " . $result->getPrimaryData()->getLabelerIdentificationCode()); - * print("Unit of measure ID: " . $result->getPrimaryData()->getUnitOfMeasureID()); - * print("Expiry date: " . $result->getSecondaryAndAdditionalData()->getExpiryDate()); - * print("Quantity: " . $result->getSecondaryAndAdditionalData()->getQuantity()); - * print("Lot number: " . $result->getSecondaryAndAdditionalData()->getLotNumber()); - * print("Serial number: " . $result->getSecondaryAndAdditionalData()->getSerialNumber()); - * print("Date of manufacture: " . $result->getSecondaryAndAdditionalData()->getDateOfManufacture()); - * } - * } - *- *
- * Identifies primary data. - *
- */ - public function getPrimaryData() : PrimaryData - { - return $this->auto_PrimaryData; - } - - /** - *- * Identifies primary data. - *
- */ - public function setPrimaryData(PrimaryData $value) : void - { - $this->getIComplexCodetextDTO()->primaryData = ($value->getPrimaryDataDto()); - $this->auto_PrimaryData = $value; - } - - private $auto_PrimaryData; - - /** - *- * Identifies secondary and additional supplemental data. - *
- */ - public function getSecondaryAndAdditionalData() : SecondaryAndAdditionalData - { - return $this->auto_SecondaryAndAdditionalData; - } - - /** - *- * Identifies secondary and additional supplemental data. - *
- */ - public function setSecondaryAndAdditionalData(SecondaryAndAdditionalData $value) : void - { - $this->getIComplexCodetextDTO()->secondaryAndAdditionalData = ($value->getSecondaryAndAdditionalDataDto()); - $this->auto_SecondaryAndAdditionalData = $value; - } - - private $auto_SecondaryAndAdditionalData; - - /** - *- * Constructs codetext - *
- * - * @return string Constructed codetext - */ - public function getConstructedCodetext() : string - { - $thriftConnection = new ThriftConnection(); - $client = $thriftConnection->openConnection(); - $constructedCodetext = $client->HIBCLICCombinedCodetext_getConstructedCodetext($this->getIComplexCodetextDTO()); - $thriftConnection->closeConnection(); - return $constructedCodetext; - } - - /** - *- * Initializes instance from constructed codetext. - *
- * - * @param string constructedCodetext Constructed codetext. - * @return void - */ - public function initFromString(string $constructedCodetext) : void - { - $thriftConnection = new ThriftConnection(); - $client = $thriftConnection->openConnection(); - $HIBCLICCombinedCodetextDTO = $client->HIBCLICCombinedCodetext_initFromString($this->getIComplexCodetextDTO(), $constructedCodetext); - $this->setIComplexCodetextDTO($HIBCLICCombinedCodetextDTO); - $thriftConnection->closeConnection(); - $this->initFieldsFromDto(); - } - - /** - *- * Returns a value indicating whether this instance is equal to a specified {@code HIBCLICCombinedCodetext} value. - *
- * - * @param obj An {@code HIBCLICCombinedCodetext} value to compare to this instance. - * @return {@code true} if obj has the same value as this instance; otherwise, {@code false}. - */ - public function equals(HIBCLICCombinedCodetext $obj) : bool - { - $thriftConnection = new ThriftConnection(); - $client = $thriftConnection->openConnection(); - $isEqual = $client->HIBCLICCombinedCodetext_equals($this->getIComplexCodetextDTO(), $obj->getIComplexCodetextDTO()); - $thriftConnection->closeConnection(); - return $isEqual; - } -} - - -/** - *- * Class for encoding and decoding the text embedded in the HIBC LIC code which stores primary data. - *
- */ -class HIBCLICPrimaryDataCodetext extends HIBCLICComplexCodetext -{ - - function __construct() - { - $this->setIComplexCodetextDTO($this->obtainDto()); - $this->getIComplexCodetextDTO()->complexCodetextType = ComplexCodetextType::HIBCLICPrimaryDataCodetext; - $this->initFieldsFromDto(); - } - - static function construct($HIBCLICPrimaryDataCodetextDto) : HIBCLICPrimaryDataCodetext - { - $obj = new HIBCLICPrimaryDataCodetext(); - $obj->setIComplexCodetextDTO($HIBCLICPrimaryDataCodetextDto); - return $obj; - } - - public function obtainDto(...$args) - { - $thriftConnection = new ThriftConnection(); - $client = $thriftConnection->openConnection(); - $complexCodetextDTO = $client->HIBCLICPrimaryDataCodetext_ctor(); - $thriftConnection->closeConnection(); - return $complexCodetextDTO; - } - - public function initFieldsFromDto() - { - $this->primaryData = PrimaryData::construct($this->getIComplexCodetextDTO()->primaryData); - } - - private $primaryData; - - /** - *- * This sample shows how to encode and decode HIBC LIC using HIBCLICPrimaryCodetext. - *- * $complexCodetext = new HIBCLICPrimaryCodetext(); - * $complexCodetext->setBarcodeType(EncodeTypes::HIBCQRLIC); - * $complexCodetext->setData(new PrimaryData()); - * $complexCodetext->getData()->setProductOrCatalogNumber("12345"); - * $complexCodetext->getData()->setLabelerIdentificationCode("A999"); - * $complexCodetext->getData()->setUnitOfMeasureID(1); - * $generator = new ComplexBarcodeGenerator($complexCodetext); - * { - * $image = $generator->generateBarCodeImage(BarCodeImageFormat::PNG); - * $reader = new BarCodeReader($image, null, DecodeType::HIBCQRLIC); - * { - * $reader->readBarCodes(); - * $codetext = $reader->getFoundBarCodes()[0]->getCodeText(); - * $result = ComplexCodetextReader::tryDecodeHIBCLIC($codetext) ; - * print("Product or catalog number: " . $result->getData()->getProductOrCatalogNumber()); - * print("Labeler identification code: " . $result->getData()->getLabelerIdentificationCode()); - * print("Unit of measure ID: " . $result->getData()->getUnitOfMeasureID()); - * } - * } - *- *
- * Identifies primary data. - *
- */ - public function getData() : PrimaryData - { - return $this->primaryData; - } - - /** - *- * Identifies primary data. - *
- */ - public function setData(PrimaryData $value) : void - { - $this->getIComplexCodetextDTO()->primaryData = $value->getPrimaryDataDto(); - $this->primaryData = $value; - } - - /** - *- * Constructs codetext - *
- * - * @return string Constructed codetext - */ - public function getConstructedCodetext() : string - { - $thriftConnection = new ThriftConnection(); - $client = $thriftConnection->openConnection(); - $constructedCodetext = $client->HIBCLICPrimaryDataCodetext_getConstructedCodetext($this->getIComplexCodetextDTO()); - $thriftConnection->closeConnection(); - return $constructedCodetext; - } - - /** - *- * Initializes instance from constructed codetext. - *
- * - * @param string constructedCodetext Constructed codetext. - */ - public function initFromString(string $constructedCodetext) : void - { - $thriftConnection = new ThriftConnection(); - $client = $thriftConnection->openConnection(); - $HIBCLICPrimaryDataCodetextDTO = $client->HIBCLICPrimaryDataCodetext_initFromString($this->getIComplexCodetextDTO(), $constructedCodetext); - $this->setIComplexCodetextDTO($HIBCLICPrimaryDataCodetextDTO); - $thriftConnection->closeConnection(); - $this->initFieldsFromDto(); - } - - /** - *- * Returns a value indicating whether this instance is equal to a specified {@code HIBCLICPrimaryDataCodetext} value. - *
- * - * @param bool obj An {@code HIBCLICPrimaryDataCodetext} value to compare to this instance. - * @return {@code true} if obj has the same value as this instance; otherwise, {@code false}. - */ - function equals(HIBCLICPrimaryDataCodetext $obj) : bool - { - $thriftConnection = new ThriftConnection(); - $client = $thriftConnection->openConnection(); - $isEqual = $client->HIBCLICPrimaryDataCodetext_equals($this->getIComplexCodetextDTO(), $obj->getIComplexCodetextDTO()); - $thriftConnection->closeConnection(); - return $isEqual; - } -} - -/** - * Class for encoding and decoding the text embedded in the HIBC LIC code which stores seconday data. - * @example - * This sample shows how to encode and decode HIBC LIC using HIBCLICSecondaryAndAdditionalDataCodetext. - * - * @code - * $complexCodetext = new HIBCLICSecondaryAndAdditionalDataCodetext(); - * $complexCodetext->setBarcodeType(EncodeTypes::HIBCQRLIC); - * $complexCodetext->setLinkCharacter('L'); - * $complexCodetext->setData(new SecondaryAndAdditionalData()); - * $complexCodetext->getData()->setExpiryDate(new Date()); - * $complexCodetext->getData()->setExpiryDateFormat(HIBCLICDateFormat.MMDDYY); - * $complexCodetext->getData()->setQuantity(30); - * $complexCodetext->getData()->setLotNumber("LOT123"); - * $complexCodetext->getData()->setSerialNumber("SERIAL123"); - * $complexCodetext->getData()->setDateOfManufacture(new Date()); - * $generator = new ComplexBarcodeGenerator($complexCodetext); - * $image = $generator->generateBarCodeImage(BarcodeImageFormat::PNG); - * $reader = new BarCodeReader($image, null, DecodeType::HIBCQRLIC); - * $reader->readBarCodes(); - * $codetext = $reader->getFoundBarCodes()[0]->getCodeText(); - * $result = ComplexCodetextReader::tryDecodeHIBCLIC($codetext); - * print("Expiry date: " . $result->getData()->getExpiryDate()); - * print("Quantity: " . $result->getData()->getQuantity()); - * print("Lot number: " . $result->getData()->getLotNumber()); - * print("Serial number: " . $result->getData()->getSerialNumber()); - * print("Date of manufacture: " . $result->getData()->getDateOfManufacture()); - * - * - */ -class HIBCLICSecondaryAndAdditionalDataCodetext extends HIBCLICComplexCodetext -{ - private $data; - - function __construct() - { - $this->setIComplexCodetextDTO($this->obtainDto()); - $this->getIComplexCodetextDTO()->complexCodetextType = ComplexCodetextType::HIBCLICSecondaryAndAdditionalDataCodetext; - $this->initFieldsFromDto(); - } - - static function construct($java_class) : HIBCLICSecondaryAndAdditionalDataCodetext - { - $obj = new HIBCLICSecondaryAndAdditionalDataCodetext(); - $obj->setIComplexCodetextDTO($java_class); - $obj->initFieldsFromDto(); - return $obj; - } - - public function obtainDto(...$args) - { - $thriftConnection = new ThriftConnection(); - $client = $thriftConnection->openConnection(); - $HIBCLICSecondaryAndAdditionalDataCodetextDTO = $client->HIBCLICSecondaryAndAdditionalDataCodetext_ctor(); - $thriftConnection->closeConnection(); - return $HIBCLICSecondaryAndAdditionalDataCodetextDTO; - } - - public function initFieldsFromDto() - { - $this->data = SecondaryAndAdditionalData::construct($this->getIComplexCodetextDTO()->secondaryAndAdditionalData); - } - - /** - *- * Identifies secodary and additional supplemental data. - *
- */ - public function getData() : SecondaryAndAdditionalData - { - return $this->data; - } - - /** - *- * Identifies secodary and additional supplemental data. - *
- */ - public function setData(SecondaryAndAdditionalData $value) : void - { - $this->getIComplexCodetextDTO()->secondaryAndAdditionalData = ($value->getSecondaryAndAdditionalDataDto()); - $this->data = $value; - } - - /** - *- * Identifies link character. - *
- */ - public function getLinkCharacter() : string - { - return $this->getIComplexCodetextDTO()->linkCharacter; - } - - /** - *- * Identifies link character. - *
- */ - public function setLinkCharacter(string $value) : void - { - $this->getIComplexCodetextDTO()->linkCharacter = $value; - } - - /** - *- * Constructs codetext - *
- * - * @return string Constructed codetext - */ - public function getConstructedCodetext() : string - { - $thriftConnection = new ThriftConnection(); - $client = $thriftConnection->openConnection(); - $constructedCodetext = $client->HIBCLICSecondaryAndAdditionalDataCodetext_getConstructedCodetext($this->getIComplexCodetextDTO()); - $thriftConnection->closeConnection(); - return $constructedCodetext; - } - - /** - *- * Initializes instance from constructed codetext. - *
- * - * @param string constructedCodetext Constructed codetext. - */ - function initFromString(string $constructedCodetext) : void - { - $thriftConnection = new ThriftConnection(); - $client = $thriftConnection->openConnection(); - $HIBCLICSecondaryAndAdditionalDataCodetext = $client->HIBCLICSecondaryAndAdditionalDataCodetext_initFromString($this->getIComplexCodetextDTO(), $constructedCodetext); - $this->setIComplexCodetextDTO($HIBCLICSecondaryAndAdditionalDataCodetext); - $thriftConnection->closeConnection(); - $this->initFieldsFromDto(); - } - - /** - *- * Returns a value indicating whether this instance is equal to a specified {@code HIBCLICSecondaryAndAdditionalDataCodetext} value. - *
- * - * @param obj An {@code HIBCLICSecondaryAndAdditionalDataCodetext} value to compare to this instance. - * @return bool true if obj has the same value as this instance; otherwise, false - */ - public function equals(HIBCLICSecondaryAndAdditionalDataCodetext $obj) : bool - { - $thriftConnection = new ThriftConnection(); - $client = $thriftConnection->openConnection(); - $isEqual = $client->HIBCLICSecondaryAndAdditionalDataCodetext_equals($this->getIComplexCodetextDTO(), $obj->getIComplexCodetextDTO()); - $thriftConnection->closeConnection(); - return $isEqual; - } -} - -/** - *- * Class for encoding and decoding the text embedded in the HIBC PAS code. - *
- */ -class HIBCPASCodetext extends IComplexCodetext -{ - private $_recordsList; - function __construct() - { - $this->setIComplexCodetextDTO($this->obtainDto()); - $this->initFieldsFromDto(); - } - - /** - *- * This sample shows how to encode and decode HIBC PAS using HIBCPASCodetext. - *- * - * $complexCodetext = new HIBCPASComplexCodetext(); - * $complexCodetext->setDataLocation(HIBCPASDataLocation::PATIENT); - * $complexCodetext->addRecord(HIBCPASDataType::LABELER_IDENTIFICATION_CODE, "A123"); - * $complexCodetext->addRecord(HIBCPASDataType::MANUFACTURER_SERIAL_NUMBER, "SERIAL123"); - * $complexCodetext->setBarcodeType(EncodeTypes::HIBC_DATA_MATRIX_PAS); - * $generator = new ComplexBarcodeGenerator($complexCodetext); - * { - * BarCodeReader reader = new BarCodeReader($generator->generateBarCodeImage(BarCodeImageFormat::PNG), null, DecodeType::HIBC_DATA_MATRIX_PAS); - * { - * $reader->readBarCodes(); - * $codetext = $reader->getFoundBarCodes()[0]->getCodeText(); - * $readCodetext = ComplexCodetextReader::tryDecodeHIBCPAS($codetext); - * print("Data location: " . $readCodetext->getDataLocation()); - * print("Data type: " . $readCodetext->getRecords()[0]->getDataType()); - * print("Data: " . $readCodetext->getRecords()[0]->getData()); - * print("Data type: " . $readCodetext->getRecords()[1]->getDataType()); - * print("Data: " . $readCodetext->getRecords()[1]->getData()); - * } - * } - *- *
- * HIBCPASRecord constructor - *
- */ - static function construct($HIBCPASCodetextDto) : HIBCPASCodetext - { - $obj = new HIBCPASCodetext(); - $obj->setIComplexCodetextDTO($HIBCPASCodetextDto); - $obj->initFieldsFromDto(); - return $obj; - } - - public function obtainDto(...$args) - { - $thriftConnection = new ThriftConnection(); - $client = $thriftConnection->openConnection(); - $dtoRef = $client->HIBCPASCodetext_ctor(); - $thriftConnection->closeConnection(); - return $dtoRef; - } - - public function initFieldsFromDto() - { - $this->_recordsList = array(); - foreach($this->getIComplexCodetextDTO()->records as $recordDTO) - array_push($this->_recordsList, HIBCPASRecord::construct($recordDTO)); - $this->getIComplexCodetextDTO()->complexCodetextType = ComplexCodetextType::HIBCPASCodetext; - } - - /** - *- * Gets or sets barcode type. HIBC PAS codetext can be encoded using HIBCCode39PAS, HIBCCode128PAS, HIBCAztec:PAS, HIBCDataMatrixPAS and HIBCQRPAS encode types. - * Default value: HIBCCode39PAS. - *
- * @param int $value Barcode type. - * @return void - */ - public function setBarcodeType(int $value) : void - { - $this->getIComplexCodetextDTO()->barcodeType = $value; - } - - /** - *- * Identifies data location. - *
- */ - public function getDataLocation() : int - { - return $this->getIComplexCodetextDTO()->dataLocation; - } - /** - *- * Identifies data location. - *
- */ - public function setDataLocation(int $value) : void - { - $this->getIComplexCodetextDTO()->dataLocation = $value; - } - - /** - *- * Gets records list - *
- * @return List of records - */ - function getRecords() : array - { - return $this->_recordsList; - } - - /** - *- * Adds new record - *
- * @param int dataType Type of data - * @param string data Data string - */ - public function addRecord(int $dataType, string $data) : void - { - $hibcPASRecord = new HIBCPASRecord($dataType, $data); - - array_push($this->_recordsList, $hibcPASRecord); - array_push($this->getIComplexCodetextDTO()->records, $hibcPASRecord->getHIBCPASRecordDto()); - } - - /** - *- * Adds new record - *
- * @param HIBCPASRecord record Record to be added - * @return void - */ - public function addHIBCPASRecord(HIBCPASRecord $record) : void - { - array_push($this->_recordsList, $record); - array_push($this->getIComplexCodetextDTO()->records, $record->getHIBCPASRecordDto()); - } - - /** - *- * Clears records list - *
- */ - public function clear() : void - { - $this->_recordsList = array(); - } - - /** - *- * Gets barcode type. - *
- * @return int Barcode type. - */ - public function getBarcodeType() : int - { - return $this->getIComplexCodetextDTO()->barcodeType; - } - - /** - *- * Constructs codetext - *
- * @return string Constructed codetext - */ - public function getConstructedCodetext() : string - { - $thriftConnection = new ThriftConnection(); - $client = $thriftConnection->openConnection(); - $constructedCodetext = $client->HIBCPASCodetext_getConstructedCodetext($this->getIComplexCodetextDTO()); - $thriftConnection->closeConnection(); - return $constructedCodetext; - } - - /** - *- * Initializes instance from constructed codetext. - *
- * @param string constructedCodetext Constructed codetext. - * @return void - */ - public function initFromString(string $constructedCodetext) : void - { - $thriftConnection = new ThriftConnection(); - $client = $thriftConnection->openConnection(); - $hibcPASCodetextDTO = $client->HIBCPASCodetext_initFromString($this->getIComplexCodetextDTO(), $constructedCodetext); - $this->setIComplexCodetextDTO($hibcPASCodetextDTO); - $thriftConnection->closeConnection(); - $this->initFieldsFromDto(); - } - - /** - *- * Returns a value indicating whether this instance is equal to a specified {@code HIBCPASCodetext} value. - *
- * @return bool true if obj has the same value as this instance; otherwise, false. - * @param HIBCPASCodetext obj An {@code HIBCPASCodetext} value to compare to this instance. - */ - public function equals(HIBCPASCodetext $obj) : bool - { - $thriftConnection = new ThriftConnection(); - $client = $thriftConnection->openConnection(); - $isEquals = $client->HIBCPASCodetext_equals($this->getIComplexCodetextDTO(), $obj->getIComplexCodetextDTO()); - $thriftConnection->closeConnection(); - - return $isEquals; - } -} - -/** - *- * Class for storing HIBC PAS record. - *
- */ -class HIBCPASRecord implements Communicator -{ - private $HIBCPASRecordDto; - - /** - * @return mixed - */ - public function getHIBCPASRecordDto() - { - return $this->HIBCPASRecordDto; - } - - /** - * @param mixed $HIBCPASRecordDto - */ - public function setHIBCPASRecordDto($HIBCPASRecordDto): void - { - $this->HIBCPASRecordDto = $HIBCPASRecordDto; - } - - /** - *- * HIBCPASRecord constructor - *
- * - * @param int dataType Type of data. - * @param string data - */ - function __construct(int $dataType, string $data) - { - $this->HIBCPASRecordDto = new HIBCPASRecordDTO(); - $this->HIBCPASRecordDto->dataType = $dataType; - $this->HIBCPASRecordDto->data = $data; - $this->initFieldsFromDto(); - } - - /** - *- * HIBCPASRecord constructor - *
- */ - static function construct($javaClass) : HIBCPASRecord - { - $obj = new HIBCPASRecord(0,""); - $obj->setHIBCPASRecordDto($javaClass); - return $obj; - } - - public function obtainDto(...$args) - { - - } - - public function initFieldsFromDto() - { - } - - /** - *- * Identifies data type. - *
- */ - public function getDataType() : int - { - return $this->getHIBCPASRecordDto()->dataType; - } - - /** - *- * Identifies data type. - *
- */ - public function setDataType(int $value) : void - { - $this->getHIBCPASRecordDto()->setDataType = $value; - } - - /** - *- * Identifies data. - *
- */ - public function getData() : string - { - return $this->getHIBCPASRecordDto()->data; - } - - /** - *- * Identifies data. - *
- */ - public function setData(string $value) : void - { - $this->getHIBCPASRecordDto()->setData = $value; - } - - /** - *- * Returns a value indicating whether this instance is equal to a specified {@code HIBCPASDataType} value. - *
- * - * @param HIBCPASRecord obj An {@code HIBCPASDataType} value to compare to this instance. - * @return bool true if obj has the same value as this instance; otherwise, false. - */ - public function equals(HIBCPASRecord $obj) : bool - { - $thriftConnection = new ThriftConnection(); - $client = $thriftConnection->openConnection(); - $isEqual = $client->HIBCPASRecord_equals($this->getHIBCPASRecordDto(), $obj->getHIBCPASRecordDto()); - $thriftConnection->closeConnection(); - return $isEqual; - } -} - - -/** - *- * Class for storing HIBC LIC primary data. - *
- */ -class PrimaryData implements Communicator -{ - private $primaryDataDto; - - /** - * @return mixed - */ - public function getPrimaryDataDto() - { - return $this->primaryDataDto; - } - - /** - * @param mixed $PrimaryDataDto - */ - public function setPrimaryDataDto($primaryDataDto): void - { - $this->primaryDataDto = $primaryDataDto; - } - - function __construct() - { - $this->primaryDataDto = $this->obtainDto(); - $this->initFieldsFromDto(); - } - - static function construct($java_class) : PrimaryData - { - $obj = new PrimaryData(); - $obj->setPrimaryDataDto($java_class); - $obj->initFieldsFromDto(); - return $obj; - } - - public function obtainDto(...$args) - { - $thriftConnection = new ThriftConnection(); - $client = $thriftConnection->openConnection(); - $dtoRef = $client->PrimaryData_ctor(); - $thriftConnection->closeConnection(); - - return $dtoRef; - } - - public function initFieldsFromDto() - { - } - - /** - *- * Identifies date of labeler identification code. - * Labeler identification code must be 4 symbols alphanumeric string, with first character always being alphabetic. - *
- */ - public function getLabelerIdentificationCode() : string - { - return $this->getPrimaryDataDto()->labelerIdentificationCode; - } - - /** - *- * Identifies date of labeler identification code. - * Labeler identification code must be 4 symbols alphanumeric string, with first character always being alphabetic. - *
- */ - public function setLabelerIdentificationCode(string $value) : void - { - $this->getPrimaryDataDto()->labelerIdentificationCode = $value; - } - - /** - *- * Identifies product or catalog number. Product or catalog number must be alphanumeric string up to 18 sybmols length. - *
- */ - public function getProductOrCatalogNumber() : string - { - return $this->getPrimaryDataDto()->productOrCatalogNumber; - } - - /** - *- * Identifies product or catalog number. Product or catalog number must be alphanumeric string up to 18 sybmols length. - *
- */ - public function setProductOrCatalogNumber(string $value) : void - { - $this->getPrimaryDataDto()->productOrCatalogNumber = $value; - } - - /** - *- * Identifies unit of measure ID. Unit of measure ID must be integer value from 0 to 9. - *
- */ - public function getUnitOfMeasureID() : int - { - return $this->getPrimaryDataDto()->unitOfMeasureID; - } - - /** - *- * Identifies unit of measure ID. Unit of measure ID must be integer value from 0 to 9. - *
- */ - public function setUnitOfMeasureID(int $value) : void - { - $this->getPrimaryDataDto()->unitOfMeasureID = $value; - } - - /** - *- * Converts data to string format according HIBC LIC specification. - *
- * - * @return string Formatted string. - */ - public function toString() : string - { - $thriftConnection = new ThriftConnection(); - $client = $thriftConnection->openConnection(); - $str = $client->PrimaryData_toString($this->getPrimaryDataDto()); - $thriftConnection->closeConnection(); - - return $str; - } - - /** - *- * Instantiates primary data from string format according HIBC LIC specification. - *
- * - * @param primaryDataCodetext Formatted string. - */ - public function parseFromString(string $primaryDataCodetext) : void - { - $thriftConnection = new ThriftConnection(); - $client = $thriftConnection->openConnection(); - $this->setPrimaryDataDto($client->PrimaryData_parseFromString($this->getPrimaryDataDto(), $primaryDataCodetext)); - $thriftConnection->closeConnection(); - $this->initFieldsFromDto(); - - } - - /** - *- * Returns a value indicating whether this instance is equal to a specified {@code PrimaryData} value. - *
- * - * @param obj An {@code PrimaryData} value to compare to this instance. - * @return {@code true} if obj has the same value as this instance; otherwise, {@code false}. - */ - public function equals(PrimaryData $obj) : bool - { - $thriftConnection = new ThriftConnection(); - $client = $thriftConnection->openConnection(); - $isEqual = $client->PrimaryData_equals($this->getPrimaryDataDto(), $obj->getPrimaryDataDto()); - $thriftConnection->closeConnection(); - - return $isEqual; - } -} - -/** - *- * Class for storing HIBC LIC secondary and additional data. - *
- */ -class SecondaryAndAdditionalData implements Communicator -{ - private $secondaryAndAdditionalDataDto; - - /** - * @return mixed - */ - public function getSecondaryAndAdditionalDataDto() - { - return $this->secondaryAndAdditionalDataDto; - } - - /** - * @param mixed $secondaryAndAdditionalDataDto - */ - public function setSecondaryAndAdditionalDataDto($secondaryAndAdditionalDataDto): void - { - $this->secondaryAndAdditionalDataDto = $secondaryAndAdditionalDataDto; - } - - function __construct() - { - $this->secondaryAndAdditionalDataDto = $this->obtainDto(); - $this->initFieldsFromDto(); - } - - static function construct($java_class) : SecondaryAndAdditionalData - { - $obj = new SecondaryAndAdditionalData(); - $obj->setSecondaryAndAdditionalDataDto($java_class); - $obj->initFieldsFromDto(); - return $obj; - } - - public function obtainDto(...$args) - { - $thriftConnection = new ThriftConnection(); - $client = $thriftConnection->openConnection(); - $dtoRef = $client->SecondaryAndAdditionalData_ctor(); - $thriftConnection->closeConnection(); - - return $dtoRef; - } - - public function initFieldsFromDto() - { - } - - /** - *- * Identifies expiry date format. - *
- */ - public function getExpiryDateFormat() : int - { - return $this->getSecondaryAndAdditionalDataDto()->expiryDateFormat; - } - - /** - *- * Identifies expiry date format. - *
- */ - public function setExpiryDateFormat(int $value) : void - { - $this->getSecondaryAndAdditionalDataDto()->expiryDateFormat = $value; - } - - /** - *- * Identifies expiry date. Will be used if ExpiryDateFormat is not set to None. - *
- */ - public function getExpiryDate() : DateTime - { - return new DateTime('@' . $this->getSecondaryAndAdditionalDataDto()->expiryDate); - } - - /** - *- * Identifies expiry date. Will be used if ExpiryDateFormat is not set to None. - *
- */ - public function setExpiryDate(DateTime $value) : void - { - $this->getSecondaryAndAdditionalDataDto()->expiryDate = $value->getTimestamp() . ""; - } - - /** - *- * Identifies lot or batch number. Lot/batch number must be alphanumeric string with up to 18 sybmols length. . - *
- */ - public function getLotNumber() : string - { - return $this->getSecondaryAndAdditionalDataDto()->lotNumber; - } - - /** - *- * Identifies lot or batch number. Lot/batch number must be alphanumeric string with up to 18 sybmols length. . - *
- */ - public function setLotNumber(?string $value) : void - { - if($value == null) - $value = "null"; - $this->getSecondaryAndAdditionalDataDto()->lotNumber = $value; - } - - /** - *- * Identifies serial number. Serial number must be alphanumeric string up to 18 sybmols length. - *
- */ - public function getSerialNumber() : string - { - return $this->getSecondaryAndAdditionalDataDto()->serialNumber; - } - - /** - *- * Identifies serial number. Serial number must be alphanumeric string up to 18 sybmols length. - *
- */ - public function setSerialNumber(?string $value) : void - { - if($value == null) - $value = "null"; - $this->getSecondaryAndAdditionalDataDto()->serialNumber = $value; - } - - /** - *- * Identifies date of manufacture. - * Date of manufacture can be set to DateTime.MinValue in order not to use this field. - * Default value: DateTime.MinValue - *
- */ - public function getDateOfManufacture() : DateTime - { - return new DateTime('@' . $this->getSecondaryAndAdditionalDataDto()->dateOfManufacture); - } - - /** - *- * Identifies date of manufacture. - * Date of manufacture can be set to DateTime.MinValue in order not to use this field. - * Default value: DateTime.MinValue - *
- */ - public function setDateOfManufacture(DateTime $value) : void - { - $this->getSecondaryAndAdditionalDataDto()->dateOfManufacture = ($value->getTimestamp() . ""); - } - - /** - *- * Identifies quantity, must be integer value from 0 to 500. - * Quantity can be set to -1 in order not to use this field. - * Default value: -1 - *
- */ - public function getQuantity() : int - { - return $this->getSecondaryAndAdditionalDataDto()->quantity; - } - - /** - *- * Identifies quantity, must be integer value from 0 to 500. - * Quantity can be set to -1 in order not to use this field. - * Default value: -1 - *
- */ - public function setQuantity(int $value) : void - { - $this->getSecondaryAndAdditionalDataDto()->quantity = $value; - } - - /** - *- * Converts data to string format according HIBC LIC specification. - *
- * - * @return string Formatted string. - */ - public function toString() : string - { - $thriftConnection = new ThriftConnection(); - $client = $thriftConnection->openConnection(); - $str = $client->SecondaryAndAdditionalData_toString($this->getSecondaryAndAdditionalDataDto()); - $thriftConnection->closeConnection(); - return $str; - } - - /** - *- * Instantiates secondary and additional supplemental data from string format according HIBC LIC specification. - *
- * - * @param string secondaryDataCodetext Formatted string. - */ - public function parseFromString(string $secondaryDataCodetext) : void - { - $thriftConnection = new ThriftConnection(); - $client = $thriftConnection->openConnection(); - $secondaryAndAdditionalDataDTO = $client->SecondaryAndAdditionalData_parseFromString($this->getSecondaryAndAdditionalDataDto(), $secondaryDataCodetext); - $thriftConnection->closeConnection(); - $this->setSecondaryAndAdditionalDataDto($secondaryAndAdditionalDataDTO); - $this->initFieldsFromDto(); - } - - /** - *- * Returns a value indicating whether this instance is equal to a specified {@code SecondaryAndAdditionalData} value. - *
- * - * @param SecondaryAndAdditionalData obj An {@code SecondaryAndAdditionalData} value to compare to this instance. - * @return bool true if obj has the same value as this instance; otherwise, false. - */ - public function equals(SecondaryAndAdditionalData $obj) : bool - { - $thriftConnection = new ThriftConnection(); - $client = $thriftConnection->openConnection(); - $isEqual = $client->SecondaryAndAdditionalData_equals($this->getSecondaryAndAdditionalDataDto(), $obj->getSecondaryAndAdditionalDataDto()); - $thriftConnection->closeConnection(); - return $isEqual; - } -} - -/** - * 2D Mailmark Type defines size of Data Matrix barcode - */ -class Mailmark2DType -{ - /** - * Auto determine - */ - const AUTO = 0; - - /** - * 24 x 24 modules - */ - const TYPE_7 = 1; - - /** - * 32 x 32 modules - */ - const TYPE_9 = 2; - - /** - * 16 x 48 modules - */ - const TYPE_29 = 3; -} - -/** - *- * Specifies the different types of date formats for HIBC LIC. - *
- */ -class HIBCLICDateFormat -{ - /** - *- * YYYYMMDD format. Will be encoded in additional supplemental data. - *
- */ - const YYYYMMDD = 0; - /** - *- * MMYY format. - *
- */ - const MMYY = 1; - /** - *- * MMDDYY format. - *
- */ - const MMDDYY = 2; - /** - *- * YYMMDD format. - *
- */ - const YYMMDD = 3; - /** - *- * YYMMDDHH format. - *
- */ - const YYMMDDHH = 4; - /** - *- * Julian date format. - *
- */ - const YYJJJ = 5; - /** - *- * Julian date format with hours. - *
- */ - const YYJJJHH = 6; - /** - *- * Do not encode expiry date. - *
- */ - const NONE =7; -} - -/** - *- * HIBC PAS data location types. - *
- */ -class HIBCPASDataLocation -{ - /** - *- * A - Patient - *
- */ - const PATIENT = 0; - /** - *- * B - Patient Care Record - *
- */ - const PATIENT_CARE_RECORD = 1; - /** - *- * C - Specimen Container - *
- */ - const SPECIMEN_CONTAINER = 2; - /** - *- * D - Direct Patient Image Item - *
- */ - const DIRECT_PATIENT_IMAGE_ITEM = 3; - /** - *- * E - Business Record - *
- */ - const BUSINESS_RECORD = 4; - /** - *- * F - Medical Administration Record - *
- */ - const MEDICAL_ADMINISTRATION_RECORD = 5; - /** - *- * G - Library Reference Material - *
- */ - const LIBRARY_REFERENCE_MATERIAL = 6; - /** - *- * H - Devices and Materials - *
- */ - const DEVICES_AND_MATERIALS = 7; - /** - *- * I - Identification Card - *
- */ - const IDENTIFICATION_CARD = 8; - /** - *- * J - Product Container - *
- */ - const PRODUCT_CONTAINER = 9; - /** - *- * K - Asset data type - *
- */ - const ASSET = 10; - /** - *- * L - Surgical Instrument - *
- */ - const SURGICAL_INSTRUMENT = 11; - /** - *- * Z - User Defined - *
- */ - const USER_DEFINED = 25; -} - -/** - *- * HIBC PAS record's data types. - *
- */ -class HIBCPASDataType -{ - /** - *- * A - Labeler Identification Code - *
- */ - const LABELER_IDENTIFICATION_CODE = 0; - /** - *- * B - Service Identification - *
- */ - const SERVICE_IDENTIFICATION = 1; - /** - *- * C - Patient Identification - *
- */ - const PATIENT_IDENTIFICATION = 2; - /** - *- * D - Specimen Identification - *
- */ - const SPECIMEN_IDENTIFICATION = 3; - /** - *- * E - Personnel Identification - *
- */ - const PERSONNEL_IDENTIFICATION = 4; - /** - *- * F - Administrable Product Identification - *
- */ - const ADMINISTRABLE_PRODUCT_IDENTIFICATION = 5; - /** - *- * G - Implantable Product Information - *
- */ - const IMPLANTABLE_PRODUCT_INFORMATION = 6; - /** - *- * H - Hospital Item Identification - *
- */ - const HOSPITAL_ITEM_IDENTIFICATION = 7; - /** - *- * I - Medical Procedure Identification - *
- */ - const MEDICAL_PROCEDURE_IDENTIFICATION = 8; - /** - *- * J - Reimbursement Category - *
- */ - const REIMBURSEMENT_CATEGORY = 9; - /** - *- * K - Blood Product Identification - *
- */ - const BLOOD_PRODUCT_IDENTIFICATION = 10; - /** - *- * L - Demographic Data - *
- */ - const DEMOGRAPHIC_DATA = 11; - /** - *- * M - DateTime in YYYDDDHHMMG format - *
- */ - const DATE_TIME = 12; - /** - *- * N - Asset Identification - *
- */ - const ASSET_IDENTIFICATION = 13; - /** - *- * O - Purchase Order Number - *
- */ - const PURCHASE_ORDER_NUMBER = 14; - /** - *- * P - Dietary Item Identification - *
- */ - const DIETARY_ITEM_IDENTIFICATION = 15; - /** - *- * Q - Manufacturer Serial Number - *
- */ - const MANUFACTURER_SERIAL_NUMBER = 16; - /** - *- * R - Library Materials Identification - *
- */ - const LIBRARY_MATERIALS_IDENTIFICATION = 17; - /** - *- * S - Business Control Number - *
- */ - const BUSINESS_CONTROL_NUMBER = 18; - /** - *- * T - Episode of Care Identification - *
- */ - const EPISODE_OF_CARE_IDENTIFICATION = 19; - /** - *- * U - Health Industry Number - *
- */ - const HEALTH_INDUSTRY_NUMBER = 20; - /** - *- * V - Patient Visit ID - *
- */ - const PATIENT_VISIT_ID = 21; - /** - *- * X - XML Document - *
- */ - const XML_DOCUMENT = 22; - /** - *- * Z - User Defined - *
- */ - const USER_DEFINED = 25; -} - -/** - * Address type - */ -class AddressType -{ - - /** - * Undetermined - */ - const UNDETERMINED = 0; - - /** - * Structured address - */ - const STRUCTURED = 1; - - /** - * Combined address elements - */ - const COMBINED_ELEMENTS = 2; - - /** - * Conflicting - */ - const CONFLICTING = 3; -} - -/** - * SwissQR bill standard version - */ -class QrBillStandardVersion -{ - /** - * Version 2.0 - */ - const V2_0 = 0; -} - -?> \ No newline at end of file diff --git a/lib/ComplexBarcode/Address.php b/lib/ComplexBarcode/Address.php new file mode 100644 index 00000000..4286c63c --- /dev/null +++ b/lib/ComplexBarcode/Address.php @@ -0,0 +1,447 @@ +addressDto; + } + + /** + * @param mixed $addressDto + */ + public function setAddressDto(\Aspose\Barcode\Bridge\AddressDTO $addressDto): void + { + $this->addressDto = $addressDto; + } + + public function __construct() + { + $this->addressDto = new \Aspose\Barcode\Bridge\AddressDTO(); + $this->initFieldsFromDto(); + } + + /** + * Constructs an Address object from AddressDTO. + * + * @param \Aspose\Barcode\Bridge\AddressDTO $addressDto + * @return Address + * @throws BarcodeException + */ + static function construct(\Aspose\Barcode\Bridge\AddressDTO $addressDto) + { + try + { + $address = new Address(); + $address->setAddressDto($addressDto); + return $address; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + public function obtainDto(...$args) + { + } + + public function initFieldsFromDto() + { + } + + /** + * Gets the address type. + * + * The address type is automatically set by either setting street / house number + * or address line 1 and 2. Before setting the fields, the address type is Undetermined. + * If fields of both types are set, the address type becomes Conflicting. + * + * @return int The address type. + */ + public function getType(): int + { + return $this->getAddressDto()->type; + } + + /** + * Gets the name, either the first and last name of a natural person or the + * company name of a legal person. + * @return string The name. + */ + public function getName(): ?string + { + try + { + return $this->getAddressDto()->name; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Sets the name, either the first and last name of a natural person or the + * company name of a legal person. + * @param string $value The name. + */ + public function setName(?string $value): void + { + try + { + $this->getAddressDto()->name = $value; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Gets the address line 1. + * + * Address line 1 contains street name, house number or P.O. box. + * + * + * Setting this field sets the address type to AddressType.CombinedElements unless it's already + * AddressType.Structured, in which case it becomes AddressType.Conflicting. + * + * This field is only used for combined elements addresses and is optional. + * + * @return string The address line 1. + */ + public function getAddressLine1(): ?string + { + try + { + return $this->getAddressDto()->addressLine1; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Sets the address line 1. + * + * Address line 1 contains street name, house number or P.O. box. + * + * Setting this field sets the address type to AddressType.CombinedElements unless it's already + * AddressType.Structured, in which case it becomes AddressType.Conflicting. + * + * This field is only used for combined elements addresses and is optional. + * + * @param string $value The address line 1. + */ + public function setAddressLine1(?string $value): void + { + try + { + $this->getAddressDto()->addressLine1 = $value; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Gets the address line 2. + * Address line 2 contains postal code and town. + * Setting this field sets the address type to AddressType.CombinedElements unless it's already + * AddressType.Structured, in which case it becomes AddressType.Conflicting. + * This field is only used for combined elements addresses. For this type, it's mandatory. + * @return string The address line 2. + */ + public function getAddressLine2(): ?string + { + try + { + return $this->getAddressDto()->addressLine2; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Sets the address line 2. + * Address line 2 contains postal code and town. + * Setting this field sets the address type to AddressType.CombinedElements unless it's already + * AddressType.Structured, in which case it becomes AddressType.Conflicting. + * This field is only used for combined elements addresses. For this type, it's mandatory. + * @param string $value The address line 2. + */ + public function setAddressLine2(?string $value): void + { + try + { + $this->getAddressDto()->addressLine2 = $value; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Gets the street. + * The street must be speicfied without house number. + * Setting this field sets the address type to AddressType.Structured unless it's already + * AddressType.CombinedElements, in which case it becomes AddressType.Conflicting. + * This field is only used for structured addresses and is optional. + * @return string The street. + */ + public function getStreet(): ?string + { + return $this->getAddressDto()->street; + } + + /** + * Sets the street. + * + * The street must be speicfied without house number. + * + * + * Setting this field sets the address type to AddressType.Structured unless it's already + * AddressType.CombinedElements, in which case it becomes AddressType.Conflicting. + * + * This field is only used for structured addresses and is optional. + * + * @param string $value The street. + */ + public function setStreet(?string $value): void + { + try + { + $this->getAddressDto()->street = $value; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Gets the house number. + * + * Setting this field sets the address type to AddressType.Structured unless it's already + * AddressType.CombinedElements, in which case it becomes AddressType.Conflicting. + * + * This field is only used for structured addresses and is optional. + * + * @return string The house number. + */ + public function getHouseNo(): ?string + { + return $this->getAddressDto()->houseNo; + } + + /** + * Sets the house number. + * + * Setting this field sets the address type to AddressType.Structured unless it's already + * AddressType.CombinedElements, in which case it becomes AddressType.Conflicting. + * + * This field is only used for structured addresses and is optional. + * + * @param string $value The house number. + */ + public function setHouseNo(?string $value): void + { + try + { + $this->getAddressDto()->houseNo = $value; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Gets the postal code. + * + * Setting this field sets the address type to AddressType.Structured unless it's already + * AddressType.CombinedElements, in which case it becomes AddressType.Conflicting. + * + * This field is only used for structured addresses. For this type, it's mandatory. + * + * @param string The postal code. + */ + public function getPostalCode(): ?string + { + try + { + return $this->getAddressDto()->postalCode; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Sets the postal code. + * + * Setting this field sets the address type to AddressType.Structured unless it's already + * AddressType.CombinedElements, in which case it becomes AddressType.Conflicting. + * + * This field is only used for structured addresses. For this type, it's mandatory. + * + * @param string $value The postal code. + */ + public function setPostalCode(?string $value): void + { + try + { + $this->getAddressDto()->postalCode = $value; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Gets the town or city. + * + * Setting this field sets the address type to AddressType.Structured unless it's already + * AddressType.CombinedElements, in which case it becomes AddressType.Conflicting. + * + * This field is only used for structured addresses. For this type, it's mandatory. + * + * @return string The town or city. + */ + public function getTown(): ?string + { + try + { + return $this->getAddressDto()->town; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Sets the town or city. + * + * Setting this field sets the address type to AddressType.Structured unless it's already + * AddressType.CombinedElements, in which case it becomes AddressType.Conflicting. + * + * This field is only used for structured addresses. For this type, it's mandatory. + * + * @param string $value The town or city. + */ + public function setTown(?string $value): void + { + try + { + $this->getAddressDto()->town = $value; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Gets the two-letter ISO country code. + * + * The country code is mandatory unless the entire address contains null or emtpy values. + * + * @return string The ISO country code. + */ + public function getCountryCode(): ?string + { + try + { + return $this->getAddressDto()->countryCode; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Sets the two-letter ISO country code. + * + * The country code is mandatory unless the entire address contains null or emtpy values. + * + * @param string $value The ISO country code. + */ + public function setCountryCode(?string $value): void + { + try + { + $this->getAddressDto()->countryCode = $value; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Clears all fields and sets the type to AddressType.Undetermined. + */ + public function clear(): void + { + try + { + $this->setName(null); + $this->setAddressLine1(null); + $this->setAddressLine2(null); + $this->setStreet(null); + $this->setHouseNo(null); + $this->setPostalCode(null); + $this->setTown(null); + $this->setCountryCode(null); + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Determines whether the specified object is equal to the current object. + * @param Address $obj The object to compare with the current object. + * @return bool true if the specified object is equal to the current object; otherwise, false. + */ + public function equals(Address $obj): bool + { + $thriftConnection = new ThriftConnection(); + $client = $thriftConnection->openConnection(); + $isEquals = $client->Address_equals($this->getAddressDto(), $obj->getAddressDto()); + $thriftConnection->closeConnection(); + return $isEquals; + } +} \ No newline at end of file diff --git a/lib/ComplexBarcode/AddressType.php b/lib/ComplexBarcode/AddressType.php new file mode 100644 index 00000000..ce7ba85f --- /dev/null +++ b/lib/ComplexBarcode/AddressType.php @@ -0,0 +1,30 @@ +alternativeSchemeDto; + } + + /** + * @param mixed $alternativeSchemeDto + */ + public function setAlternativeSchemeDto(\Aspose\Barcode\Bridge\AlternativeSchemeDTO $alternativeSchemeDto): void + { + $this->alternativeSchemeDto = $alternativeSchemeDto; + } + + public function __construct($instruction) + { + try + { + $this->alternativeSchemeDto = new \Aspose\Barcode\Bridge\AlternativeSchemeDTO(); + $this->alternativeSchemeDto->instruction = $instruction; + $this->initFieldsFromDto(); + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + static function construct($javaClass) + { + try + { + $phpClass = new AlternativeScheme(""); + $phpClass->setAlternativeSchemeDto($javaClass); + return $phpClass; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + public function obtainDto(...$args) + { + + } + + public function initFieldsFromDto() + { + } + + /** + * Gets the payment instruction for a given bill. + * + * The instruction consists of a two letter abbreviation for the scheme, a separator characters + * and a sequence of parameters(separated by the character at index 2). + * + * Value: The payment instruction. + */ + public function getInstruction(): string + { + try + { + return $this->getAlternativeSchemeDto()->instruction; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Gets the payment instruction for a given bill. + * The instruction consists of a two letter abbreviation for the scheme, a separator characters + * and a sequence of parameters(separated by the character at index 2). + * Value: The payment instruction. + */ + public function setInstruction(string $value): void + { + try + { + $this->getAlternativeSchemeDto()->instruction = $value; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Determines whether the specified object is equal to the current object. + * @param AlternativeScheme $obj The object to compare with the current object. + * @return bool true if the specified object is equal to the current object; otherwise, false. + */ + public function equals(AlternativeScheme $obj): bool + { + $thriftConnection = new ThriftConnection(); + $client = $thriftConnection->openConnection(); + $isEquals = $client->AlternativeScheme_equals($this->getAlternativeSchemeDto(), $obj->getAlternativeSchemeDto()); + $thriftConnection->closeConnection(); + return $isEquals; + } +} \ No newline at end of file diff --git a/lib/ComplexBarcode/ComplexBarcodeGenerator.php b/lib/ComplexBarcode/ComplexBarcodeGenerator.php new file mode 100644 index 00000000..15985cfb --- /dev/null +++ b/lib/ComplexBarcode/ComplexBarcodeGenerator.php @@ -0,0 +1,147 @@ +getBill()->setAccount("Account"); + * $swissQRCodetext->getBill()->setBillInformation("BillInformation"); + * $cg = new ComplexBarcodeGenerator($swissQRCodetext); + * $res = $cg->generateBarCodeImage(BarcodeImageFormat::PNG); + * @endcode + */ +final class ComplexBarcodeGenerator implements Communicator +{ + private $complexBarcodeGeneratorDto; + + /** + * @return mixed + */ + public function getComplexBarcodeGeneratorDto(): \Aspose\Barcode\Bridge\ComplexBarcodeGeneratorDTO + { + return $this->complexBarcodeGeneratorDto; + } + + /** + * @param mixed $complexBarcodeGeneratorDto + */ + public function setComplexBarcodeGeneratorDto(\Aspose\Barcode\Bridge\ComplexBarcodeGeneratorDTO $complexBarcodeGeneratorDto): void + { + $this->complexBarcodeGeneratorDto = $complexBarcodeGeneratorDto; + } + + private $parameters; +// private $complexCodeText; + + + /** + * Creates an instance of ComplexBarcodeGenerator. + * + * @param IComplexCodetext $complexCodetext complexCodetext Complex codetext + */ + public function __construct(IComplexCodetext $complexCodetext) + { + $this->setComplexBarcodeGeneratorDto($this->obtainDto($complexCodetext->getIComplexCodetextDTO())); + $this->initFieldsFromDto(); + } + + public function obtainDto(...$args): \Aspose\Barcode\Bridge\ComplexBarcodeGeneratorDTO + { + $thriftConnection = new ThriftConnection(); + $client = $thriftConnection->openConnection(); + $dtoRef = $client->ComplexBarcodeGenerator_ctor($args[0]); + $thriftConnection->closeConnection(); + + return $dtoRef; + } + + public function initFieldsFromDto() + { + try + { +// $this->complexCodeText = $this->getComplexBarcodeGeneratorDto()->complexCodetextDTO; + $this->parameters = new BaseGenerationParameters($this->getComplexBarcodeGeneratorDto()->parameters); + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Generation parameters. + */ + public function getParameters(): BaseGenerationParameters + { + return $this->parameters; + } + + /** + * Generates complex barcode image under current settings. + * @param int format value of BarCodeImageFormat (PNG, BMP, JPEG, GIF) + * @code + * $swissQRCodetext = new SwissQRCodetext(null); + * $swissQRCodetext->getBill()->setAccount("Account"); + * $swissQRCodetext->getBill()->setBillInformation("BillInformation"); + * $cg = new ComplexBarcodeGenerator($swissQRCodetext); + * $res = $cg->generateBarCodeImage(BarcodeImageFormat::PNG); + * @endcode + * @return string base64 representation of image. + */ + public function generateBarcodeImage(int $format, bool $passLicense = false): string + { + try + { + $thriftConnection = new ThriftConnection(); + $client = $thriftConnection->openConnection(); + + // Deciding if the license should be used + $licenseContent = $passLicense ? License::getLicenseContent() : null; + // Passing the license or null + $base64Image = $client->ComplexBarcodeGenerator_generateBarcodeImage($this->getComplexBarcodeGeneratorDto(), $format, $licenseContent); + $thriftConnection->closeConnection(); + return $base64Image; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Save barcode image to specific file in specific format. + * @param $filePath string Path to save to. + * @param int format value of BarCodeImageFormat (PNG, BMP, JPEG, GIF) + * @code: + * $swissQRCodetext = new SwissQRCodetext(null); + * $swissQRCodetext->getBill()->setAccount("Account"); + * $swissQRCodetext->getBill()->setBillInformation("BillInformation"); + * $cg = new ComplexBarcodeGenerator($swissQRCodetext); + * $res = $cg->save("filePath.png", BarcodeImageFormat::PNG); + * @endcode + */ + public function save(string $filePath, int $format): void + { + try + { + $image = $this->generateBarcodeImage($format); + file_put_contents($filePath, base64_decode($image)); + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } +} \ No newline at end of file diff --git a/lib/ComplexBarcode/ComplexCodetextReader.php b/lib/ComplexBarcode/ComplexCodetextReader.php new file mode 100644 index 00000000..e1120b21 --- /dev/null +++ b/lib/ComplexBarcode/ComplexCodetextReader.php @@ -0,0 +1,175 @@ +read(); + * $result = ComplexCodetextReader::tryDecodeSwissQR($cr->getCodeText(false)); + * @endcode + */ +final class ComplexCodetextReader +{ + /** + * Decodes SwissQR codetext. + * + * @param string encodedCodetext encoded codetext + * @return SwissQRCodetext decoded SwissQRCodetext or null. + */ + public static function tryDecodeSwissQR(string $encodedCodetext): SwissQRCodetext + { + try + { + $thriftConnection = new ThriftConnection(); + $client = $thriftConnection->openConnection(); + $swissQRCodetextDTO = $client->ComplexCodetextReader_tryDecodeSwissQR($encodedCodetext); + $thriftConnection->closeConnection(); + return SwissQRCodetext::construct($swissQRCodetextDTO); + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Decodes Royal Mail Mailmark 2D codetext. + * @param string $encodedCodetext encoded codetext + * @return Mailmark2DCodetext decoded Royal Mail Mailmark 2D or null. + */ + public static function tryDecodeMailmark2D(string $encodedCodetext): Mailmark2DCodetext + { + try + { + $thriftConnection = new ThriftConnection(); + $client = $thriftConnection->openConnection(); + $mailmark2DCodetextDTO = $client->ComplexCodetextReader_tryDecodeMailmark2D($encodedCodetext); + $thriftConnection->closeConnection(); + $mailmark2DCodetext = Mailmark2DCodetext::construct($mailmark2DCodetextDTO); + return $mailmark2DCodetext; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Decodes Mailmark Barcode C and L codetext. + * @param string $encodedCodetext encoded codetext + * @return MailmarkCodetext|null Mailmark Barcode C and L or null. + */ + public static function tryDecodeMailmark(string $encodedCodetext): ?MailmarkCodetext + { + $res = new MailmarkCodetext(); + try + { + $res->initFromString($encodedCodetext); + } + catch (Exception $e) + { + return null; + } + return $res; + } + + /** + * Decodes MaxiCode codetext. + * @param int maxiCodeMode MaxiCode mode + * @param string encodedCodetext encoded codetext + * @return MaxiCodeCodetext Decoded MaxiCode codetext. + */ + public static function tryDecodeMaxiCode(int $maxiCodeMode, string $encodedCodetext): MaxiCodeCodetext + { + $thriftConnection = new ThriftConnection(); + $client = $thriftConnection->openConnection(); + $maxiCodeCodetextDTO = $client->ComplexCodetextReader_tryDecodeMaxiCode($maxiCodeMode, $encodedCodetext); + $thriftConnection->closeConnection(); + + if ($maxiCodeCodetextDTO->complexCodetextType == ComplexCodetextType::MaxiCodeCodetextMode2) + { + return MaxiCodeCodetextMode2::construct($maxiCodeCodetextDTO); + } elseif ($maxiCodeCodetextDTO->complexCodetextType == ComplexCodetextType::MaxiCodeCodetextMode3) + { + return MaxiCodeCodetextMode3::construct($maxiCodeCodetextDTO); + } else + { + return MaxiCodeStandardCodetext::construct($maxiCodeCodetextDTO); + } + } + + /** + *+ * Decodes HIBC LIC codetext. + *
+ * @param string|null $encodedCodetext Encoded codetext + * @return HIBCLICComplexCodetext|null Decoded HIBC LIC Complex Codetext or null + */ + public static function tryDecodeHIBCLIC(?string $encodedCodetext): ?HIBCLICComplexCodetext + { + $thriftConnection = new ThriftConnection(); + $client = $thriftConnection->openConnection(); + + $hibclicComplexCodetext = null; + try + { + $hibclicComplexCodetext = $client->ComplexCodetextReader_tryDecodeHIBCLIC($encodedCodetext); + } + catch (\Aspose\Barcode\Bridge\NullValueException $e) + { + return null; + } + + $thriftConnection->closeConnection(); + if ($hibclicComplexCodetext->complexCodetextType == ComplexCodetextType::HIBCLICSecondaryAndAdditionalDataCodetext) + { + return HIBCLICSecondaryAndAdditionalDataCodetext::construct($hibclicComplexCodetext); + } else if ($hibclicComplexCodetext->complexCodetextType == ComplexCodetextType::HIBCLICPrimaryDataCodetext) + { + return HIBCLICPrimaryDataCodetext::construct($hibclicComplexCodetext); + } else if ($hibclicComplexCodetext->complexCodetextType == ComplexCodetextType::HIBCLICCombinedCodetext) + { + return HIBCLICCombinedCodetext::construct($hibclicComplexCodetext); + } + return null; + } + + /** + *+ * Decodes HIBC PAS codetext. + *
+ * @param string encodedCodetext encoded codetext + * @return ?HIBCPASCodetext decoded HIBC PAS Complex Codetext or null. + */ + public static function tryDecodeHIBCPAS(string $encodedCodetext): ?HIBCPASCodetext + { + $thriftConnection = new ThriftConnection(); + $client = $thriftConnection->openConnection(); + $hibclicComplexCodetextDTO = $client->ComplexCodetextReader_tryDecodeHIBCPAS($encodedCodetext); + $thriftConnection->closeConnection(); + if ($hibclicComplexCodetextDTO->isNull) + return null; + return HIBCPASCodetext::construct($hibclicComplexCodetextDTO); + } +} \ No newline at end of file diff --git a/lib/ComplexBarcode/ComplexCodetextType.php b/lib/ComplexBarcode/ComplexCodetextType.php new file mode 100644 index 00000000..9c0d5ff0 --- /dev/null +++ b/lib/ComplexBarcode/ComplexCodetextType.php @@ -0,0 +1,17 @@ + + * Class for encoding and decoding the text embedded in the HIBC LIC code which stores primary and secodary data. + *+ */ +class HIBCLICCombinedCodetext extends HIBCLICComplexCodetext +{ + function __construct() + { + $this->setIComplexCodetextDTO($this->obtainDto()); + $this->getIComplexCodetextDTO()->complexCodetextType = ComplexCodetextType::HIBCLICCombinedCodetext; + $this->initFieldsFromDto(); + } + + static function construct($javaClass): HIBCLICCombinedCodetext + { + $obj = new HIBCLICCombinedCodetext(); + $obj->setIComplexCodetextDTO($javaClass); + $obj->initFieldsFromDto(); + return $obj; + } + + public function obtainDto(...$args) + { + $thriftConnection = new ThriftConnection(); + $client = $thriftConnection->openConnection(); + $complexCodetextDTO = $client->HIBCLICCombinedCodetext_ctor(); + $thriftConnection->closeConnection(); + return $complexCodetextDTO; + } + + public function initFieldsFromDto() + { + $this->auto_PrimaryData = PrimaryData::construct($this->getIComplexCodetextDTO()->primaryData); + $this->auto_SecondaryAndAdditionalData = SecondaryAndAdditionalData::construct($this->getIComplexCodetextDTO()->secondaryAndAdditionalData); + } + + /** + *+ * This sample shows how to encode and decode HIBC LIC using HIBCLICCombinedCodetext. + *+ * + * $combinedCodetext = new HIBCLICCombinedCodetext(); + * $combinedCodetext->setBarcodeType(EncodeTypes::HIBCQRLIC); + * $combinedCodetext->setPrimaryData(new PrimaryData()); + * $combinedCodetext->getPrimaryData()->setProductOrCatalogNumber("12345"); + * $combinedCodetext->getPrimaryData()->setLabelerIdentificationCode("A999"); + * $combinedCodetext->getPrimaryData()->setUnitOfMeasureID(1); + * $combinedCodetext->setSecondaryAndAdditionalData(new SecondaryAndAdditionalData()); + * $combinedCodetext->getSecondaryAndAdditionalData()->setExpiryDate(new Date()); + * $combinedCodetext->getSecondaryAndAdditionalData()->setExpiryDateFormat(HIBCLICDateFormat.MMDDYY); + * $combinedCodetext->getSecondaryAndAdditionalData()->setQuantity(30); + * $combinedCodetext->getSecondaryAndAdditionalData()->setLotNumber("LOT123"); + * $combinedCodetext->getSecondaryAndAdditionalData()->setSerialNumber("SERIAL123"); + * $combinedCodetext->getSecondaryAndAdditionalData()->setDateOfManufacture(new Date()); + * ComplexBarcodeGenerator generator = new ComplexBarcodeGenerator(combinedCodetext); + * { + * $image = $generator->generateBarCodeImage(BarCodeImageFormat::PNG); + * $reader = new BarCodeReader($image, null, DecodeType::HIBCQRLIC); + * { + * $reader->readBarCodes(); + * $codetext = $reader->getFoundBarCodes()[0]->getCodeText(); + * $result = ComplexCodetextReader::tryDecodeHIBCLIC($codetext) ; + * print("Product or catalog number: " . $result->getPrimaryData()->getProductOrCatalogNumber()); + * print("Labeler identification code: " . $result->getPrimaryData()->getLabelerIdentificationCode()); + * print("Unit of measure ID: " . $result->getPrimaryData()->getUnitOfMeasureID()); + * print("Expiry date: " . $result->getSecondaryAndAdditionalData()->getExpiryDate()); + * print("Quantity: " . $result->getSecondaryAndAdditionalData()->getQuantity()); + * print("Lot number: " . $result->getSecondaryAndAdditionalData()->getLotNumber()); + * print("Serial number: " . $result->getSecondaryAndAdditionalData()->getSerialNumber()); + * print("Date of manufacture: " . $result->getSecondaryAndAdditionalData()->getDateOfManufacture()); + * } + * } + *+ *
+ * Identifies primary data. + *
+ */ + public function getPrimaryData(): PrimaryData + { + return $this->auto_PrimaryData; + } + + /** + *+ * Identifies primary data. + *
+ */ + public function setPrimaryData(PrimaryData $value): void + { + $this->getIComplexCodetextDTO()->primaryData = ($value->getPrimaryDataDto()); + $this->auto_PrimaryData = $value; + } + + private $auto_PrimaryData; + + /** + *+ * Identifies secondary and additional supplemental data. + *
+ */ + public function getSecondaryAndAdditionalData(): SecondaryAndAdditionalData + { + return $this->auto_SecondaryAndAdditionalData; + } + + /** + *+ * Identifies secondary and additional supplemental data. + *
+ */ + public function setSecondaryAndAdditionalData(SecondaryAndAdditionalData $value): void + { + $this->getIComplexCodetextDTO()->secondaryAndAdditionalData = ($value->getSecondaryAndAdditionalDataDto()); + $this->auto_SecondaryAndAdditionalData = $value; + } + + private $auto_SecondaryAndAdditionalData; + + /** + *+ * Constructs codetext + *
+ * + * @return string Constructed codetext + */ + public function getConstructedCodetext(): string + { + $thriftConnection = new ThriftConnection(); + $client = $thriftConnection->openConnection(); + $constructedCodetext = $client->HIBCLICCombinedCodetext_getConstructedCodetext($this->getIComplexCodetextDTO()); + $thriftConnection->closeConnection(); + return $constructedCodetext; + } + + /** + *+ * Initializes instance from constructed codetext. + *
+ * + * @param string constructedCodetext Constructed codetext. + * @return void + */ + public function initFromString(string $constructedCodetext): void + { + $thriftConnection = new ThriftConnection(); + $client = $thriftConnection->openConnection(); + $HIBCLICCombinedCodetextDTO = $client->HIBCLICCombinedCodetext_initFromString($this->getIComplexCodetextDTO(), $constructedCodetext); + $this->setIComplexCodetextDTO($HIBCLICCombinedCodetextDTO); + $thriftConnection->closeConnection(); + $this->initFieldsFromDto(); + } + + /** + *+ * Returns a value indicating whether this instance is equal to a specified {@code HIBCLICCombinedCodetext} value. + *
+ * + * @param obj An {@code HIBCLICCombinedCodetext} value to compare to this instance. + * @return {@code true} if obj has the same value as this instance; otherwise, {@code false}. + */ + public function equals(HIBCLICCombinedCodetext $obj): bool + { + $thriftConnection = new ThriftConnection(); + $client = $thriftConnection->openConnection(); + $isEqual = $client->HIBCLICCombinedCodetext_equals($this->getIComplexCodetextDTO(), $obj->getIComplexCodetextDTO()); + $thriftConnection->closeConnection(); + return $isEqual; + } +} \ No newline at end of file diff --git a/lib/ComplexBarcode/HIBCLICComplexCodetext.php b/lib/ComplexBarcode/HIBCLICComplexCodetext.php new file mode 100644 index 00000000..38167e6e --- /dev/null +++ b/lib/ComplexBarcode/HIBCLICComplexCodetext.php @@ -0,0 +1,73 @@ + + * Base class for encoding and decoding the text embedded in the HIBC LIC code. + *+ */ +abstract class HIBCLICComplexCodetext extends IComplexCodetext +{ + + function __construct($HIBCLICComplexCodetextDto) + { + $this->setIComplexCodetextDTO($HIBCLICComplexCodetextDto); + $this->initFieldsFromDto(); + } + + /** + *+ * This sample shows how to decode raw HIBC LIC codetext to HIBCLICComplexCodetext instance. + *+ * $reader = new BarCodeReader("c:\\test.png", null, DecodeType::HIBC_AZTEC_LIC); + * { + * foreach($reader->readBarCodes() as $result) + * { + * $resultHIBCLICComplexCodetext = ComplexCodetextReader::tryDecodeHIBCLIC($result->getCodeText()); + * print("BarCode Type: " . $resultMaxiCodeCodetext->getBarcodeType()); + * print("BarCode CodeText: " . $resultMaxiCodeCodetext->getConstructedCodetext()); + * } + * } + *+ *
+ * Constructs codetext + *
+ * @return string Constructed codetext + */ + public abstract function getConstructedCodetext(): string; + + /** + *+ * Initializes instance from constructed codetext. + *
+ * @param string constructedCodetext Constructed codetext. + */ + public abstract function initFromString(string $constructedCodetext): void; + + /** + *+ * Gets or sets barcode type. HIBC LIC codetext can be encoded using HIBCCode39LIC, HIBCCode128LIC, HIBCAztecLIC, HIBCDataMatrixLIC and HIBCQRLIC encode types. + * Default value: HIBCCode39LIC. + *
+ * @return int Barcode type. + */ + public function getBarcodeType(): int + { + return $this->getIComplexCodetextDTO()->barcodeType; + } + + /** + *+ * Gets or sets barcode type. HIBC LIC codetext can be encoded using HIBCCode39LIC, HIBCCode128LIC, HIBCAztecLIC, HIBCDataMatrixLIC and HIBCQRLIC encode types. + * Default value: HIBCCode39LIC. + *
+ * @return int Barcode type. + */ + public function setBarcodeType(int $value): void + { + $this->getIComplexCodetextDTO()->barcodeType = $value; + } +} \ No newline at end of file diff --git a/lib/ComplexBarcode/HIBCLICDateFormat.php b/lib/ComplexBarcode/HIBCLICDateFormat.php new file mode 100644 index 00000000..828d403f --- /dev/null +++ b/lib/ComplexBarcode/HIBCLICDateFormat.php @@ -0,0 +1,60 @@ + + * Specifies the different types of date formats for HIBC LIC. + * + */ +class HIBCLICDateFormat +{ + /** + *+ * YYYYMMDD format. Will be encoded in additional supplemental data. + *
+ */ + const YYYYMMDD = 0; + /** + *+ * MMYY format. + *
+ */ + const MMYY = 1; + /** + *+ * MMDDYY format. + *
+ */ + const MMDDYY = 2; + /** + *+ * YYMMDD format. + *
+ */ + const YYMMDD = 3; + /** + *+ * YYMMDDHH format. + *
+ */ + const YYMMDDHH = 4; + /** + *+ * Julian date format. + *
+ */ + const YYJJJ = 5; + /** + *+ * Julian date format with hours. + *
+ */ + const YYJJJHH = 6; + /** + *+ * Do not encode expiry date. + *
+ */ + const NONE = 7; +} \ No newline at end of file diff --git a/lib/ComplexBarcode/HIBCLICPrimaryDataCodetext.php b/lib/ComplexBarcode/HIBCLICPrimaryDataCodetext.php new file mode 100644 index 00000000..b55cde7a --- /dev/null +++ b/lib/ComplexBarcode/HIBCLICPrimaryDataCodetext.php @@ -0,0 +1,141 @@ + + * Class for encoding and decoding the text embedded in the HIBC LIC code which stores primary data. + *+ */ +class HIBCLICPrimaryDataCodetext extends HIBCLICComplexCodetext +{ + + function __construct() + { + $this->setIComplexCodetextDTO($this->obtainDto()); + $this->getIComplexCodetextDTO()->complexCodetextType = ComplexCodetextType::HIBCLICPrimaryDataCodetext; + $this->initFieldsFromDto(); + } + + static function construct($HIBCLICPrimaryDataCodetextDto): HIBCLICPrimaryDataCodetext + { + $obj = new HIBCLICPrimaryDataCodetext(); + $obj->setIComplexCodetextDTO($HIBCLICPrimaryDataCodetextDto); + return $obj; + } + + public function obtainDto(...$args) + { + $thriftConnection = new ThriftConnection(); + $client = $thriftConnection->openConnection(); + $complexCodetextDTO = $client->HIBCLICPrimaryDataCodetext_ctor(); + $thriftConnection->closeConnection(); + return $complexCodetextDTO; + } + + public function initFieldsFromDto() + { + $this->primaryData = PrimaryData::construct($this->getIComplexCodetextDTO()->primaryData); + } + + private $primaryData; + + /** + *+ * This sample shows how to encode and decode HIBC LIC using HIBCLICPrimaryCodetext. + *+ * $complexCodetext = new HIBCLICPrimaryCodetext(); + * $complexCodetext->setBarcodeType(EncodeTypes::HIBCQRLIC); + * $complexCodetext->setData(new PrimaryData()); + * $complexCodetext->getData()->setProductOrCatalogNumber("12345"); + * $complexCodetext->getData()->setLabelerIdentificationCode("A999"); + * $complexCodetext->getData()->setUnitOfMeasureID(1); + * $generator = new ComplexBarcodeGenerator($complexCodetext); + * { + * $image = $generator->generateBarCodeImage(BarCodeImageFormat::PNG); + * $reader = new BarCodeReader($image, null, DecodeType::HIBCQRLIC); + * { + * $reader->readBarCodes(); + * $codetext = $reader->getFoundBarCodes()[0]->getCodeText(); + * $result = ComplexCodetextReader::tryDecodeHIBCLIC($codetext) ; + * print("Product or catalog number: " . $result->getData()->getProductOrCatalogNumber()); + * print("Labeler identification code: " . $result->getData()->getLabelerIdentificationCode()); + * print("Unit of measure ID: " . $result->getData()->getUnitOfMeasureID()); + * } + * } + *+ *
+ * Identifies primary data. + *
+ */ + public function getData(): PrimaryData + { + return $this->primaryData; + } + + /** + *+ * Identifies primary data. + *
+ */ + public function setData(PrimaryData $value): void + { + $this->getIComplexCodetextDTO()->primaryData = $value->getPrimaryDataDto(); + $this->primaryData = $value; + } + + /** + *+ * Constructs codetext + *
+ * + * @return string Constructed codetext + */ + public function getConstructedCodetext(): string + { + $thriftConnection = new ThriftConnection(); + $client = $thriftConnection->openConnection(); + $constructedCodetext = $client->HIBCLICPrimaryDataCodetext_getConstructedCodetext($this->getIComplexCodetextDTO()); + $thriftConnection->closeConnection(); + return $constructedCodetext; + } + + /** + *+ * Initializes instance from constructed codetext. + *
+ * + * @param string constructedCodetext Constructed codetext. + */ + public function initFromString(string $constructedCodetext): void + { + $thriftConnection = new ThriftConnection(); + $client = $thriftConnection->openConnection(); + $HIBCLICPrimaryDataCodetextDTO = $client->HIBCLICPrimaryDataCodetext_initFromString($this->getIComplexCodetextDTO(), $constructedCodetext); + $this->setIComplexCodetextDTO($HIBCLICPrimaryDataCodetextDTO); + $thriftConnection->closeConnection(); + $this->initFieldsFromDto(); + } + + /** + *+ * Returns a value indicating whether this instance is equal to a specified {@code HIBCLICPrimaryDataCodetext} value. + *
+ * + * @param bool obj An {@code HIBCLICPrimaryDataCodetext} value to compare to this instance. + * @return {@code true} if obj has the same value as this instance; otherwise, {@code false}. + */ + function equals(HIBCLICPrimaryDataCodetext $obj): bool + { + $thriftConnection = new ThriftConnection(); + $client = $thriftConnection->openConnection(); + $isEqual = $client->HIBCLICPrimaryDataCodetext_equals($this->getIComplexCodetextDTO(), $obj->getIComplexCodetextDTO()); + $thriftConnection->closeConnection(); + return $isEqual; + } +} \ No newline at end of file diff --git a/lib/ComplexBarcode/HIBCLICSecondaryAndAdditionalDataCodetext.php b/lib/ComplexBarcode/HIBCLICSecondaryAndAdditionalDataCodetext.php new file mode 100644 index 00000000..5e290f87 --- /dev/null +++ b/lib/ComplexBarcode/HIBCLICSecondaryAndAdditionalDataCodetext.php @@ -0,0 +1,164 @@ +setBarcodeType(EncodeTypes::HIBCQRLIC); + * $complexCodetext->setLinkCharacter('L'); + * $complexCodetext->setData(new SecondaryAndAdditionalData()); + * $complexCodetext->getData()->setExpiryDate(new Date()); + * $complexCodetext->getData()->setExpiryDateFormat(HIBCLICDateFormat.MMDDYY); + * $complexCodetext->getData()->setQuantity(30); + * $complexCodetext->getData()->setLotNumber("LOT123"); + * $complexCodetext->getData()->setSerialNumber("SERIAL123"); + * $complexCodetext->getData()->setDateOfManufacture(new Date()); + * $generator = new ComplexBarcodeGenerator($complexCodetext); + * $image = $generator->generateBarCodeImage(BarcodeImageFormat::PNG); + * $reader = new BarCodeReader($image, null, DecodeType::HIBCQRLIC); + * $reader->readBarCodes(); + * $codetext = $reader->getFoundBarCodes()[0]->getCodeText(); + * $result = ComplexCodetextReader::tryDecodeHIBCLIC($codetext); + * print("Expiry date: " . $result->getData()->getExpiryDate()); + * print("Quantity: " . $result->getData()->getQuantity()); + * print("Lot number: " . $result->getData()->getLotNumber()); + * print("Serial number: " . $result->getData()->getSerialNumber()); + * print("Date of manufacture: " . $result->getData()->getDateOfManufacture()); + * + * + */ +class HIBCLICSecondaryAndAdditionalDataCodetext extends HIBCLICComplexCodetext +{ + private $data; + + function __construct() + { + $this->setIComplexCodetextDTO($this->obtainDto()); + $this->getIComplexCodetextDTO()->complexCodetextType = ComplexCodetextType::HIBCLICSecondaryAndAdditionalDataCodetext; + $this->initFieldsFromDto(); + } + + static function construct($java_class): HIBCLICSecondaryAndAdditionalDataCodetext + { + $obj = new HIBCLICSecondaryAndAdditionalDataCodetext(); + $obj->setIComplexCodetextDTO($java_class); + $obj->initFieldsFromDto(); + return $obj; + } + + public function obtainDto(...$args) + { + $thriftConnection = new ThriftConnection(); + $client = $thriftConnection->openConnection(); + $HIBCLICSecondaryAndAdditionalDataCodetextDTO = $client->HIBCLICSecondaryAndAdditionalDataCodetext_ctor(); + $thriftConnection->closeConnection(); + return $HIBCLICSecondaryAndAdditionalDataCodetextDTO; + } + + public function initFieldsFromDto() + { + $this->data = SecondaryAndAdditionalData::construct($this->getIComplexCodetextDTO()->secondaryAndAdditionalData); + } + + /** + *+ * Identifies secodary and additional supplemental data. + *
+ */ + public function getData(): SecondaryAndAdditionalData + { + return $this->data; + } + + /** + *+ * Identifies secodary and additional supplemental data. + *
+ */ + public function setData(SecondaryAndAdditionalData $value): void + { + $this->getIComplexCodetextDTO()->secondaryAndAdditionalData = ($value->getSecondaryAndAdditionalDataDto()); + $this->data = $value; + } + + /** + *+ * Identifies link character. + *
+ */ + public function getLinkCharacter(): string + { + return $this->getIComplexCodetextDTO()->linkCharacter; + } + + /** + *+ * Identifies link character. + *
+ */ + public function setLinkCharacter(string $value): void + { + $this->getIComplexCodetextDTO()->linkCharacter = $value; + } + + /** + *+ * Constructs codetext + *
+ * + * @return string Constructed codetext + */ + public function getConstructedCodetext(): string + { + $thriftConnection = new ThriftConnection(); + $client = $thriftConnection->openConnection(); + $constructedCodetext = $client->HIBCLICSecondaryAndAdditionalDataCodetext_getConstructedCodetext($this->getIComplexCodetextDTO()); + $thriftConnection->closeConnection(); + return $constructedCodetext; + } + + /** + *+ * Initializes instance from constructed codetext. + *
+ * + * @param string constructedCodetext Constructed codetext. + */ + function initFromString(string $constructedCodetext): void + { + $thriftConnection = new ThriftConnection(); + $client = $thriftConnection->openConnection(); + $HIBCLICSecondaryAndAdditionalDataCodetext = $client->HIBCLICSecondaryAndAdditionalDataCodetext_initFromString($this->getIComplexCodetextDTO(), $constructedCodetext); + $this->setIComplexCodetextDTO($HIBCLICSecondaryAndAdditionalDataCodetext); + $thriftConnection->closeConnection(); + $this->initFieldsFromDto(); + } + + /** + *+ * Returns a value indicating whether this instance is equal to a specified {@code HIBCLICSecondaryAndAdditionalDataCodetext} value. + *
+ * + * @param obj An {@code HIBCLICSecondaryAndAdditionalDataCodetext} value to compare to this instance. + * @return bool true if obj has the same value as this instance; otherwise, false + */ + public function equals(HIBCLICSecondaryAndAdditionalDataCodetext $obj): bool + { + $thriftConnection = new ThriftConnection(); + $client = $thriftConnection->openConnection(); + $isEqual = $client->HIBCLICSecondaryAndAdditionalDataCodetext_equals($this->getIComplexCodetextDTO(), $obj->getIComplexCodetextDTO()); + $thriftConnection->closeConnection(); + return $isEqual; + } +} \ No newline at end of file diff --git a/lib/ComplexBarcode/HIBCPASCodetext.php b/lib/ComplexBarcode/HIBCPASCodetext.php new file mode 100644 index 00000000..c14618c0 --- /dev/null +++ b/lib/ComplexBarcode/HIBCPASCodetext.php @@ -0,0 +1,221 @@ + + * Class for encoding and decoding the text embedded in the HIBC PAS code. + *+ */ +class HIBCPASCodetext extends IComplexCodetext +{ + private $_recordsList; + + function __construct() + { + $this->setIComplexCodetextDTO($this->obtainDto()); + $this->initFieldsFromDto(); + } + + /** + *+ * This sample shows how to encode and decode HIBC PAS using HIBCPASCodetext. + *+ * + * $complexCodetext = new HIBCPASComplexCodetext(); + * $complexCodetext->setDataLocation(HIBCPASDataLocation::PATIENT); + * $complexCodetext->addRecord(HIBCPASDataType::LABELER_IDENTIFICATION_CODE, "A123"); + * $complexCodetext->addRecord(HIBCPASDataType::MANUFACTURER_SERIAL_NUMBER, "SERIAL123"); + * $complexCodetext->setBarcodeType(EncodeTypes::HIBC_DATA_MATRIX_PAS); + * $generator = new ComplexBarcodeGenerator($complexCodetext); + * { + * BarCodeReader reader = new BarCodeReader($generator->generateBarCodeImage(BarCodeImageFormat::PNG), null, DecodeType::HIBC_DATA_MATRIX_PAS); + * { + * $reader->readBarCodes(); + * $codetext = $reader->getFoundBarCodes()[0]->getCodeText(); + * $readCodetext = ComplexCodetextReader::tryDecodeHIBCPAS($codetext); + * print("Data location: " . $readCodetext->getDataLocation()); + * print("Data type: " . $readCodetext->getRecords()[0]->getDataType()); + * print("Data: " . $readCodetext->getRecords()[0]->getData()); + * print("Data type: " . $readCodetext->getRecords()[1]->getDataType()); + * print("Data: " . $readCodetext->getRecords()[1]->getData()); + * } + * } + *+ *
+ * HIBCPASRecord constructor + *
+ */ + static function construct($HIBCPASCodetextDto): HIBCPASCodetext + { + $obj = new HIBCPASCodetext(); + $obj->setIComplexCodetextDTO($HIBCPASCodetextDto); + $obj->initFieldsFromDto(); + return $obj; + } + + public function obtainDto(...$args) + { + $thriftConnection = new ThriftConnection(); + $client = $thriftConnection->openConnection(); + $dtoRef = $client->HIBCPASCodetext_ctor(); + $thriftConnection->closeConnection(); + return $dtoRef; + } + + public function initFieldsFromDto() + { + $this->_recordsList = array(); + foreach ($this->getIComplexCodetextDTO()->records as $recordDTO) + array_push($this->_recordsList, HIBCPASRecord::construct($recordDTO)); + $this->getIComplexCodetextDTO()->complexCodetextType = ComplexCodetextType::HIBCPASCodetext; + } + + /** + *+ * Gets or sets barcode type. HIBC PAS codetext can be encoded using HIBCCode39PAS, HIBCCode128PAS, HIBCAztec:PAS, HIBCDataMatrixPAS and HIBCQRPAS encode types. + * Default value: HIBCCode39PAS. + *
+ * @param int $value Barcode type. + * @return void + */ + public function setBarcodeType(int $value): void + { + $this->getIComplexCodetextDTO()->barcodeType = $value; + } + + /** + *+ * Identifies data location. + *
+ */ + public function getDataLocation(): int + { + return $this->getIComplexCodetextDTO()->dataLocation; + } + + /** + *+ * Identifies data location. + *
+ */ + public function setDataLocation(int $value): void + { + $this->getIComplexCodetextDTO()->dataLocation = $value; + } + + /** + *+ * Gets records list + *
+ * @return List of records + */ + function getRecords(): array + { + return $this->_recordsList; + } + + /** + *+ * Adds new record + *
+ * @param int dataType Type of data + * @param string data Data string + */ + public function addRecord(int $dataType, string $data): void + { + $hibcPASRecord = new HIBCPASRecord($dataType, $data); + + array_push($this->_recordsList, $hibcPASRecord); + array_push($this->getIComplexCodetextDTO()->records, $hibcPASRecord->getHIBCPASRecordDto()); + } + + /** + *+ * Adds new record + *
+ * @param HIBCPASRecord record Record to be added + * @return void + */ + public function addHIBCPASRecord(HIBCPASRecord $record): void + { + array_push($this->_recordsList, $record); + array_push($this->getIComplexCodetextDTO()->records, $record->getHIBCPASRecordDto()); + } + + /** + *+ * Clears records list + *
+ */ + public function clear(): void + { + $this->_recordsList = array(); + } + + /** + *+ * Gets barcode type. + *
+ * @return int Barcode type. + */ + public function getBarcodeType(): int + { + return $this->getIComplexCodetextDTO()->barcodeType; + } + + /** + *+ * Constructs codetext + *
+ * @return string Constructed codetext + */ + public function getConstructedCodetext(): string + { + $thriftConnection = new ThriftConnection(); + $client = $thriftConnection->openConnection(); + $constructedCodetext = $client->HIBCPASCodetext_getConstructedCodetext($this->getIComplexCodetextDTO()); + $thriftConnection->closeConnection(); + return $constructedCodetext; + } + + /** + *+ * Initializes instance from constructed codetext. + *
+ * @param string constructedCodetext Constructed codetext. + * @return void + */ + public function initFromString(string $constructedCodetext): void + { + $thriftConnection = new ThriftConnection(); + $client = $thriftConnection->openConnection(); + $hibcPASCodetextDTO = $client->HIBCPASCodetext_initFromString($this->getIComplexCodetextDTO(), $constructedCodetext); + $this->setIComplexCodetextDTO($hibcPASCodetextDTO); + $thriftConnection->closeConnection(); + $this->initFieldsFromDto(); + } + + /** + *+ * Returns a value indicating whether this instance is equal to a specified {@code HIBCPASCodetext} value. + *
+ * @param HIBCPASCodetext obj An {@code HIBCPASCodetext} value to compare to this instance. + * @return bool true if obj has the same value as this instance; otherwise, false. + */ + public function equals(HIBCPASCodetext $obj): bool + { + $thriftConnection = new ThriftConnection(); + $client = $thriftConnection->openConnection(); + $isEquals = $client->HIBCPASCodetext_equals($this->getIComplexCodetextDTO(), $obj->getIComplexCodetextDTO()); + $thriftConnection->closeConnection(); + + return $isEquals; + } +} \ No newline at end of file diff --git a/lib/ComplexBarcode/HIBCPASDataLocation.php b/lib/ComplexBarcode/HIBCPASDataLocation.php new file mode 100644 index 00000000..9ca28436 --- /dev/null +++ b/lib/ComplexBarcode/HIBCPASDataLocation.php @@ -0,0 +1,90 @@ + + * HIBC PAS data location types. + * + */ +class HIBCPASDataLocation +{ + /** + *+ * A - Patient + *
+ */ + const PATIENT = 0; + /** + *+ * B - Patient Care Record + *
+ */ + const PATIENT_CARE_RECORD = 1; + /** + *+ * C - Specimen Container + *
+ */ + const SPECIMEN_CONTAINER = 2; + /** + *+ * D - Direct Patient Image Item + *
+ */ + const DIRECT_PATIENT_IMAGE_ITEM = 3; + /** + *+ * E - Business Record + *
+ */ + const BUSINESS_RECORD = 4; + /** + *+ * F - Medical Administration Record + *
+ */ + const MEDICAL_ADMINISTRATION_RECORD = 5; + /** + *+ * G - Library Reference Material + *
+ */ + const LIBRARY_REFERENCE_MATERIAL = 6; + /** + *+ * H - Devices and Materials + *
+ */ + const DEVICES_AND_MATERIALS = 7; + /** + *+ * I - Identification Card + *
+ */ + const IDENTIFICATION_CARD = 8; + /** + *+ * J - Product Container + *
+ */ + const PRODUCT_CONTAINER = 9; + /** + *+ * K - Asset data type + *
+ */ + const ASSET = 10; + /** + *+ * L - Surgical Instrument + *
+ */ + const SURGICAL_INSTRUMENT = 11; + /** + *+ * Z - User Defined + *
+ */ + const USER_DEFINED = 25; +} \ No newline at end of file diff --git a/lib/ComplexBarcode/HIBCPASDataType.php b/lib/ComplexBarcode/HIBCPASDataType.php new file mode 100644 index 00000000..ea9c42e0 --- /dev/null +++ b/lib/ComplexBarcode/HIBCPASDataType.php @@ -0,0 +1,156 @@ + + * HIBC PAS record's data types. + * + */ +class HIBCPASDataType +{ + /** + *+ * A - Labeler Identification Code + *
+ */ + const LABELER_IDENTIFICATION_CODE = 0; + /** + *+ * B - Service Identification + *
+ */ + const SERVICE_IDENTIFICATION = 1; + /** + *+ * C - Patient Identification + *
+ */ + const PATIENT_IDENTIFICATION = 2; + /** + *+ * D - Specimen Identification + *
+ */ + const SPECIMEN_IDENTIFICATION = 3; + /** + *+ * E - Personnel Identification + *
+ */ + const PERSONNEL_IDENTIFICATION = 4; + /** + *+ * F - Administrable Product Identification + *
+ */ + const ADMINISTRABLE_PRODUCT_IDENTIFICATION = 5; + /** + *+ * G - Implantable Product Information + *
+ */ + const IMPLANTABLE_PRODUCT_INFORMATION = 6; + /** + *+ * H - Hospital Item Identification + *
+ */ + const HOSPITAL_ITEM_IDENTIFICATION = 7; + /** + *+ * I - Medical Procedure Identification + *
+ */ + const MEDICAL_PROCEDURE_IDENTIFICATION = 8; + /** + *+ * J - Reimbursement Category + *
+ */ + const REIMBURSEMENT_CATEGORY = 9; + /** + *+ * K - Blood Product Identification + *
+ */ + const BLOOD_PRODUCT_IDENTIFICATION = 10; + /** + *+ * L - Demographic Data + *
+ */ + const DEMOGRAPHIC_DATA = 11; + /** + *+ * M - DateTime in YYYDDDHHMMG format + *
+ */ + const DATE_TIME = 12; + /** + *+ * N - Asset Identification + *
+ */ + const ASSET_IDENTIFICATION = 13; + /** + *+ * O - Purchase Order Number + *
+ */ + const PURCHASE_ORDER_NUMBER = 14; + /** + *+ * P - Dietary Item Identification + *
+ */ + const DIETARY_ITEM_IDENTIFICATION = 15; + /** + *+ * Q - Manufacturer Serial Number + *
+ */ + const MANUFACTURER_SERIAL_NUMBER = 16; + /** + *+ * R - Library Materials Identification + *
+ */ + const LIBRARY_MATERIALS_IDENTIFICATION = 17; + /** + *+ * S - Business Control Number + *
+ */ + const BUSINESS_CONTROL_NUMBER = 18; + /** + *+ * T - Episode of Care Identification + *
+ */ + const EPISODE_OF_CARE_IDENTIFICATION = 19; + /** + *+ * U - Health Industry Number + *
+ */ + const HEALTH_INDUSTRY_NUMBER = 20; + /** + *+ * V - Patient Visit ID + *
+ */ + const PATIENT_VISIT_ID = 21; + /** + *+ * X - XML Document + *
+ */ + const XML_DOCUMENT = 22; + /** + *+ * Z - User Defined + *
+ */ + const USER_DEFINED = 25; +} \ No newline at end of file diff --git a/lib/ComplexBarcode/HIBCPASRecord.php b/lib/ComplexBarcode/HIBCPASRecord.php new file mode 100644 index 00000000..cec718f9 --- /dev/null +++ b/lib/ComplexBarcode/HIBCPASRecord.php @@ -0,0 +1,127 @@ + + * Class for storing HIBC PAS record. + * + */ +class HIBCPASRecord implements Communicator +{ + private $HIBCPASRecordDto; + + /** + * @return mixed + */ + public function getHIBCPASRecordDto() + { + return $this->HIBCPASRecordDto; + } + + /** + * @param mixed $HIBCPASRecordDto + */ + public function setHIBCPASRecordDto($HIBCPASRecordDto): void + { + $this->HIBCPASRecordDto = $HIBCPASRecordDto; + } + + /** + *+ * HIBCPASRecord constructor + *
+ * + * @param int dataType Type of data. + * @param string data + */ + function __construct(int $dataType, string $data) + { + $this->HIBCPASRecordDto = new HIBCPASRecordDTO(); + $this->HIBCPASRecordDto->dataType = $dataType; + $this->HIBCPASRecordDto->data = $data; + $this->initFieldsFromDto(); + } + + /** + *+ * HIBCPASRecord constructor + *
+ */ + static function construct($javaClass): HIBCPASRecord + { + $obj = new HIBCPASRecord(0, ""); + $obj->setHIBCPASRecordDto($javaClass); + return $obj; + } + + public function obtainDto(...$args) + { + + } + + public function initFieldsFromDto() + { + } + + /** + *+ * Identifies data type. + *
+ */ + public function getDataType(): int + { + return $this->getHIBCPASRecordDto()->dataType; + } + + /** + *+ * Identifies data type. + *
+ */ + public function setDataType(int $value): void + { + $this->getHIBCPASRecordDto()->setDataType = $value; + } + + /** + *+ * Identifies data. + *
+ */ + public function getData(): string + { + return $this->getHIBCPASRecordDto()->data; + } + + /** + *+ * Identifies data. + *
+ */ + public function setData(string $value): void + { + $this->getHIBCPASRecordDto()->setData = $value; + } + + /** + *+ * Returns a value indicating whether this instance is equal to a specified {@code HIBCPASDataType} value. + *
+ * + * @param HIBCPASRecord obj An {@code HIBCPASDataType} value to compare to this instance. + * @return bool true if obj has the same value as this instance; otherwise, false. + */ + public function equals(HIBCPASRecord $obj): bool + { + $thriftConnection = new ThriftConnection(); + $client = $thriftConnection->openConnection(); + $isEqual = $client->HIBCPASRecord_equals($this->getHIBCPASRecordDto(), $obj->getHIBCPASRecordDto()); + $thriftConnection->closeConnection(); + return $isEqual; + } +} \ No newline at end of file diff --git a/lib/ComplexBarcode/IComplexCodetext.php b/lib/ComplexBarcode/IComplexCodetext.php new file mode 100644 index 00000000..42c8667f --- /dev/null +++ b/lib/ComplexBarcode/IComplexCodetext.php @@ -0,0 +1,50 @@ + + * Interface for complex codetext used with ComplexBarcodeGenerator. + * + */ +abstract class IComplexCodetext implements Communicator +{ + private $complexCodetext; + + /** + * @return mixed + */ + public function getIComplexCodetextDTO(): IComplexCodetextDTO + { + return $this->complexCodetext; + } + + /** + * @param mixed $HIBCLICCombinedCodetextDto + */ + public function setIComplexCodetextDTO(IComplexCodetextDTO $complexCodetext): void + { + $this->complexCodetext = $complexCodetext; + } + + /** + * Construct codetext for complex barcode + * @return string Constructed codetext + */ + abstract function getConstructedCodetext(): string; + + /** + * Initializes instance with constructed codetext. + * @param string $constructedCodetext Constructed codetext. + */ + public abstract function initFromString(string $constructedCodetext): void; + + /** + * Gets barcode type. + * @return int Barcode type. + */ + abstract function getBarcodeType(): int; +} \ No newline at end of file diff --git a/lib/ComplexBarcode/Mailmark2DCodetext.php b/lib/ComplexBarcode/Mailmark2DCodetext.php new file mode 100644 index 00000000..100c3bc4 --- /dev/null +++ b/lib/ComplexBarcode/Mailmark2DCodetext.php @@ -0,0 +1,569 @@ +setIComplexCodetextDTO($this->obtainDto()); + $this->getIComplexCodetextDTO()->complexCodetextType = ComplexCodetextType::Mailmark2DCodetext; + $this->initFieldsFromDto(); + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + static function construct($complexCodetextDTO) + { + try + { + $class = new Mailmark2DCodetext(); + $class->setIComplexCodetextDTO($complexCodetextDTO); + $class->initFieldsFromDto(); + return $class; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + public function obtainDto(...$args) + { + $thriftConnection = new ThriftConnection(); + $client = $thriftConnection->openConnection(); + $dtoRef = $client->Mailmark2DCodetext_ctor(); + $thriftConnection->closeConnection(); + + return $dtoRef; + } + + public function initFieldsFromDto() + { + } + + /** + * Identifies the UPU Country ID.Max length: 4 characters. + * @return string Country ID + */ + public function getUPUCountryID(): string + { + return $this->getIComplexCodetextDTO()->UPUCountryID; + } + + /** + * Identifies the UPU Country ID.Max length: 4 characters. + * @param string $value Country ID + */ + public function setUPUCountryID(string $value): void + { + try + { + $this->getIComplexCodetextDTO()->UPUCountryID = $value; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Identifies the Royal Mail Mailmark barcode payload for each product type. + * Valid Values: + * + * "0" - Domestic Sorted & Unsorted + * "A" - Online Postage + * "B" - Franking + * "C" - Consolidation + * + * @return string Information type ID + */ + public function getInformationTypeID(): string + { + try + { + return $this->getIComplexCodetextDTO()->informationTypeID; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Identifies the Royal Mail Mailmark barcode payload for each product type. + * Valid Values: + * + * "0" - Domestic Sorted & Unsorted + * "A" - Online Postage + * "B" - Franking + * "C" - Consolidation + * + * @param string $value Information type ID + */ + public function setInformationTypeID(string $value): void + { + try + { + $this->getIComplexCodetextDTO()->informationTypeID = $value; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Identifies the barcode version as relevant to each Information Type ID. + * Valid Values: + * + * Currently "1". + * "0" & "2" to "9" and "A" to "Z" spare reserved for potential future use. + * + * @return string Version ID + */ + public function getVersionID(): string + { + return (string)$this->getIComplexCodetextDTO()->versionID; + } + + /** + * Identifies the barcode version as relevant to each Information Type ID. + * Valid Values: + * + * Currently "1". + * "0" & "2" to "9" and "A" to "Z" spare reserved for potential future use. + * + * @param string $value Version ID + */ + public function setVersionID(string $value): void + { + try + { + $this->getIComplexCodetextDTO()->versionID = (int)$value; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Identifies the class of the item. + * + * Valid Values: + * "1" - 1C (Retail) + * "2" - 2C (Retail) + * "3" - Economy (Retail) + * "5" - Deffered (Retail) + * "8" - Premium (Network Access) + * "9" - Standard (Network Access) + * + * @return string class of the item + */ + public function getClass_(): string + { + try + { + return $this->getIComplexCodetextDTO()->class_; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Identifies the class of the item. + * + * Valid Values: + * "1" - 1C (Retail) + * "2" - 2C (Retail) + * "3" - Economy (Retail) + * "5" - Deffered (Retail) + * "8" - Premium (Network Access) + * "9" - Standard (Network Access) + * + * @param string $value class of the item + */ + public function setClass_(string $value): void + { + try + { + $this->getIComplexCodetextDTO()->class_ = $value; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Identifies the unique group of customers involved in the mailing. + * Max value: 9999999. + * + * @return int Supply chain ID + */ + public function getSupplyChainID(): int + { + try + { + return $this->getIComplexCodetextDTO()->supplyChainID; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Identifies the unique group of customers involved in the mailing. + * Max value: 9999999. + * + * @param int $value Supply chain ID + */ + public function setSupplyChainID(int $value): void + { + try + { + $this->getIComplexCodetextDTO()->supplyChainID = $value; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Identifies the unique item within the Supply Chain ID. + * Every Mailmark barcode is required to carry an ID + * so it can be uniquely identified for at least 90 days. + * Max value: 99999999. + * + * @return int item within the Supply Chain ID + */ + public function getItemID(): int + { + try + { + return $this->getIComplexCodetextDTO()->itemID; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Identifies the unique item within the Supply Chain ID. + * Every Mailmark barcode is required to carry an ID + * so it can be uniquely identified for at least 90 days. + * Max value: 99999999. + * + * @param int $value item within the Supply Chain ID + */ + public function setItemID(int $value): void + { + try + { + $this->getIComplexCodetextDTO()->itemID = $value; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Contains the Postcode of the Delivery Address with DPS + * If inland the Postcode/DP contains the following number of characters. + * Area (1 or 2 characters) District(1 or 2 characters) + * Sector(1 character) Unit(2 characters) DPS (2 characters). + * The Postcode and DPS must comply with a valid PAF® format. + * + * @return string the Postcode of the Delivery Address with DPS + */ + public function getDestinationPostCodeAndDPS(): string + { + try + { + return $this->getIComplexCodetextDTO()->destinationPostCodeAndDPS; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Contains the Postcode of the Delivery Address with DPS + * If inland the Postcode/DP contains the following number of characters. + * Area (1 or 2 characters) District(1 or 2 characters) + * Sector(1 character) Unit(2 characters) DPS (2 characters). + * The Postcode and DPS must comply with a valid PAF® format. + * + * @param string $value the Postcode of the Delivery Address with DPS + */ + public function setDestinationPostCodeAndDPS(string $value): void + { + try + { + $this->getIComplexCodetextDTO()->destinationPostCodeAndDPS = $value; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Flag which indicates what level of Return to Sender service is being requested. + * + * @return string RTS Flag + */ + public function getRTSFlag(): string + { + try + { + return $this->getIComplexCodetextDTO()->RTSFlag; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Flag which indicates what level of Return to Sender service is being requested. + * + * @param string $value RTS Flag + */ + public function setRTSFlag(string $value): void + { + try + { + $this->getIComplexCodetextDTO()->RTSFlag = $value; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Contains the Return to Sender Post Code but no DPS. + * The PC(without DPS) must comply with a PAF® format. + * + * @return string Return to Sender Post Code but no DPS + */ + public function getReturnToSenderPostCode(): string + { + try + { + return $this->getIComplexCodetextDTO()->returnToSenderPostCode; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Contains the Return to Sender Post Code but no DPS. + * The PC(without DPS) must comply with a PAF® format. + * + * @param string $value Return to Sender Post Code but no DPS + */ + public function setReturnToSenderPostCode(string $value): void + { + try + { + $this->getIComplexCodetextDTO()->returnToSenderPostCode = $value; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Optional space for use by customer. + * + * Max length by Type: + * Type 7: 6 characters + * Type 9: 45 characters + * Type 29: 25 characters + * + * @return string Customer content + */ + public function getCustomerContent(): string + { + try + { + return $this->getIComplexCodetextDTO()->customerContent; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Optional space for use by customer. + * + * Max length by Type: + * Type 7: 6 characters + * Type 9: 45 characters + * Type 29: 25 characters + * + * @param string $value Customer content + */ + public function setCustomerContent(string $value): void + { + try + { + $this->getIComplexCodetextDTO()->customerContent = $value; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Encode mode of Datamatrix barcode. + * Default value: DataMatrixEncodeMode.C40. + * + * @return int Encode mode of Datamatrix barcode. + */ + public function getCustomerContentEncodeMode(): int + { + try + { + return $this->getIComplexCodetextDTO()->customerContentEncodeMode; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Encode mode of Datamatrix barcode. + * Default value: DataMatrixEncodeMode.C40. + * + * @param int $value Encode mode of Datamatrix barcode. + */ + public function setCustomerContentEncodeMode(int $value): void + { + try + { + $this->getIComplexCodetextDTO()->customerContentEncodeMode = $value; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * 2D Mailmark Type defines size of Data Matrix barcode. + * + * @return int Size of Data Matrix barcode + */ + public function getDataMatrixType(): int + { + try + { + return $this->getIComplexCodetextDTO()->dataMatrixType; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * 2D Mailmark Type defines size of Data Matrix barcode. + * + * @param int $value Size of Data Matrix barcode + */ + public function setDataMatrixType(int $value): void + { + try + { + $this->getIComplexCodetextDTO()->dataMatrixType = $value; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Construct codetext from Mailmark data. + * @return string Constructed codetext + */ + public function getConstructedCodetext(): string + { + try + { + $thriftConnection = new ThriftConnection(); + $client = $thriftConnection->openConnection(); + $constructedCodetext = $client->Mailmark2DCodetext_getConstructedCodetext($this->getIComplexCodetextDTO()); + $thriftConnection->closeConnection(); + return $constructedCodetext; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Initializes Mailmark data from constructed codetext. + * @param string $constructedCodetext Constructed codetext. + */ + public function initFromString($constructedCodetext): void + { + try + { + $thriftConnection = new ThriftConnection(); + $client = $thriftConnection->openConnection(); + $this->setIComplexCodetextDTO($client->Mailmark2DCodetext_initFromString($this->getIComplexCodetextDTO(), $constructedCodetext)); + $thriftConnection->closeConnection(); + $this->initFieldsFromDto(); + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Gets barcode type. + * @return int Barcode type. + */ + public function getBarcodeType(): int + { + $barcode_type = $this->getIComplexCodetextDTO()->barcodeType; + return $barcode_type; + } +} \ No newline at end of file diff --git a/lib/ComplexBarcode/Mailmark2DType.php b/lib/ComplexBarcode/Mailmark2DType.php new file mode 100644 index 00000000..00190d5c --- /dev/null +++ b/lib/ComplexBarcode/Mailmark2DType.php @@ -0,0 +1,29 @@ +setIComplexCodetextDTO($this->obtainDto()); + $this->getIComplexCodetextDTO()->complexCodetextType = ComplexCodetextType::MailmarkCodetext; + $this->initFieldsFromDto(); + } + + public function initFieldsFromDto() + { + } + + public function obtainDto(...$args): IComplexCodetextDTO + { + $thriftConnection = new ThriftConnection(); + $client = $thriftConnection->openConnection(); + $dtoRef = $client->MailmarkCodetext_ctor(); + $thriftConnection->closeConnection(); + + return $dtoRef; + } + + /** + * "0" – Null or Test + * "1" – Letter + * "2" – Large Letter + */ + public function getFormat(): int + { + return $this->getIComplexCodetextDTO()->format; + } + + /** + * "0" – Null or Test + * "1" – LetterN + * "2" – Large Letter + */ + public function setFormat(int $value) + { + $this->getIComplexCodetextDTO()->format = $value; + } + + /** + * Currently 1 – For Mailmark barcode (0 and 2 to 9 and A to Z spare for future use) + */ + public function getVersionID(): int + { + return $this->getIComplexCodetextDTO()->versionID; + } + + /** + * Currently 1 – For Mailmark barcode (0 and 2 to 9 and A to Z spare for future use) + */ + public function setVersionID(int $value) + { + $this->getIComplexCodetextDTO()->versionID = $value; + } + + /** + * "0" - Null or Test + * "1" - 1C (Retail) + * "2" - 2C (Retail) + * "3" - 3C (Retail) + * "4" - Premium (RetailPublishing Mail) (for potential future use) + * "5" - Deferred (Retail) + * "6" - Air (Retail) (for potential future use) + * "7" - Surface (Retail) (for potential future use) + * "8" - Premium (Network Access) + * "9" - Standard (Network Access) + */ + public function getClass_(): string + { + return $this->getIComplexCodetextDTO()->class_; + } + + /** + * "0" - Null or Test + * "1" - 1C (Retail) + * "2" - 2C (Retail) + * "3" - 3C (Retail) + * "4" - Premium (RetailPublishing Mail) (for potential future use) + * "5" - Deferred (Retail) + * "6" - Air (Retail) (for potential future use) + * "7" - Surface (Retail) (for potential future use) + * "8" - Premium (Network Access) + * "9" - Standard (Network Access) + */ + public function setClass_(string $value) + { + $this->getIComplexCodetextDTO()->class_ = $value; + } + + /** + * Maximum values are 99 for Barcode C and 999999 for Barcode L. + */ + public function getSupplyChainID(): int + { + return $this->getIComplexCodetextDTO()->supplyChainID; + } + + /** + * Maximum values are 99 for Barcode C and 999999 for Barcode L. + */ + public function setSupplyChainID(int $value) + { + $this->getIComplexCodetextDTO()->supplyChainID = $value; + } + + /** + * Maximum value is 99999999. + */ + public function getItemID(): int + { + return $this->getIComplexCodetextDTO()->itemID; + } + + /** + * Maximum value is 99999999. + */ + public function setItemID(int $value) + { + $this->getIComplexCodetextDTO()->itemID = $value; + } + + /** + * The PC and DP must comply with a PAF format. + * Nine character string denoting international "XY11 " (note the 5 trailing spaces) or a pattern + * of characters denoting a domestic sorting code. + * A domestic sorting code consists of an outward postcode, an inward postcode, and a Delivery Point Suffix. + */ + public function getDestinationPostCodePlusDPS(): string + { + return $this->getIComplexCodetextDTO()->destinationPostCodePlusDPS; + } + + /** + * The PC and DP must comply with a PAF format. + * Nine character string denoting international "XY11 " (note the 5 trailing spaces) or a pattern + * of characters denoting a domestic sorting code. + * A domestic sorting code consists of an outward postcode, an inward postcode, and a Delivery Point Suffix. + */ + public function setDestinationPostCodePlusDPS(string $value) + { + $this->getIComplexCodetextDTO()->destinationPostCodePlusDPS = $value; + } + + /** + * Construct codetext from Mailmark data. + * + * @return string Constructed codetext + */ + public function getConstructedCodetext(): string + { + $thriftConnection = new ThriftConnection(); + $client = $thriftConnection->openConnection(); + $constructedCodetext = $client->MailmarkCodetext_getConstructedCodetext($this->getIComplexCodetextDTO()); + $thriftConnection->closeConnection(); + return $constructedCodetext; + } + + /** + * Initializes Mailmark data from constructed codetext. + * + * @param string $constructedCodetext Constructed codetext. + */ + public function initFromString($constructedCodetext): void + { + $thriftConnection = new ThriftConnection(); + $client = $thriftConnection->openConnection(); + $this->setIComplexCodetextDTO($client->MailmarkCodetext_initFromString($this->getIComplexCodetextDTO(), $constructedCodetext)); + $thriftConnection->closeConnection(); + $this->initFieldsFromDto(); + } + + /** + * Gets barcode type. + * + * @return int Barcode type. + */ + public function getBarcodeType(): int + { + $barcode_type = $this->getIComplexCodetextDTO()->barcodeType; + return $barcode_type; + } +} \ No newline at end of file diff --git a/lib/ComplexBarcode/MaxiCodeCodetext.php b/lib/ComplexBarcode/MaxiCodeCodetext.php new file mode 100644 index 00000000..5e75fd23 --- /dev/null +++ b/lib/ComplexBarcode/MaxiCodeCodetext.php @@ -0,0 +1,65 @@ +readBarCodes() as $result) + * { + * $resultMaxiCodeCodetext = ComplexCodetextReader::tryDecodeMaxiCode($result->getExtended()->getMaxiCode()->getMaxiCodeMode(), $result->getCodeText()); + * print("BarCode Type: ".$resultMaxiCodeCodetext->getBarcodeType()); + * print("MaxiCode mode: ".$resultMaxiCodeCodetext->getMode()); + * print("BarCode CodeText: ".$resultMaxiCodeCodetext->getConstructedCodetext()); + * } + * @endcode + */ +abstract class MaxiCodeCodetext extends IComplexCodetext +{ + /** + * Gets a MaxiCode encode mode. + */ + public function getMaxiCodeEncodeMode(): int + { + return $this->getIComplexCodetextDTO()->maxiCodeEncodeMode; + } + + /** + * Sets a MaxiCode encode mode. + */ + public function setMaxiCodeEncodeMode(int $value): void + { + $this->getIComplexCodetextDTO()->maxiCodeEncodeMode = $value; + } + + /** + * Gets ECI encoding. Used when MaxiCodeEncodeMode is AUTO. + */ + public function getECIEncoding(): int + { + return $this->getIComplexCodetextDTO()->ECIEncoding; + } + + /** + * Sets ECI encoding. Used when MaxiCodeEncodeMode is AUTO. + */ + public function setECIEncoding(int $value): void + { + $this->getIComplexCodetextDTO()->ECIEncoding = $value; + } + + /** + * Gets barcode type. + * @return int Barcode type + */ + public function getBarcodeType(): int + { + return $this->getIComplexCodetextDTO()->barcodeType; + } +} \ No newline at end of file diff --git a/lib/ComplexBarcode/MaxiCodeCodetextMode2.php b/lib/ComplexBarcode/MaxiCodeCodetextMode2.php new file mode 100644 index 00000000..8ee76244 --- /dev/null +++ b/lib/ComplexBarcode/MaxiCodeCodetextMode2.php @@ -0,0 +1,157 @@ + + * This sample shows how to encode and decode MaxiCode codetext for mode 2. + * @code + * //Mode 2 with standart second message + * $maxiCodeCodetext = new MaxiCodeCodetextMode2(); + * $maxiCodeCodetext->setPostalCode("524032140"); + * $maxiCodeCodetext->setCountryCode(056); + * $maxiCodeCodetext->setServiceCategory(999); + * $maxiCodeStandartSecondMessage = new MaxiCodeStandartSecondMessage(); + * $maxiCodeStandartSecondMessage->setMessage("Test message"); + * $maxiCodeCodetext->setSecondMessage($maxiCodeStandartSecondMessage); + * $complexGenerator = new ComplexBarcodeGenerator($maxiCodeCodetext); + * $complexGenerator->generateBarCodeImage(BarcodeImageFormat::PNG); + * + * //Mode 2 with structured second message + * $maxiCodeCodetext = new MaxiCodeCodetextMode2(); + * $maxiCodeCodetext->setPostalCode("524032140"); + * $maxiCodeCodetext->setCountryCode(056); + * $maxiCodeCodetext->setServiceCategory(999); + * $maxiCodeStructuredSecondMessage = new MaxiCodeStructuredSecondMessage(); + * $maxiCodeStructuredSecondMessage->add("634 ALPHA DRIVE"); + * $maxiCodeStructuredSecondMessage->add("PITTSBURGH"); + * $maxiCodeStructuredSecondMessage->add("PA"); + * $maxiCodeStructuredSecondMessage->setYear(99); + * $maxiCodeCodetext->setSecondMessage(maxiCodeStructuredSecondMessage); + * $complexGenerator = new ComplexBarcodeGenerator($maxiCodeCodetext); + * $complexGenerator->generateBarCodeImage(BarcodeImageFormat::PNG); + * + * //Decoding raw codetext with standart second message + * $reader = new BarCodeReader("c:\\test.png", DecodeType::MAXI_CODE); + * { + * foreach($reader->readBarCodes() as $result) + * { + * $resultMaxiCodeCodetext = ComplexCodetextReader::tryDecodeMaxiCode($result->getExtended()->getMaxiCode()->getMaxiCodeMode(), $result->getCodeText()); + * if ($resultMaxiCodeCodetext instanceof MaxiCodeCodetextMode2) + * { + * $maxiCodeStructuredCodetext = $resultMaxiCodeCodetext; + * print("BarCode Type: ".$maxiCodeStructuredCodetext->getPostalCode()); + * print("MaxiCode mode: ".$maxiCodeStructuredCodetext->getCountryCode()); + * print("BarCode CodeText: ".$maxiCodeStructuredCodetext->getServiceCategory()); + * if ($maxiCodeStructuredCodetext->getSecondMessage() instanceof MaxiCodeStandartSecondMessage){ + * $secondMessage = $maxiCodeStructuredCodetext->getSecondMessage(); + * print("Message: ".$secondMessage->getMessage()); + * } + * } + * } + * } + * //Decoding raw codetext with structured second message + * $reader = new BarCodeReader("c:\\test.png", DecodeType::MAXI_CODE); + * { + * foreach($reader->readBarCodes() as $result) + * { + * $resultMaxiCodeCodetext = ComplexCodetextReader::tryDecodeMaxiCode($result->getExtended()->getMaxiCode()->getMaxiCodeMode(), $result->getCodeText()); + * if ($resultMaxiCodeCodetext instanceof MaxiCodeCodetextMode2){ + * $maxiCodeStructuredCodetext = $resultMaxiCodeCodetext; + * print("BarCode Type: ".$maxiCodeStructuredCodetext->getPostalCode()); + * print("MaxiCode mode: ".$maxiCodeStructuredCodetext->getCountryCode()); + * print("BarCode CodeText: ".$maxiCodeStructuredCodetext->getServiceCategory()); + * if ($maxiCodeStructuredCodetext->getSecondMessage() instanceof MaxiCodeStructuredSecondMessage) + * { + * $secondMessage = $maxiCodeStructuredCodetext->getSecondMessage(); + * print("Message:"); + * for ($secondMessage->getIdentifiers() as $identifier){ + * print($identifier); + * } + * } + * } + * } + * } + * @endcode + * + */ +class MaxiCodeCodetextMode2 extends MaxiCodeStructuredCodetext +{ + + public function __construct() + { + try + { + $this->setIComplexCodetextDTO($this->obtainDto()); + $this->initFieldsFromDto(); + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + static function construct($maxiCodeCodetextMode2Dto) + { + $class_ = new MaxiCodeCodetextMode2(); + $class_->setIComplexCodetextDTO($maxiCodeCodetextMode2Dto); + $class_->initFieldsFromDto(); + return $class_; + } + + public function obtainDto(...$args) + { + $thriftConnection = new ThriftConnection(); + $client = $thriftConnection->openConnection(); + $dtoObj = $client->MaxiCodeCodetextMode2_ctor(); + $thriftConnection->closeConnection(); + return $dtoObj; + } + + public function initFieldsFromDto(): void + { + parent::initFieldsFromDto(); + } + + /** + * Gets MaxiCode mode. + * @return int MaxiCode mode + */ + public function getMode(): int + { + return $this->getIComplexCodetextDTO()->mode; + } + + public function initFromString(string $constructedCodetext): void + { + $thriftConnection = new ThriftConnection(); + $client = $thriftConnection->openConnection(); + $this->setIComplexCodetextDTO($client->MaxiCodeCodetextMode2_initFromString($this->getIComplexCodetextDTO(), $constructedCodetext)); + $thriftConnection->closeConnection(); + } + + public function getConstructedCodetext(): string + { + $thriftConnection = new ThriftConnection(); + $client = $thriftConnection->openConnection(); + $constructedCodetext = $client->MaxiCodeCodetextMode2_getConstructedCodetext($this->getIComplexCodetextDTO()); + $thriftConnection->closeConnection(); + return $constructedCodetext; + } + + public function equals($obj): bool + { + $thriftConnection = new ThriftConnection(); + $client = $thriftConnection->openConnection(); + $isEqual = $client->MaxiCodeCodetextMode2_equals($this->getIComplexCodetextDTO(), $obj->getIComplexCodetextDTO()); + $thriftConnection->closeConnection(); + return $isEqual; + } +} \ No newline at end of file diff --git a/lib/ComplexBarcode/MaxiCodeCodetextMode3.php b/lib/ComplexBarcode/MaxiCodeCodetextMode3.php new file mode 100644 index 00000000..c2d5f44c --- /dev/null +++ b/lib/ComplexBarcode/MaxiCodeCodetextMode3.php @@ -0,0 +1,152 @@ +setPostalCode("B1050"); + * $maxiCodeCodetext->setCountryCode(056); + * $maxiCodeCodetext->setServiceCategory(999); + * MaxiCodeStandartSecondMessage maxiCodeStandartSecondMessage = new MaxiCodeStandartSecondMessage(); + * maxiCodeStandartSecondMessage->setMessage("Test message"); + * $maxiCodeCodetext->setSecondMessage(maxiCodeStandartSecondMessage); + * ComplexBarcodeGenerator complexGenerator = new ComplexBarcodeGenerator($maxiCodeCodetext); + * complexGenerator.generateBarCodeImage(BarcodeImageFormat::PNG); + * + * //Mode 3 with structured second message + * MaxiCodeCodetextMode3 $maxiCodeCodetext = new MaxiCodeCodetextMode3(); + * $maxiCodeCodetext->setPostalCode("B1050"); + * $maxiCodeCodetext->setCountryCode(056); + * $maxiCodeCodetext->setServiceCategory(999); + * $maxiCodeStructuredSecondMessage = new MaxiCodeStructuredSecondMessage(); + * $maxiCodeStructuredSecondMessage->add("634 ALPHA DRIVE"); + * $maxiCodeStructuredSecondMessage->add("PITTSBURGH"); + * $maxiCodeStructuredSecondMessage->add("PA"); + * $maxiCodeStructuredSecondMessage->setYear(99); + * $maxiCodeCodetext->setSecondMessage($maxiCodeStructuredSecondMessage); + * $complexGenerator = new ComplexBarcodeGenerator($maxiCodeCodetext); + * $complexGenerator->generateBarCodeImage(BarcodeImageFormat::PNG); + * + * //Decoding raw codetext with standart second message + * $reader = new BarCodeReader("c:\\test.png", DecodeType::MAXI_CODE); + * foreach($reader->readBarCodes() as $result) + * { + * $resultMaxiCodeCodetext = ComplexCodetextReader::tryDecodeMaxiCode($result->getExtended()->getMaxiCode()->getMaxiCodeMode(), $result->getCodeText()); + * if ($resultMaxiCodeCodetext instanceOf MaxiCodeCodetextMode3) + * { + * MaxiCodeCodetextMode3 maxiCodeStructuredCodetext = (MaxiCodeCodetextMode3)$resultMaxiCodeCodetext; + * print("BarCode Type: ".$maxiCodeStructuredCodetext->getPostalCode()); + * print("MaxiCode mode: ".$maxiCodeStructuredCodetext->getCountryCode()); + * print("BarCode CodeText: ".$maxiCodeStructuredCodetext->getServiceCategory()); + * if ($maxiCodeStructuredCodetext->getSecondMessage() instanceOf MaxiCodeStandartSecondMessage) + * { + * $secondMessage = maxiCodeStructuredCodetext->getSecondMessage(); + * print("Message: ".$secondMessage->getMessage()); + * } + * } + * } + * //Decoding raw codetext with structured second message + * $reader = new BarCodeReader("c:\\test.png", DecodeType::MAXI_CODE); + * foreach($reader->readBarCodes() as $result) + * { + * $resultMaxiCodeCodetext = ComplexCodetextReader::tryDecodeMaxiCode($result->getExtended()->getMaxiCode()->getMaxiCodeMode(), $result->getCodeText()); + * if ($resultMaxiCodeCodetext instanceOf MaxiCodeCodetextMode3) + * { + * maxiCodeStructuredCodetext = $resultMaxiCodeCodetext; + * print("BarCode Type: ".$maxiCodeStructuredCodetext->getPostalCode()); + * print("MaxiCode mode: ".$maxiCodeStructuredCodetext->getCountryCode()); + * print("BarCode CodeText: ".$maxiCodeStructuredCodetext->getServiceCategory()); + * if (maxiCodeStructuredCodetext->getSecondMessage() instanceOf MaxiCodeStructuredSecondMessage) + * { + * $secondMessage = $maxiCodeStructuredCodetext->getSecondMessage(); + * print("Message:"); + * foreach($secondMessage->getIdentifiers() as $identifier) + * { + * print($identifier); + * } + * } + * } + * } + * @endcode + */ +class MaxiCodeCodetextMode3 extends MaxiCodeStructuredCodetext +{ + public function __construct() + { + try + { + $this->setIComplexCodetextDTO($this->obtainDto()); + $this->initFieldsFromDto(); + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + static function construct($maxiCodeCodetextMode2Dto) + { + $class_ = new MaxiCodeCodetextMode3(); + $class_->setIComplexCodetextDTO($maxiCodeCodetextMode2Dto); + $class_->initFieldsFromDto(); + return $class_; + } + + public function obtainDto(...$args) + { + $thriftConnection = new ThriftConnection(); + $client = $thriftConnection->openConnection(); + $dtoObj = $client->MaxiCodeCodetextMode3_ctor(); + $thriftConnection->closeConnection(); + return $dtoObj; + } + + public function initFieldsFromDto(): void + { + parent::initFieldsFromDto(); + } + + /** + * Gets MaxiCode mode. + * @return int MaxiCode mode + */ + public function getMode(): int + { + return $this->getIComplexCodetextDTO()->mode; + } + + public function getConstructedCodetext(): string + { + $thriftConnection = new ThriftConnection(); + $client = $thriftConnection->openConnection(); + $constructedCodetext = $client->MaxiCodeCodetextMode3_getConstructedCodetext($this->getIComplexCodetextDTO()); + $thriftConnection->closeConnection(); + return $constructedCodetext; + } + + public function initFromString(string $constructedCodetext): void + { + $thriftConnection = new ThriftConnection(); + $client = $thriftConnection->openConnection(); + $this->setIComplexCodetextDTO($client->MaxiCodeCodetextMode3_initFromString($this->getIComplexCodetextDTO(), $constructedCodetext)); + $thriftConnection->closeConnection(); + } + + public function equals($obj): bool + { + $thriftConnection = new ThriftConnection(); + $client = $thriftConnection->openConnection(); + $isEqual = $client->MaxiCodeCodetextMode3_equals($this->getIComplexCodetextDTO(), $obj->getIComplexCodetextDTO()); + $thriftConnection->closeConnection(); + return $isEqual; + } +} \ No newline at end of file diff --git a/lib/ComplexBarcode/MaxiCodeSecondMessage.php b/lib/ComplexBarcode/MaxiCodeSecondMessage.php new file mode 100644 index 00000000..c2d62216 --- /dev/null +++ b/lib/ComplexBarcode/MaxiCodeSecondMessage.php @@ -0,0 +1,44 @@ +maxiCodeSecondMessageDto; + } + + /** + * @param mixed $maxiCodeSecondMessageDto + */ + public function setMaxiCodeSecondMessageDto(\Aspose\Barcode\Bridge\MaxiCodeSecondMessageDTO $maxiCodeSecondMessageDto): void + { + $this->maxiCodeSecondMessageDto = $maxiCodeSecondMessageDto; + } + + + public function obtainDto(...$args) + { + } + + public function initFieldsFromDto() + { + } + + /** + * Gets constructed second message + * @return string Constructed second message + */ + public abstract function getMessage(): string; +} \ No newline at end of file diff --git a/lib/ComplexBarcode/MaxiCodeSecondMessageType.php b/lib/ComplexBarcode/MaxiCodeSecondMessageType.php new file mode 100644 index 00000000..ec7f8834 --- /dev/null +++ b/lib/ComplexBarcode/MaxiCodeSecondMessageType.php @@ -0,0 +1,9 @@ +setMode(MaxiCodeMode.MODE_4); + * $maxiCodeCodetext->setMessage("Test message"); + * $complexGenerator = new ComplexBarcodeGenerator($maxiCodeCodetext->getConstructedCodetext()); + * $complexGenerator->generateBarCodeImage(BarcodeImageFormat::PNG); + * + * //Mode 5 + * $maxiCodeCodetext = new MaxiCodeStandardCodetext(); + * $maxiCodeCodetext->setMode(MaxiCodeMode.MODE_5); + * $maxiCodeCodetext->setMessage("Test message"); + * ComplexBarcodeGenerator complexGenerator = new ComplexBarcodeGenerator($maxiCodeCodetext->getConstructedCodetext()); + * $complexGenerator->generateBarCodeImage(BarcodeImageFormat::PNG); + * + * //Mode 6 + * $maxiCodeCodetext = new MaxiCodeStandardCodetext(); + * $maxiCodeCodetext->setMode(MaxiCodeMode.MODE_6); + * $maxiCodeCodetext->setMessage("Test message"); + * $complexGenerator = new ComplexBarcodeGenerator($maxiCodeCodetext->getConstructedCodetext()); + * $complexGenerator->generateBarCodeImage(BarcodeImageFormat::PNG); + * @endcode + */ +class MaxiCodeStandardCodetext extends MaxiCodeCodetext +{ + + function __construct() + { + try + { + $this->setIComplexCodetextDTO($this->obtainDto()); + $this->initFieldsFromDto(); + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + static function construct($maxiCodeStandardCodetextDto) + { + $class_ = new MaxiCodeStandardCodetext(); + $class_->setIComplexCodetextDTO($maxiCodeStandardCodetextDto); + $class_->initFieldsFromDto(); + + return $class_; + } + + public function obtainDto(...$args): IComplexCodetextDTO + { + $thriftConnection = new ThriftConnection(); + $client = $thriftConnection->openConnection(); + $maxiCodeStandardCodetextDTO = $client->MaxiCodeStandardCodetext_ctor(); + $thriftConnection->closeConnection(); + return $maxiCodeStandardCodetextDTO; + } + + public function initFieldsFromDto() + { + } + + /** + * Gets message. + */ + public function getMessage(): ?string + { + return $this->getIComplexCodetextDTO()->message; + } + + /** + * Sets message. + */ + public function setMessage(string $value): void + { + $this->getIComplexCodetextDTO()->message = $value; + } + + /** + * Sets MaxiCode mode. Standart codetext can be used only with modes 4, 5 and 6. + */ + public function setMode(int $mode): void + { + $this->getIComplexCodetextDTO()->mode = $mode; + } + + /** + * Gets MaxiCode mode. + * @return int MaxiCode mode + */ + public function getMode(): int + { + return $this->getIComplexCodetextDTO()->mode; + } + + /** + * Constructs codetext + * @return string Constructed codetext + */ + public function getConstructedCodetext(): string + { + return $this->getMessage(); + } + + /** + * Initializes instance from constructed codetext. + * @param string constructedCodetext Constructed codetext. + */ + public function initFromString(string $constructedCodetext): void + { + $thriftConnection = new ThriftConnection(); + $client = $thriftConnection->openConnection(); + $this->setIComplexCodetextDTO($client->MaxiCodeStandardCodetext_initFromString($this->getIComplexCodetextDTO(), $constructedCodetext)); + $thriftConnection->closeConnection(); + } + + /** + * Returns a value indicating whether this instance is equal to a specified MaxiCodeStandardCodetext value. + * @param object obj An MaxiCodeStandardCodetext value to compare to this instance. + * @return bool if obj has the same value as this instance; otherwise, false. + */ + public function equals($obj): bool + { + $thriftConnection = new ThriftConnection(); + $client = $thriftConnection->openConnection(); + $isEqual = $client->MaxiCodeStandardCodetext_equals($this->getIComplexCodetextDTO(), $obj->getIComplexCodetextDTO()); + $thriftConnection->closeConnection(); + return $isEqual; + } +} \ No newline at end of file diff --git a/lib/ComplexBarcode/MaxiCodeStandartSecondMessage.php b/lib/ComplexBarcode/MaxiCodeStandartSecondMessage.php new file mode 100644 index 00000000..b116b13a --- /dev/null +++ b/lib/ComplexBarcode/MaxiCodeStandartSecondMessage.php @@ -0,0 +1,90 @@ +setMaxiCodeSecondMessageDto($this->obtainDto()); + $this->initFieldsFromDto(); + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + static function _construct($dtoObj) + { + try + { + $obj = new MaxiCodeStandartSecondMessage(); + $obj->setMaxiCodeSecondMessageDto($dtoObj); + $obj->initFieldsFromDto(); + return $obj; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + public function obtainDto(...$args) + { + $thriftConnection = new ThriftConnection(); + $client = $thriftConnection->openConnection(); + $maxiCodeStandartSecondMessageDTO = $client->MaxiCodeStandartSecondMessage_ctor(); + $thriftConnection->closeConnection(); + return $maxiCodeStandartSecondMessageDTO; + } + + public function initFieldsFromDto() + { + } + + /** + * Sets second message + */ + public function setMessage(string $value) + { + $this->getMaxiCodeSecondMessageDto()->message = $value; + } + + /** + * Gets constructed second message + * @return string Constructed second message + */ + public function getMessage(): string + { + $thriftConnection = new ThriftConnection(); + $client = $thriftConnection->openConnection(); + $message = $client->MaxiCodeStandartSecondMessage_getMessage($this->getMaxiCodeSecondMessageDto()); + $thriftConnection->closeConnection(); + return $message; + } + + /** + * Returns a value indicating whether this instance is equal to a specified MaxiCodeStandartSecondMessage value. + * @param object obj An MaxiCodeStandartSecondMessage value to compare to this instance + * @return bool true if obj has the same value as this instance; otherwise, false. + */ + public function equals($obj): bool + { + $thriftConnection = new ThriftConnection(); + $client = $thriftConnection->openConnection(); + $isEqual = $client->MaxiCodeStandardCodetext_equals($this->getMaxiCodeSecondMessageDto(), $obj->getMaxiCodeSecondMessageDto()); + $thriftConnection->closeConnection(); + return $isEqual; + } +} \ No newline at end of file diff --git a/lib/ComplexBarcode/MaxiCodeStructuredCodetext.php b/lib/ComplexBarcode/MaxiCodeStructuredCodetext.php new file mode 100644 index 00000000..e24f089f --- /dev/null +++ b/lib/ComplexBarcode/MaxiCodeStructuredCodetext.php @@ -0,0 +1,142 @@ +readBarCodes() as $result) + * { + * $resultMaxiCodeCodetext = ComplexCodetextReader::tryDecodeMaxiCode($result->getExtended()->getMaxiCode()->getMaxiCodeMode(), $result->getCodeText()); + * if ($resultMaxiCodeCodetext instanceof MaxiCodeStructuredCodetext) + * { + * $maxiCodeStructuredCodetext = $resultMaxiCodeCodetext; + * print("BarCode Type: ".$maxiCodeStructuredCodetext->getPostalCode()); + * print("MaxiCode mode: ".$maxiCodeStructuredCodetext->getCountryCode()); + * print("BarCode CodeText: ".$maxiCodeStructuredCodetext->getServiceCategory()); + * } + * } + * @endcode + */ +abstract class MaxiCodeStructuredCodetext extends MaxiCodeCodetext +{ + private $secondMessage; + + public function initFieldsFromDto(): void + { + $maxiCodeSecondMessageDTO = $this->getIComplexCodetextDTO()->secondMessage; + if (!is_null($maxiCodeSecondMessageDTO)) + { + switch ($maxiCodeSecondMessageDTO->maxiCodeSecondMessageType) + { + case MaxiCodeSecondMessageType::MAXI_CODE_STANDART_SECOND_MESSAGE: + $this->secondMessage = MaxiCodeStandartSecondMessage::_construct($maxiCodeSecondMessageDTO); + break; + case MaxiCodeSecondMessageType::MAXI_CODE_STRUCTURED_SECOND_MESSAGE: + $this->secondMessage = MaxiCodeStructuredSecondMessage::_construct($maxiCodeSecondMessageDTO); + break; + default: + throw new Exception(); + } + } else + { + $this->secondMessage = null; + } + } + + /** + * Identifies the postal code. Must be 9 digits in mode 2 or + * 6 alphanumeric symbols in mode 3. + */ + public function getPostalCode(): string + { + return $this->getIComplexCodetextDTO()->postalCode; + } + + /** + * Identifies the postal code. Must be 9 digits in mode 2 or + * 6 alphanumeric symbols in mode 3. + */ + public function setPostalCode(string $value): void + { + $this->getIComplexCodetextDTO()->postalCode = $value; + } + + /** + * Identifies 3 digit country code. + */ + public function getCountryCode(): int + { + return $this->getIComplexCodetextDTO()->countryCode; + } + + /** + * Identifies 3 digit country code. + */ + public function setCountryCode(int $value): void + { + $this->getIComplexCodetextDTO()->countryCode = $value; + } + + /** + * Identifies 3 digit service category. + */ + public function getServiceCategory(): int + { + return $this->getIComplexCodetextDTO()->serviceCategory; + } + + /** + * Identifies 3 digit service category. + */ + public function setServiceCategory(int $value): void + { + $this->getIComplexCodetextDTO()->serviceCategory = $value; + } + + /** + * Identifies second message of the barcode. + */ + public function getSecondMessage(): MaxiCodeSecondMessage + { + return $this->secondMessage; + } + + /** + * Identifies second message of the barcode. + */ + public function setSecondMessage(MaxiCodeSecondMessage $value) + { + $this->secondMessage = $value; + $this->getIComplexCodetextDTO()->secondMessage = ($value->getMaxiCodeSecondMessageDto()); + } + + /** + * Constructs codetext + * @return string Constructed codetext + */ + public abstract function getConstructedCodetext(): string; + + /** + * Initializes instance from constructed codetext. + * @param string $constructedCodetext Constructed codetext. + */ + public abstract function initFromString(string $constructedCodetext): void; + + /** + * Returns a value indicating whether this instance is equal to a specified+ * Identifies date of labeler identification code. + * Labeler identification code must be 4 symbols alphanumeric string, with first character always being alphabetic. + *
+ */ + public function getLabelerIdentificationCode(): string + { + return $this->getPrimaryDataDto()->labelerIdentificationCode; + } + + /** + *+ * Identifies date of labeler identification code. + * Labeler identification code must be 4 symbols alphanumeric string, with first character always being alphabetic. + *
+ */ + public function setLabelerIdentificationCode(string $value): void + { + $this->getPrimaryDataDto()->labelerIdentificationCode = $value; + } + + /** + *+ * Identifies product or catalog number. Product or catalog number must be alphanumeric string up to 18 sybmols length. + *
+ */ + public function getProductOrCatalogNumber(): string + { + return $this->getPrimaryDataDto()->productOrCatalogNumber; + } + + /** + *+ * Identifies product or catalog number. Product or catalog number must be alphanumeric string up to 18 sybmols length. + *
+ */ + public function setProductOrCatalogNumber(string $value): void + { + $this->getPrimaryDataDto()->productOrCatalogNumber = $value; + } + + /** + *+ * Identifies unit of measure ID. Unit of measure ID must be integer value from 0 to 9. + *
+ */ + public function getUnitOfMeasureID(): int + { + return $this->getPrimaryDataDto()->unitOfMeasureID; + } + + /** + *+ * Identifies unit of measure ID. Unit of measure ID must be integer value from 0 to 9. + *
+ */ + public function setUnitOfMeasureID(int $value): void + { + $this->getPrimaryDataDto()->unitOfMeasureID = $value; + } + + /** + *+ * Converts data to string format according HIBC LIC specification. + *
+ * + * @return string Formatted string. + */ + public function toString(): string + { + $thriftConnection = new ThriftConnection(); + $client = $thriftConnection->openConnection(); + $str = $client->PrimaryData_toString($this->getPrimaryDataDto()); + $thriftConnection->closeConnection(); + + return $str; + } + + /** + *+ * Instantiates primary data from string format according HIBC LIC specification. + *
+ * + * @param primaryDataCodetext Formatted string. + */ + public function parseFromString(string $primaryDataCodetext): void + { + $thriftConnection = new ThriftConnection(); + $client = $thriftConnection->openConnection(); + $this->setPrimaryDataDto($client->PrimaryData_parseFromString($this->getPrimaryDataDto(), $primaryDataCodetext)); + $thriftConnection->closeConnection(); + $this->initFieldsFromDto(); + + } + + /** + *+ * Returns a value indicating whether this instance is equal to a specified {@code PrimaryData} value. + *
+ * + * @param obj An {@code PrimaryData} value to compare to this instance. + * @return {@code true} if obj has the same value as this instance; otherwise, {@code false}. + */ + public function equals(PrimaryData $obj): bool + { + $thriftConnection = new ThriftConnection(); + $client = $thriftConnection->openConnection(); + $isEqual = $client->PrimaryData_equals($this->getPrimaryDataDto(), $obj->getPrimaryDataDto()); + $thriftConnection->closeConnection(); + + return $isEqual; + } +} \ No newline at end of file diff --git a/lib/ComplexBarcode/QrBillStandardVersion.php b/lib/ComplexBarcode/QrBillStandardVersion.php new file mode 100644 index 00000000..8483c249 --- /dev/null +++ b/lib/ComplexBarcode/QrBillStandardVersion.php @@ -0,0 +1,25 @@ + \ No newline at end of file diff --git a/lib/ComplexBarcode/SecondaryAndAdditionalData.php b/lib/ComplexBarcode/SecondaryAndAdditionalData.php new file mode 100644 index 00000000..73da531e --- /dev/null +++ b/lib/ComplexBarcode/SecondaryAndAdditionalData.php @@ -0,0 +1,243 @@ + + * Class for storing HIBC LIC secondary and additional data. + * + */ +class SecondaryAndAdditionalData implements Communicator +{ + private $secondaryAndAdditionalDataDto; + + /** + * @return mixed + */ + public function getSecondaryAndAdditionalDataDto() + { + return $this->secondaryAndAdditionalDataDto; + } + + /** + * @param mixed $secondaryAndAdditionalDataDto + */ + public function setSecondaryAndAdditionalDataDto($secondaryAndAdditionalDataDto): void + { + $this->secondaryAndAdditionalDataDto = $secondaryAndAdditionalDataDto; + } + + function __construct() + { + $this->secondaryAndAdditionalDataDto = $this->obtainDto(); + $this->initFieldsFromDto(); + } + + static function construct($java_class): SecondaryAndAdditionalData + { + $obj = new SecondaryAndAdditionalData(); + $obj->setSecondaryAndAdditionalDataDto($java_class); + $obj->initFieldsFromDto(); + return $obj; + } + + public function obtainDto(...$args) + { + $thriftConnection = new ThriftConnection(); + $client = $thriftConnection->openConnection(); + $dtoRef = $client->SecondaryAndAdditionalData_ctor(); + $thriftConnection->closeConnection(); + + return $dtoRef; + } + + public function initFieldsFromDto() + { + } + + /** + *+ * Identifies expiry date format. + *
+ */ + public function getExpiryDateFormat(): int + { + return $this->getSecondaryAndAdditionalDataDto()->expiryDateFormat; + } + + /** + *+ * Identifies expiry date format. + *
+ */ + public function setExpiryDateFormat(int $value): void + { + $this->getSecondaryAndAdditionalDataDto()->expiryDateFormat = $value; + } + + /** + *+ * Identifies expiry date. Will be used if ExpiryDateFormat is not set to None. + *
+ */ + public function getExpiryDate(): DateTime + { + return new DateTime('@' . $this->getSecondaryAndAdditionalDataDto()->expiryDate); + } + + /** + *+ * Identifies expiry date. Will be used if ExpiryDateFormat is not set to None. + *
+ */ + public function setExpiryDate(DateTime $value): void + { + $this->getSecondaryAndAdditionalDataDto()->expiryDate = $value->getTimestamp() . ""; + } + + /** + *+ * Identifies lot or batch number. Lot/batch number must be alphanumeric string with up to 18 sybmols length. . + *
+ */ + public function getLotNumber(): string + { + return $this->getSecondaryAndAdditionalDataDto()->lotNumber; + } + + /** + *+ * Identifies lot or batch number. Lot/batch number must be alphanumeric string with up to 18 sybmols length. . + *
+ */ + public function setLotNumber(?string $value): void + { + if ($value == null) + $value = "null"; + $this->getSecondaryAndAdditionalDataDto()->lotNumber = $value; + } + + /** + *+ * Identifies serial number. Serial number must be alphanumeric string up to 18 sybmols length. + *
+ */ + public function getSerialNumber(): string + { + return $this->getSecondaryAndAdditionalDataDto()->serialNumber; + } + + /** + *+ * Identifies serial number. Serial number must be alphanumeric string up to 18 sybmols length. + *
+ */ + public function setSerialNumber(?string $value): void + { + if ($value == null) + $value = "null"; + $this->getSecondaryAndAdditionalDataDto()->serialNumber = $value; + } + + /** + *+ * Identifies date of manufacture. + * Date of manufacture can be set to DateTime.MinValue in order not to use this field. + * Default value: DateTime.MinValue + *
+ */ + public function getDateOfManufacture(): DateTime + { + return new DateTime('@' . $this->getSecondaryAndAdditionalDataDto()->dateOfManufacture); + } + + /** + *+ * Identifies date of manufacture. + * Date of manufacture can be set to DateTime.MinValue in order not to use this field. + * Default value: DateTime.MinValue + *
+ */ + public function setDateOfManufacture(DateTime $value): void + { + $this->getSecondaryAndAdditionalDataDto()->dateOfManufacture = ($value->getTimestamp() . ""); + } + + /** + *+ * Identifies quantity, must be integer value from 0 to 500. + * Quantity can be set to -1 in order not to use this field. + * Default value: -1 + *
+ */ + public function getQuantity(): int + { + return $this->getSecondaryAndAdditionalDataDto()->quantity; + } + + /** + *+ * Identifies quantity, must be integer value from 0 to 500. + * Quantity can be set to -1 in order not to use this field. + * Default value: -1 + *
+ */ + public function setQuantity(int $value): void + { + $this->getSecondaryAndAdditionalDataDto()->quantity = $value; + } + + /** + *+ * Converts data to string format according HIBC LIC specification. + *
+ * + * @return string Formatted string. + */ + public function toString(): string + { + $thriftConnection = new ThriftConnection(); + $client = $thriftConnection->openConnection(); + $str = $client->SecondaryAndAdditionalData_toString($this->getSecondaryAndAdditionalDataDto()); + $thriftConnection->closeConnection(); + return $str; + } + + /** + *+ * Instantiates secondary and additional supplemental data from string format according HIBC LIC specification. + *
+ * + * @param string secondaryDataCodetext Formatted string. + */ + public function parseFromString(string $secondaryDataCodetext): void + { + $thriftConnection = new ThriftConnection(); + $client = $thriftConnection->openConnection(); + $secondaryAndAdditionalDataDTO = $client->SecondaryAndAdditionalData_parseFromString($this->getSecondaryAndAdditionalDataDto(), $secondaryDataCodetext); + $thriftConnection->closeConnection(); + $this->setSecondaryAndAdditionalDataDto($secondaryAndAdditionalDataDTO); + $this->initFieldsFromDto(); + } + + /** + *+ * Returns a value indicating whether this instance is equal to a specified {@code SecondaryAndAdditionalData} value. + *
+ * + * @param SecondaryAndAdditionalData obj An {@code SecondaryAndAdditionalData} value to compare to this instance. + * @return bool true if obj has the same value as this instance; otherwise, false. + */ + public function equals(SecondaryAndAdditionalData $obj): bool + { + $thriftConnection = new ThriftConnection(); + $client = $thriftConnection->openConnection(); + $isEqual = $client->SecondaryAndAdditionalData_equals($this->getSecondaryAndAdditionalDataDto(), $obj->getSecondaryAndAdditionalDataDto()); + $thriftConnection->closeConnection(); + return $isEqual; + } +} \ No newline at end of file diff --git a/lib/ComplexBarcode/SwissQRBill.php b/lib/ComplexBarcode/SwissQRBill.php new file mode 100644 index 00000000..f21e66f1 --- /dev/null +++ b/lib/ComplexBarcode/SwissQRBill.php @@ -0,0 +1,495 @@ +swissQRBillDto; + } + + /** + * @param mixed $swissQRBillDto + */ + public function setSwissQRBillDto(\Aspose\Barcode\Bridge\SwissQRBillDTO $swissQRBillDto): void + { + $this->swissQRBillDto = $swissQRBillDto; + } + + + private $creditor; + private $debtor; + + + public function obtainDto(...$args) + { + } + + public function initFieldsFromDto() + { + try + { + $this->creditor = Address::construct($this->getSwissQRBillDto()->creditor); + $this->debtor = Address::construct($this->getSwissQRBillDto()->debtor); + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + public function __construct(\Aspose\Barcode\Bridge\SwissQRBillDTO $swissQRBillDto) + { + try + { + $this->swissQRBillDto = $swissQRBillDto; + $this->initFieldsFromDto(); + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + private static function convertAlternativeSchemes($javaAlternativeSchemes) + { + try + { + $alternativeSchemes = array(); + for ($i = 0; $i < $javaAlternativeSchemes->size(); $i++) + { + $alternativeSchemes[$i] = AlternativeScheme::construct($javaAlternativeSchemes->get($i)); + } + return $alternativeSchemes; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Gets the version of the SwissQR bill standard. + * Value: The SwissQR bill standard version. + */ + public function getVersion(): int + { + try + { + return $this->getSwissQRBillDto()->version; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Sets the version of the SwissQR bill standard. + * Value: The SwissQR bill standard version. + */ + public function setVersion(int $value): void + { + try + { + $this->getSwissQRBillDto()->version = $value; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Gets the payment amount. + * + * Valid values are between 0.01 and 999,999,999.99. + * + * Value: The payment amount. + */ + public function getAmount(): float + { + try + { + return $this->getSwissQRBillDto()->amount; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Sets the payment amount. + * + * Valid values are between 0.01 and 999,999,999.99. + * + * Value: The payment amount. + */ + public function setAmount(float $value): void + { + try + { + $this->getSwissQRBillDto()->amount = $value; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Gets the payment currency. + * + * Valid values are "CHF" and "EUR". + * + * Value: The payment currency. + */ + public function getCurrency(): string + { + try + { + return $this->getSwissQRBillDto()->currency; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Sets the payment currency. + * + * Valid values are "CHF" and "EUR". + * + * Value: The payment currency. + */ + public function setCurrency(string $value): void + { + try + { + $this->getSwissQRBillDto()->currency = $value; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Gets the creditor's account number. + * + * Account numbers must be valid IBANs of a bank of Switzerland or + * Liechtenstein. Spaces are allowed in the account number. + * + * Value: The creditor account number. + */ + public function getAccount(): ?string + { + try + { + return $this->getSwissQRBillDto()->account; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Sets the creditor's account number. + * + * Account numbers must be valid IBANs of a bank of Switzerland or + * Liechtenstein. Spaces are allowed in the account number. + * @param string $value Value: The creditor account number. + * @throws BarcodeException + */ + public function setAccount(string $value): void + { + try + { + $this->getSwissQRBillDto()->account = $value; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Gets the creditor address. + * @return Address The creditor address. + */ + public function getCreditor(): Address + { + return $this->creditor; + } + + /** + * Sets the creditor address. + * @param Address $value The creditor address. + * @throws BarcodeException + */ + public function setCreditor(Address $value): void + { + try + { + $this->creditor = $value; + $this->getSwissQRBillDto()->creditor = $value->getAddressDto(); + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Gets the creditor payment reference. + * + * The reference is mandatory for SwissQR IBANs, i.e.IBANs in the range + * CHxx30000xxxxxx through CHxx31999xxxxx. + * + * If specified, the reference must be either a valid SwissQR reference + * (corresponding to ISR reference form) or a valid creditor reference + * according to ISO 11649 ("RFxxxx"). Both may contain spaces for formatting. + * + * @return string The creditor payment reference. + */ + public function getReference(): string + { + try + { + return $this->getSwissQRBillDto()->reference; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Sets the creditor payment reference. + * + * The reference is mandatory for SwissQR IBANs, i.e.IBANs in the range + * CHxx30000xxxxxx through CHxx31999xxxxx. + * + * If specified, the reference must be either a valid SwissQR reference + * (corresponding to ISR reference form) or a valid creditor reference + * according to ISO 11649 ("RFxxxx"). Both may contain spaces for formatting. + * + * @param string $value The creditor payment reference. + */ + public function setReference(string $value): void + { + try + { + $this->getSwissQRBillDto()->reference = $value; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Creates and sets a ISO11649 creditor reference from a raw string by prefixing + * the String with "RF" and the modulo 97 checksum. + * + * Whitespace is removed from the reference + * + * @exception ArgumentException rawReference contains invalid characters. + * @param string $rawReference The raw reference. + */ + public function createAndSetCreditorReference(string $rawReference): void + { + try + { + $thriftConnection = new ThriftConnection(); + $client = $thriftConnection->openConnection(); + $this->setSwissQRBillDto($client->SwissQRBill_createAndSetCreditorReference($this->getSwissQRBillDto(), $rawReference)); + $thriftConnection->closeConnection(); + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Gets the debtor address. + * + * The debtor is optional. If it is omitted, both setting this field to + * null or setting an address with all null or empty values is ok. + * + * return Address The debtor address. + */ + public function getDebtor(): Address + { + return $this->debtor; + } + + /** + * Sets the debtor address. + * + * The debtor is optional. If it is omitted, both setting this field to + * null or setting an address with all null or empty values is ok. + * + * @param Address The debtor address. + */ + public function setDebtor(Address $value): void + { + try + { + $this->debtor = $value; + $this->getSwissQRBillDto()->debtor = $value->getAddressDto(); + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Gets the additional unstructured message. + * @return string The unstructured message. + */ + public function getUnstructuredMessage(): string + { + try + { + return $this->getSwissQRBillDto()->UnstructuredMessage; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Sets the additional unstructured message. + * @param string $value The unstructured message. + */ + public function setUnstructuredMessage(string $value): void + { + try + { + $this->getSwissQRBillDto()->UnstructuredMessage = $value; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Gets the additional structured bill information. + * @return string The structured bill information. + */ + public function getBillInformation(): string + { + try + { + return $this->getSwissQRBillDto()->billInformation; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Sets the additional structured bill information. + * @param string The structured bill information. + */ + public function setBillInformation(string $value): void + { + try + { + $this->getSwissQRBillDto()->billInformation = $value; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Gets ors sets the alternative payment schemes. + * + * A maximum of two schemes with parameters are allowed. + * + * @return array The alternative payment schemes. + */ + public function getAlternativeSchemes(): array + { + try + { + return self::convertAlternativeSchemes($this->getSwissQRBillDto()->alternativeSchemes); + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Gets ors sets the alternative payment schemes. + * + * A maximum of two schemes with parameters are allowed. + * + * @param AlternativeScheme[] $alternativeSchemes + */ + public function setAlternativeSchemes(array $alternativeSchemes): void + { + try + { + $dto = $this->getSwissQRBillDto(); + + if (!is_array($dto->alternativeSchemes)) + { + $dto->alternativeSchemes = []; + } + + foreach ($alternativeSchemes as $value) + { + $dto->alternativeSchemes[] = $value->getAlternativeSchemeDto(); + } + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + + /** + * Determines whether the specified object is equal to the current object. + * @param SwissQRBill $obj The object to compare with the current object. + * @return bool true if the specified object is equal to the current object; otherwise, false. + */ + public function equals(SwissQRBill $obj): bool + { + $thriftConnection = new ThriftConnection(); + $client = $thriftConnection->openConnection(); + $isEquals = $client->SwissQRBill_equals($this->getSwissQRBillDto(), $obj->getSwissQRBillDto()); + $thriftConnection->closeConnection(); + + return $isEquals; + } +} \ No newline at end of file diff --git a/lib/ComplexBarcode/SwissQRCodetext.php b/lib/ComplexBarcode/SwissQRCodetext.php new file mode 100644 index 00000000..78e2921f --- /dev/null +++ b/lib/ComplexBarcode/SwissQRCodetext.php @@ -0,0 +1,146 @@ +setIComplexCodetextDTO($this->obtainDto($bill)); + $this->initFieldsFromDto(); + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + static function construct($dtoRef) + { + try + { + $class = new SwissQRCodetext(null); + $class->setIComplexCodetextDTO($dtoRef); + $class->initFieldsFromDto(); + return $class; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + public function obtainDto(...$args) + { + $thriftConnection = new ThriftConnection(); + $client = $thriftConnection->openConnection(); + $dtoRef = null; + if (is_null($args[0])) + $dtoRef = $client->SwissQRCodetext_ctor(); + else + $dtoRef = $client->SwissQRCodetext_ctorSwissQRBill($args[0]->getSwissQRBillDto()); + $dtoRef->complexCodetextType = ComplexCodetextType::SwissQRCodetext; + $thriftConnection->closeConnection(); + + return $dtoRef; + } + + public function initFieldsFromDto() + { + try + { + $this->bill = new SwissQRBill($this->getIComplexCodetextDTO()->bill); + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * SwissQR bill data + */ + public function getBill(): SwissQRBill + { + return $this->bill; + } + + /** + * Construct codetext from SwissQR bill data + * + * @return string Constructed codetext + */ + public function getConstructedCodetext(): string + { + try + { + $thriftConnection = new ThriftConnection(); + $client = $thriftConnection->openConnection(); + $constructedCodetext = $client->SwissQRCodetext_getConstructedCodetext($this->getIComplexCodetextDTO()); + $thriftConnection->closeConnection(); + return $constructedCodetext; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Initializes Bill with constructed codetext. + * + * @param string $constructedCodetext Constructed codetext. + */ + public function initFromString($constructedCodetext): void + { + try + { + $thriftConnection = new ThriftConnection(); + $client = $thriftConnection->openConnection(); + $this->setIComplexCodetextDTO($client->SwissQRCodetext_initFromString($this->getIComplexCodetextDTO(), $constructedCodetext)); + $this->initFieldsFromDto(); + $thriftConnection->closeConnection(); + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Gets barcode type. + * + * @return int Barcode type. + */ + public function getBarcodeType(): int + { + try + { + return $this->getIComplexCodetextDTO()->barcodeType; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } +} \ No newline at end of file diff --git a/lib/Generation.php b/lib/Generation.php deleted file mode 100644 index 25fe0eb4..00000000 --- a/lib/Generation.php +++ /dev/null @@ -1,12225 +0,0 @@ -setCodeText("123ABC"); - * @endcode - */ -class BarcodeGenerator implements Communicator -{ - private $barcodeGeneratorDto; - - private function getBarcodeGeneratorDto(): BarcodeGeneratorDTO - { - return $this->barcodeGeneratorDto; - } - - private function setBarcodeGeneratorDto(BarcodeGeneratorDTO $barcodeGeneratorDto): void - { - $this->barcodeGeneratorDto = $barcodeGeneratorDto; - } - - private $parameters; - - /** - * BarcodeGenerator constructor. - * @param int|null $encodeType Barcode symbology type. Use EncodeTypes class to setup a symbology - * @param string|null $codeText Text to be encoded. Should be encoded in UTF-8 encoding - * @code - * $barcodeGenerator = new BarcodeGenerator(EncodeTypes::EAN_14, "332211"); - * @endcode - * @throws BarcodeException - */ - public function __construct(?int $encodeType, ?string $codeText = null) - { - try { - $this->barcodeGeneratorDto = $this->obtainDto($encodeType); - $this->getBarcodeGeneratorDto()->barcodeType = $encodeType; - $this->getBarcodeGeneratorDto()->base64CodeText = $codeText; - $this->initFieldsFromDto(); - } catch (Exception $ex) { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - public function obtainDto(...$args) : BarcodeGeneratorDTO - { - $thriftConnection = new ThriftConnection(); - $client = $thriftConnection->openConnection(); - $dtoRef = $client->BarcodeGenerator_ctor($args[0]); - $thriftConnection->closeConnection(); - - return $dtoRef; - } - - public function initFieldsFromDto(): void - { - $this->parameters = new BaseGenerationParameters($this->getBarcodeGeneratorDto()->parameters); - } - - /** - * Generation parameters. - * @return BaseGenerationParameters - */ - public function getParameters(): BaseGenerationParameters - { - return $this->parameters; - } - - /** - * Barcode symbology type. - */ - public function getBarcodeType(): int - { - try { - return $this->getBarcodeGeneratorDto()->barcodeType; - } catch (Exception $ex) { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - /** - * Barcode symbology type. - */ - public function setBarcodeType(int $value): void - { - try { - $this->getBarcodeGeneratorDto()->barcodeType = $value; - } catch (Exception $ex) { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - /** - * Generate the barcode image under current settings. - * This sample shows how to create and save a barcode image. - * - * @return resource|false GD image resource or false on failure. - * - * @code - * $generator = new BarCodeGenerator(EncodeTypes::CODE_128); - * $image = $generator->generateBarCodeGDImage(); - * @endcode - * - * @throws BarcodeException - */ - public function generateBarCodeGDImage() - { - try - { - if (!extension_loaded('gd')) - throw new BarcodeException("GD extension is not available!", __FILE__, __LINE__); - $base64Image = $this->generateBarCodeImage(BarCodeImageFormat::PNG); - return imagecreatefromstring(base64_decode($base64Image)); - } - catch (Exception $ex) - { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - /** - * Generate the barcode image under current settings. - * This sample shows how to create and save a barcode image. - * - * @param int $format value of BarCodeImageFormat (PNG, BMP, JPEG, GIF, EMF) - * @return string base64 representation of image. - * - * @code - * $generator = new BarCodeGenerator(EncodeTypes::CODE_128); - * $image = $generator->generateBarCodeImage(BarCodeImageFormat::PNG); - * @endcode - * - * @throws BarcodeException - */ - public function generateBarCodeImage(int $format, bool $passLicense = false): string - { - try { - $thriftConnection = new ThriftConnection(); - $client = $thriftConnection->openConnection(); - // Deciding if the license should be used - $licenseContent = $passLicense ? License::getLicenseContent() : null; - // Passing the license or null - $base64Image = $client->BarcodeGenerator_generateBarCodeImage($this->getBarcodeGeneratorDto(), $format, $licenseContent); - $thriftConnection->closeConnection(); - return $base64Image; - }catch (BarcodeExceptionDTO $be) { - $msg = $be->message ?? '(no message)'; - $pos = $be->position ?? ''; - $kind = $be->kind ?? ''; - // pass a clear message up so it gets into your report - throw new \Exception("Java error" . - ($kind !== null ? " [$kind]" : "") . - ": $msg\n$pos"); - } - - catch (Exception $exc) { - throw new BarcodeException($exc->getMessage(), __FILE__, __LINE__); - } - } - - /** - * Save barcode image to specific file in specific format. - * @param string $filePath Path to save to. - * @param int $format value of BarCodeImageFormat (PNG, BMP, JPEG, GIF, EMF) - * - * @code - * $generator = new BarCodeGenerator(EncodeTypes::CODE_128); - * $generator->save(file_path, BarCodeImageFormat::PNG); - * @endcode - * @throws BarcodeException - */ - public function save(string $filePath, int $format): void - { - try - { - $image = $this->generateBarCodeImage($format); - file_put_contents($filePath, base64_decode($image)); - } - catch (Exception $ex) - { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - /** - * Text to be encoded. - */ - public function getCodeText(): string - { - try { - return $this->getBarcodeGeneratorDto()->base64CodeText; - } catch (Exception $ex) { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - /** - *- *
- * Encodes the Unicode {@code codeText} into a byte sequence using the specified {@code encoding}. - * UTF-8 is the most commonly used encoding. - * If the encoding supports it and {@code insertBOM} is set to {@code true}, the function includes a - * {@code byte order mark (BOM)}. - *
- *- * This function is intended for use with 2D barcodes only (e.g., Aztec, QR, DataMatrix, PDF417, MaxiCode, DotCode, HanXin, RectMicroQR, etc.). - * It enables manual encoding of Unicode text using national or special encodings; however, this method is considered obsolete in modern applications. - * For modern use cases, {@code ECI} encoding is recommended for Unicode data. - *
- *- * Using this function with 1D barcodes, GS1-compliant barcodes (including 2D), or HIBC barcodes (including 2D) is not supported by the corresponding barcode standards and may lead to unpredictable results. - *
- *- * @param codeText CodeText string - * @param encoding Applied encoding - * @param insertBOM - * Indicates whether to insert a byte order mark (BOM) when the specified encoding supports it (e.g., UTF-8, UTF-16, UTF-32). - * If set to {@code true}, the BOM is added; if {@code false}, the BOM is omitted even if the encoding normally uses one. - * - */ - public function setCodeText($codeText, ?string $encoding = null, ?bool $insertBOM = false): void - { - try - { - if(is_array($codeText)) - { - $this->getBarcodeGeneratorDto()->base64CodeText = (base64_encode(pack("C*", ...$codeText))); - $this->getBarcodeGeneratorDto()->codeTextType = Base64CodeTextType::BYTE; - } - else - { - $this->getBarcodeGeneratorDto()->base64CodeText = $codeText; - $this->getBarcodeGeneratorDto()->codeTextType = Base64CodeTextType::STRING; - if(!is_null($encoding) && strlen($encoding) > 0) - $this->getBarcodeGeneratorDto()->encoding = $encoding; - $this->getBarcodeGeneratorDto()->insertBOM = $insertBOM; - } - } - catch (Exception $ex) - { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - /** - * Exports BarCode properties to the xml-file specified - * @param string $xmlFile The path to xml file - * @return bool Whether or not export completed successfully. - * Returns True in case of success; False Otherwise - */ - public function exportToXml(string $xmlFile): bool - { - try - { - $thriftConnection = new ThriftConnection(); - $client = $thriftConnection->openConnection(); - //TODO BARCODEPHP-677 Implement the passing of license file content from PHP to Java - $xmlData = $client->BarcodeGenerator_exportToXml($this->barcodeGeneratorDto); - $thriftConnection->closeConnection(); - $isContentExported = $xmlData != null; - if ($isContentExported) - { - file_put_contents($xmlFile, $xmlData); - } - return $isContentExported; - } - catch (Exception $ex) - { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - /** - * Import BarCode properties from xml file - * @param string $resource The name of the xml file or path to http resource - * @return BarCodeReader - * @throws BarcodeException - */ - public static function importFromXml($resource):BarcodeGenerator - { - try - { - if (CommonUtility::isPath($resource)) - { - $resource = fopen($resource, "r"); - } - $xmlData = (stream_get_contents($resource)); - $thriftConnection = new ThriftConnection(); - $client = $thriftConnection->openConnection(); - - $barCodeGeneratorDto = $client->BarcodeGenerator_importFromXml($xmlData); - $thriftConnection->closeConnection(); - - return BarcodeGenerator::construct($barCodeGeneratorDto); - } - catch (Exception $ex) - { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - private static function construct(BarcodeGeneratorDTO $barCodeGeneratorDto): BarcodeGenerator - { - $barCodeGenerator = new BarcodeGenerator(0, null); - $barCodeGenerator->setBarcodeGeneratorDto($barCodeGeneratorDto); - $barCodeGenerator->initFieldsFromDto(); - return $barCodeGenerator; - } -} - -class Base64CodeTextType -{ - const STRING =0; - const BYTE = 1; -} - - -/** - * Barcode image generation parameters. - */ -class BaseGenerationParameters implements Communicator -{ - private $baseGenerationParametersDto; - - private function getBaseGenerationParametersDto(): BaseGenerationParametersDTO - { - return $this->baseGenerationParametersDto; - } - - private function setBaseGenerationParametersDto(BaseGenerationParametersDTO $baseGenerationParametersDto): void - { - $this->baseGenerationParametersDto = $baseGenerationParametersDto; - } - - private $captionAbove; - private $captionBelow; - private $barcodeParameters; - private $borderParameters; - private $image; - - private $imageWidth; - private $imageHeight; - - function __construct(BaseGenerationParametersDTO $baseGenerationParametersDto) - { - $this->baseGenerationParametersDto = $baseGenerationParametersDto; - $this->obtainDto(); - $this->initFieldsFromDto(); - } - - public function obtainDto(...$args) - { - } - - public function initFieldsFromDto(): void - { - try - { - $this->captionAbove = new CaptionParameters($this->getBaseGenerationParametersDto()->captionAbove); - $this->captionBelow = new CaptionParameters($this->getBaseGenerationParametersDto()->captionBelow); - $this->barcodeParameters = new BarcodeParameters($this->getBaseGenerationParametersDto()->barcode); - $this->borderParameters = new BorderParameters($this->getBaseGenerationParametersDto()->border); - $this->imageWidth = new Unit($this->getBaseGenerationParametersDto()->imageWidth); - $this->imageHeight = new Unit($this->getBaseGenerationParametersDto()->imageHeight); - $this->image = new ImageParameters($this->getBaseGenerationParametersDto()->image); - } - catch (Exception $ex) - { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - /** - *- *This example shows how to use {@code SetCodeText} with or without a BOM for 2D barcodes.
- *- * //Encode codetext using UTF-8 with BOM - * $gen = new BarcodeGenerator(EncodeTypes::QR, null); - * $gen->setCodeText("車種名", "UTF-8", true); - * $gen->save("barcode.png", BarCodeImageFormat::PNG); - * - * $reader = new BarCodeReader("barcode.png", null, DecodeType::QR); - * $results = $reader->readBarCodes(); - * for($i = 0; $i < sizeof($results); $i++) - * { - * $result = $results[$i]; - * echo ("BarCode CodeText: " . $result->getCodeText()); - * } - * //Encode codetext using UTF-8 without BOM - * $gen = new BarcodeGenerator(EncodeTypes::QR, null); - * $gen->setCodeText("車種名", "UTF-8", false); - * $gen->save("barcode.png", BarCodeImageFormat::PNG); - * $reader = new BarCodeReader("barcode.png", null, DecodeType.QR); - * $results = $reader->readBarCodes(); - * for($i = 0; $i < sizeof($results); $i++) - * { - * $result = $results[$i]; - * echo ("BarCode CodeText: " . $result->getCodeText()); - * } - *- *
- * Gets a value indicating whether is used anti-aliasing mode to render image - *
- */ - public function getUseAntiAlias() : bool - { - return $this->getBaseGenerationParametersDto()->useAntiAlias; - } - - /** - *- * Sets a value indicating whether is used anti-aliasing mode to render image - *
- */ - public function setUseAntiAlias(bool $value) : void - { - $this->getBaseGenerationParametersDto()->useAntiAlias = $value; - } - - /** - * Background color of the barcode image. - * Default value: #FFFFFF - * @return string value of background color. - */ - public function getBackColor(): string - { - try - { - $hexColor = strtoupper(dechex($this->getBaseGenerationParametersDto()->backColor)); - while (strlen($hexColor) < 6) - { - $hexColor = "0" . $hexColor; - } - $hexColor = "#" . $hexColor; - return $hexColor; - } - catch (Exception $ex) - { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - /** - * Background color of the barcode image. - * Default value: #FFFFFF - * @param string $hexValue value of background color. - * @throws BarcodeException - */ - public function setBackColor(string $hexValue): void - { - try - { - if($hexValue[0] == '#') - $hexValue = substr($hexValue, 1, strlen($hexValue) - 1); - $this->getBaseGenerationParametersDto()->backColor = hexdec($hexValue); - } - catch (Exception $ex) - { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - /** - * Gets the resolution of the BarCode image. - * One value for both dimensions. - * Default value: 96 dpi. - * @return float The Resolution parameter value is less than or equal to 0. - * @throws BarcodeException - */ - public function getResolution(): float - { - try - { - return $this->getBaseGenerationParametersDto()->resolution; - } - catch (Exception $ex) - { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - /** - * Sets the resolution of the BarCode image. - * One value for both dimensions. - * Default value: 96 dpi. - * @param float $value The Resolution parameter value is less than or equal to 0. - * @throws BarcodeException - */ - public function setResolution(float $value): void - { - try - { - $this->updateResolution($value); - } - catch (Exception $ex) - { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - private function updateResolution(float $newResolution) - { - $this->getBaseGenerationParametersDto()->resolution =$newResolution; - - $thriftConnection = new ThriftConnection(); - $client = $thriftConnection->openConnection(); - $resolutionUpdatedParametersDto = $client->BaseGenerationParameters_updateResolution($this->getBaseGenerationParametersDto(), $newResolution); - $thriftConnection->closeConnection(); - - - $this->getBaseGenerationParametersDto()->captionAbove = $resolutionUpdatedParametersDto->captionAbove; - $this->getBaseGenerationParametersDto()->captionBelow = $resolutionUpdatedParametersDto->captionBelow; - $this->getBaseGenerationParametersDto()->barcode = $resolutionUpdatedParametersDto->barcode; - $this->getBaseGenerationParametersDto()->border = $resolutionUpdatedParametersDto->border; - $this->getBaseGenerationParametersDto()->imageWidth = $resolutionUpdatedParametersDto->imageWidth; - $this->getBaseGenerationParametersDto()->imageHeight = $resolutionUpdatedParametersDto->imageHeight; - $this->getBaseGenerationParametersDto()->image = $resolutionUpdatedParametersDto->image; - - $this->initFieldsFromDto(); - } - - /** - * Image parameters. See- * Code128 parameters. - *
- */ - public function getCode128() : Code128Parameters - { - return $this->code128; - } - - /** - * Codabar parameters. - */ - public function getCodabar(): CodabarParameters - { - try - { - return $this->codabar; - } - catch (Exception $ex) - { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - /** - * Coupon parameters. Used for UpcaGs1DatabarCoupon, UpcaGs1Code128Coupon. - */ - public function getCoupon(): CouponParameters - { - try - { - return $this->coupon; - } - catch (Exception $ex) - { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - /** - * HanXin parameters. - */ - public function getHanXin() : HanXinParameters - { - return $this->hanXin; - } -} - - - -/** - * Codetext parameters. - */ -class CodetextParameters implements Communicator -{ - private $codetextParametersDto; - - private function getCodetextParametersDto(): CodetextParametersDTO - { - return $this->codetextParametersDto; - } - - private function setCodetextParametersDto(CodetextParametersDTO $codetextParametersDto): void - { - $this->codetextParametersDto = $codetextParametersDto; - } - - private $font; - private $space; - - function __construct(CodetextParametersDTO $codetextParametersDto) - { - $this->codetextParametersDto = $codetextParametersDto; - $this->obtainDto(); - $this->initFieldsFromDto(); - } - - public function obtainDto(...$args) - { - } - - public function initFieldsFromDto(): void - { - try - { - $this->font = new FontUnit($this->getCodetextParametersDto()->font); - $this->space = new Unit($this->getCodetextParametersDto()->space); - } - catch (Exception $ex) - { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - /** - * Text that will be displayed instead of codetext in 2D barcodes. - * Used for: Aztec, Pdf417, DataMatrix, QR, MaxiCode, DotCode - */ - public function getTwoDDisplayText(): string - { - try - { - return $this->getCodetextParametersDto()->twoDDisplayText; - } - catch (Exception $ex) - { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - /** - * Text that will be displayed instead of codetext in 2D barcodes. - * Used for: Aztec, Pdf417, DataMatrix, QR, MaxiCode, DotCode - */ - public function setTwoDDisplayText(string $value): void - { - try - { - $this->getCodetextParametersDto()->twoDDisplayText = $value; - } - catch (Exception $ex) - { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - /** - * Specify FontMode. If FontMode is set to Auto, font size will be calculated automatically based on xDimension value. - * It is recommended to use FontMode::AUTO especially in AutoSizeMode.NEAREST or AutoSizeMode::INTERPOLATION. - * Default value: FontMode::AUTO. - */ - public function getFontMode(): int - { - try - { - return $this->getCodetextParametersDto()->fontMode; - } - catch (Exception $ex) - { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - /** - * Specify FontMode. If FontMode is set to Auto, font size will be calculated automatically based on xDimension value. - * It is recommended to use FontMode::AUTO especially in AutoSizeMode.NEAREST or AutoSizeMode::INTERPOLATION. - * Default value: FontMode::AUTO. - */ - public function setFontMode(int $value): void - { - try - { - $this->getCodetextParametersDto()->fontMode = $value; - } - catch (Exception $ex) - { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - /** - * Specify the displaying CodeText's font. - * Default value: Arial 5pt regular. - * Ignored if FontMode is set to FontMode::AUTO. - */ - public function getFont(): FontUnit - { - return $this->font; - } - - /** - * Specify the displaying CodeText's font. - * Default value: Arial 5pt regular. - * Ignored if FontMode is set to FontMode::AUTO. - */ - public function setFont(FontUnit $value): void - { - try - { - $this->getCodetextParametersDto()->font = $value->getFontUnitDto(); - $this->font = $value; - } - catch (Exception $ex) - { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - /** - * Space between the CodeText and the BarCode in Unit value. - * Default value: 2pt. - * Ignored for EAN8, EAN13, UPCE, UPCA, ISBN, ISMN, ISSN, UpcaGs1DatabarCoupon. - */ - public function getSpace(): Unit - { - try - { - return $this->space; - } - catch (Exception $ex) - { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - /** - * Space between the CodeText and the BarCode in Unit value. - * Default value: 2pt. - * Ignored for EAN8, EAN13, UPCE, UPCA, ISBN, ISMN, ISSN, UpcaGs1DatabarCoupon. - */ - public function setSpace(Unit $value): void - { - try - { - $this->getCodetextParametersDto()->space = $value->getUnitDto(); - $this->space = $value; - } - catch (Exception $ex) - { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - /** - * Gets the alignment of the code text. - * Default value: TextAlignment::CENTER. - */ - public function getAlignment(): int - { - try - { - return $this->getCodetextParametersDto()->alignment; - } - catch (Exception $ex) - { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - /** - * Sets the alignment of the code text. - * Default value: TextAlignment::CENTER. - */ - public function setAlignment(int $value): void - { - try - { - $this->getCodetextParametersDto()->alignment = $value; - } - catch (Exception $ex) - { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - /** - * Specify the displaying CodeText's Color. - * Default value BLACK. - */ - public function getColor(): string - { - try - { - $hexColor = strtoupper(dechex($this->getCodetextParametersDto()->color)); - while (strlen($hexColor) < 6) - { - $hexColor = "0" . $hexColor; - } - $hexColor = "#" . $hexColor; - return $hexColor; - } - catch (Exception $ex) - { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - /** - * Specify the displaying CodeText's Color. - * Default value BLACK. - */ - public function setColor(string $value): void - { - try - { - if(substr($value, 0, 1) == '#') - $value = substr($value, 1, strlen($value) - 1); - $this->getCodetextParametersDto()->color = hexdec($value); - } - catch (Exception $ex) - { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - /** - * Specify the displaying CodeText Location, set to CodeLocation::NONE to hide CodeText. - * Default value: CodeLocation::BELOW. - */ - public function getLocation(): int - { - try - { - return $this->getCodetextParametersDto()->location; - } - catch (Exception $ex) - { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - /** - * Specify the displaying CodeText Location, set to CodeLocation::NONE to hide CodeText. - * Default value: CodeLocation::BELOW. - */ - public function setLocation(int $value): void - { - try - { - $this->getCodetextParametersDto()->location = $value; - } - catch (Exception $ex) - { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - /** - * Specify word wraps (line breaks) within text. - * @return bool - */ - public function getNoWrap(): bool - { - try - { - return $this->getCodetextParametersDto()->noWrap; - } - catch (Exception $ex) - { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - /** - * Specify word wraps (line breaks) within text. - */ - public function setNoWrap(bool $value): void - { - try - { - $this->getCodetextParametersDto()->noWrap = $value; - } - catch (Exception $ex) - { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - /** - * Returns a human-readable string representation of this CodetextParameters. - * - * @return string A string that represents this CodetextParameters. - */ - public function toString(): string - { - $thriftConnection = new ThriftConnection(); - $client = $thriftConnection->openConnection(); - $str = $client->CodetextParameters_toString($this->getCodetextParametersDto()); - $thriftConnection->closeConnection(); - - return $str; - } -} - -/** - * - * Postal parameters. Used for Postnet, Planet. - */ -class PostalParameters implements Communicator -{ - private $postalParametersDto; - - private function getPostalParametersDto(): PostalParametersDTO - { - return $this->postalParametersDto; - } - - private function setPostalParametersDto(PostalParametersDTO $postalParametersDto): void - { - $this->postalParametersDto = $postalParametersDto; - } - - private $postalShortBarHeight; - - function __construct(PostalParametersDTO $postalParametersDto) - { - $this->postalParametersDto = $postalParametersDto; - $this->obtainDto(); - $this->initFieldsFromDto(); - } - - public function obtainDto(...$args) - { - } - - public function initFieldsFromDto(): void - { - try - { - $this->postalShortBarHeight = new Unit($this->getPostalParametersDto()->postalShortBarHeight); - } - catch (Exception $ex) - { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - /** - * Short bar's height of Postal barcodes. - */ - public function getPostalShortBarHeight(): Unit - { - try - { - return $this->postalShortBarHeight; - } - catch (Exception $ex) - { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - /** - * Short bar's height of Postal barcodes. - */ - public function setPostalShortBarHeight(Unit $value): void - { - try - { - $this->getPostalParametersDto()->postalShortBarHeight = $value->getUnitDto(); - $this->postalShortBarHeight = $value; - } - catch (Exception $ex) - { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - /** - * Returns a human-readable string representation of this PostalParameters. - * - * @return string A string that represents this PostalParameters. - */ - public function toString(): string - { - $thriftConnection = new ThriftConnection(); - $client = $thriftConnection->openConnection(); - $str = $client->PostalParameters_toString($this->getPostalParametersDto()); - $thriftConnection->closeConnection(); - - return $str; - } -} - -/** - * AustralianPost barcode parameters. - */ -class AustralianPostParameters implements Communicator -{ - private $australianPostParametersDto; - - private function getAustralianPostParametersDto(): AustralianPostParametersDTO - { - return $this->australianPostParametersDto; - } - - private function setAustralianPostParametersDto(AustralianPostParametersDTO $australianPostParametersDto): void - { - $this->australianPostParametersDto = $australianPostParametersDto; - } - - private $australianPostShortBarHeight; - - function __construct(AustralianPostParametersDTO $australianPostParametersDto) - { - $this->australianPostParametersDto = $australianPostParametersDto; - $this->obtainDto(); - $this->initFieldsFromDto(); - } - - public function obtainDto(...$args) - { - } - - public function initFieldsFromDto(): void - { - try - { - $this->australianPostShortBarHeight = new Unit($this->getAustralianPostParametersDto()->australianPostShortBarHeight); - } - catch (Exception $ex) - { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - /** - * Short bar's height of AustralianPost barcode. - */ - public function getAustralianPostShortBarHeight(): Unit - { - try - { - return $this->australianPostShortBarHeight; - } - catch (Exception $ex) - { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - /** - * Short bar's height of AustralianPost barcode. - */ - public function setAustralianPostShortBarHeight(Unit $value): void - { - try - { - $this->getAustralianPostParametersDto()->australianPostShortBarHeight = $value->getUnitDto(); - $this->australianPostShortBarHeight = $value; - } - catch (Exception $ex) - { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - /** - * Interpreting type for the Customer Information of AustralianPost, default to CustomerInformationInterpretingType.Other" - */ - public function getAustralianPostEncodingTable(): int - { - try - { - return $this->getAustralianPostParametersDto()->australianPostEncodingTable; - } - catch (Exception $ex) - { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - /** - * Interpreting type for the Customer Information of AustralianPost, default to CustomerInformationInterpretingType.Other" - */ - public function setAustralianPostEncodingTable(int $value): void - { - try - { - $this->getAustralianPostParametersDto()->australianPostEncodingTable = $value; - } - catch (Exception $ex) - { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - /** - * Returns a human-readable string representation of this AustralianPostParameters. - * - * @return string A string that represents this AustralianPostParameters. - */ - public function toString(): string - { - $thriftConnection = new ThriftConnection(); - $client = $thriftConnection->openConnection(); - $str = $client->AustralianPostParameters_toString($this->getAustralianPostParametersDto()); - $thriftConnection->closeConnection(); - - return $str; - } -} - -/** - * Codablock parameters. - */ -class CodablockParameters implements Communicator -{ - private $codablockParametersDto; - - private function getCodablockParametersDto(): CodablockParametersDTO - { - return $this->codablockParametersDto; - } - - private function setCodablockParametersDto(CodablockParametersDTO $codablockParametersDto): void - { - $this->codablockParametersDto = $codablockParametersDto; - } - - function __construct(CodablockParametersDTO $codablockParametersDto) - { - $this->codablockParametersDto = $codablockParametersDto; - $this->obtainDto(); - $this->initFieldsFromDto(); - } - - public function obtainDto(...$args) - { - } - - public function initFieldsFromDto(): void - { - } - - /** - * Columns count. - */ - public function getColumns(): int - { - try - { - return $this->getCodablockParametersDto()->columns; - } - catch (Exception $ex) - { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - /** - * Columns count. - */ - public function setColumns(int $value): void - { - try - { - $this->getCodablockParametersDto()->columns = $value; - } - catch (Exception $ex) - { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - /** - * Rows count. - */ - public function getRows(): int - { - try - { - return $this->getCodablockParametersDto()->rows; - } - catch (Exception $ex) - { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - /** - * Rows count. - */ - public function setRows(int $value): void - { - try - { - $this->getCodablockParametersDto()->rows = $value; - } - catch (Exception $ex) - { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - /** - * Height/Width ratio of 2D BarCode module. - */ - public function getAspectRatio(): float - { - try - { - return $this->getCodablockParametersDto()->aspectRatio; - } - catch (Exception $ex) - { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - /** - * Height/Width ratio of 2D BarCode module. - */ - public function setAspectRatio(float $value): void - { - try - { - $this->getCodablockParametersDto()->aspectRatio = $value; - } - catch (Exception $ex) - { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - /** - * Returns a human-readable string representation of this CodablockParameters. - * - * @return string that represents this CodablockParameters. - */ - public function toString(): string - { - $thriftConnection = new ThriftConnection(); - $client = $thriftConnection->openConnection(); - $str = $client->CodablockParameters_toString($this->getCodablockParametersDto()); - $thriftConnection->closeConnection(); - - return $str; - } -} - -/** - * Databar parameters. - */ -class DataBarParameters implements Communicator -{ - private $dataBarParametersDto; - - private function getDataBarParametersDto(): DataBarParametersDTO - { - return $this->dataBarParametersDto; - } - - private function setDataBarParametersDto(DataBarParametersDTO $dataBarParametersDto): void - { - $this->dataBarParametersDto = $dataBarParametersDto; - } - - function __construct(DataBarParametersDTO $dataBarParametersDto) - { - $this->dataBarParametersDto = $dataBarParametersDto; - $this->obtainDto(); - $this->initFieldsFromDto(); - } - - public function obtainDto(...$args) - { - } - - public function initFieldsFromDto(): void - { - } - - /** - * Enables flag of 2D composite component with DataBar barcode - */ - public function is2DCompositeComponent(): bool - { - try - { - return $this->getDataBarParametersDto()->is2DCompositeComponent; - } - catch (Exception $ex) - { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - /** - * Enables flag of 2D composite component with DataBar barcode - */ - public function set2DCompositeComponent(bool $value): void - { - try - { - $this->getDataBarParametersDto()->is2DCompositeComponent = $value; - } - catch (Exception $ex) - { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - /** - * If this flag is set, it allows only GS1 encoding standard for Databar barcode types - */ - public function isAllowOnlyGS1Encoding(): bool - { - try - { - return $this->getDataBarParametersDto()->isAllowOnlyGS1Encoding; - } - catch (Exception $ex) - { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - /** - * If this flag is set, it allows only GS1 encoding standard for Databar barcode types - */ - public function setAllowOnlyGS1Encoding(bool $value): void - { - try - { - $this->getDataBarParametersDto()->isAllowOnlyGS1Encoding = $value; - } - catch (Exception $ex) - { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - /** - * Columns count. - */ - public function getColumns(): int - { - try - { - return $this->getDataBarParametersDto()->columns; - } - catch (Exception $ex) - { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - /** - * Columns count. - */ - public function setColumns(int $value): void - { - try - { - $this->getDataBarParametersDto()->columns = $value; - } - catch (Exception $ex) - { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - /** - * Rows count. - */ - public function getRows(): int - { - try - { - return $this->getDataBarParametersDto()->rows; - } - catch (Exception $ex) - { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - /** - * Rows count. - */ - public function setRows(int $value): void - { - try - { - $this->getDataBarParametersDto()->rows = $value; - } - catch (Exception $ex) - { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - /** - * Height/Width ratio of 2D BarCode module. - * Used for DataBar stacked. - */ - public function getAspectRatio(): float - { - try - { - return $this->getDataBarParametersDto()->aspectRatio; - } - catch (Exception $ex) - { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - /** - * Height/Width ratio of 2D BarCode module. - * Used for DataBar stacked. - */ - public function setAspectRatio(float $value): void - { - try - { - $this->getDataBarParametersDto()->aspectRatio = $value; - } - catch (Exception $ex) - { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - /** - * Returns a human-readable string representation of this DataBarParameters. - * - * @return string that represents this DataBarParameters. - */ - public function toString(): string - { - $thriftConnection = new ThriftConnection(); - $client = $thriftConnection->openConnection(); - $str = $client->DataBarParameters_toString($this->getDataBarParametersDto()); - $thriftConnection->closeConnection(); - - return $str; - } -} - -/** - * DataMatrix parameters. - */ -class DataMatrixParameters implements Communicator -{ - private $dataMatrixParametersDto; - - private function getDataMatrixParametersDto(): DataMatrixParametersDTO - { - return $this->dataMatrixParametersDto; - } - - private function setDataMatrixParametersDto(DataMatrixParametersDTO $dataMatrixParametersDto): void - { - $this->dataMatrixParametersDto = $dataMatrixParametersDto; - } - - function __construct(DataMatrixParametersDTO $dataMatrixParametersDto) - { - $this->dataMatrixParametersDto = $dataMatrixParametersDto; - $this->obtainDto(); - $this->initFieldsFromDto(); - } - - public function obtainDto(...$args) - { - } - - public function initFieldsFromDto(): void - { - } - - /** - *- * Gets a Datamatrix symbol size. - * Default value: DataMatrixVersion.Auto. - *
- */ - public function getDataMatrixVersion() : int - { - return $this->getDataMatrixParametersDto()->dataMatrixVersion; - } - - /** - *- * Sets a Datamatrix symbol size. - * Default value: DataMatrixVersion.Auto. - *
- */ - public function setDataMatrixVersion(int $value) - { - $this->getDataMatrixParametersDto()->dataMatrixVersion = $value; - } - - /** - * Gets a Datamatrix ECC type. - * Default value: DataMatrixEccType::ECC_200. - */ - public function getDataMatrixEcc(): int - { - try - { - return $this->getDataMatrixParametersDto()->dataMatrixEcc; - } - catch (Exception $ex) - { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - /** - * Sets a Datamatrix ECC type. - * Default value: DataMatrixEccType::ECC_200. - */ - public function setDataMatrixEcc(int $value): void - { - try - { - $this->getDataMatrixParametersDto()->dataMatrixEcc = $value; - } - catch (Exception $ex) - { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - /** - * Encode mode of Datamatrix barcode. - * Default value: DataMatrixEncodeMode::AUTO. - */ - public function getDataMatrixEncodeMode(): int - { - try - { - return $this->getDataMatrixParametersDto()->dataMatrixEncodeMode; - } - catch (Exception $ex) - { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - /** - * Encode mode of Datamatrix barcode. - * Default value: DataMatrixEncodeMode::AUTO. - */ - public function setDataMatrixEncodeMode(int $value): void - { - try - { - $this->getDataMatrixParametersDto()->dataMatrixEncodeMode = $value; - } - catch (Exception $ex) - { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - /** - *- * Barcode ID for Structured Append mode of Datamatrix barcode. - * Default value: 0 - *
- */ - public function getStructuredAppendBarcodeId() : int - { - return $this->getDataMatrixParametersDto()->structuredAppendBarcodeId; - } - /** - *- * Barcode ID for Structured Append mode of Datamatrix barcode. - * Default value: 0 - *
- */ - public function setStructuredAppendBarcodeId(int $value) : void - { - $this->getDataMatrixParametersDto()->structuredAppendBarcodeId = $value; - } - - /** - *- * Barcodes count for Structured Append mode of Datamatrix barcode. - * Default value: 0 - *
- */ - public function getStructuredAppendBarcodesCount() : int - { - return $this->getDataMatrixParametersDto()->structuredAppendBarcodesCount; - } - /** - *- * Barcodes count for Structured Append mode of Datamatrix barcode. - * Default value: 0 - *
- */ - public function setStructuredAppendBarcodesCount(int $value) : void - { - $this->getDataMatrixParametersDto()->structuredAppendBarcodesCount = $value; - } - - /** - *- * File ID for Structured Append mode of Datamatrix barcode. - * Default value: 0 - *
- */ - public function getStructuredAppendFileId() : int - { - return $this->getDataMatrixParametersDto()->structuredAppendFileId; - } - /** - *- * File ID for Structured Append mode of Datamatrix barcode. - * Default value: 0 - *
- */ - public function setStructuredAppendFileId(int $value) : void - { - $this->getDataMatrixParametersDto()->structuredAppendFileId = $value; - } - - /** - *- * Used to instruct the reader to interpret the data contained within the symbol - * as programming for reader initialization. - * Default value: false - *
- */ - public function isReaderProgramming() : bool - { - return $this->getDataMatrixParametersDto()->isReaderProgramming; - } - /** - *- * Used to instruct the reader to interpret the data contained within the symbol - * as programming for reader initialization. - * Default value: false - *
- */ - public function setReaderProgramming(bool $value) : void - { - $this->getDataMatrixParametersDto()->isReaderProgramming = $value; - } - - /** - * ISO/IEC 16022 - * 5.2.4.7 Macro characters - * 11.3 Protocol for Macro characters in the first position (ECC 200 only) - * Macro Characters 05 and 06 values are used to obtain more compact encoding in special modes. - * Can be used only with DataMatrixEccType.Ecc200 or DataMatrixEccType.EccAuto. - * Cannot be used with EncodeTypes::GS_1_DATA_MATRIX - * Default value: MacroCharacter::NONE. - */ - public function getMacroCharacters(): int - { - try - { - return $this->getDataMatrixParametersDto()->macroCharacters; - } - catch (Exception $ex) - { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - /** - * ISO/IEC 16022 - * 5.2.4.7 Macro characters - * 11.3 Protocol for Macro characters in the first position (ECC 200 only) - * Macro Characters 05 and 06 values are used to obtain more compact encoding in special modes. - * Can be used only with DataMatrixEccType.Ecc200 or DataMatrixEccType.EccAuto. - * Cannot be used with EncodeTypes::GS_1_DATA_MATRIX - * Default value: MacroCharacter::NONE. - */ - public function setMacroCharacters(int $value): void - { - try - { - $this->getDataMatrixParametersDto()->macroCharacters = $value; - } - catch (Exception $ex) - { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - /** - * Columns count. - */ - public function getColumns(): int - { - try - { - return $this->getDataMatrixParametersDto()->columns; - } - catch (Exception $ex) - { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - /** - * Columns count. - */ - public function setColumns(int $value): void - { - try - { - $this->getDataMatrixParametersDto()->columns = $value; - } - catch (Exception $ex) - { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - /** - * Rows count. - */ - public function getRows(): int - { - try - { - return $this->getDataMatrixParametersDto()->rows; - } - catch (Exception $ex) - { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - /** - * Rows count. - */ - public function setRows(int $value): void - { - try - { - $this->getDataMatrixParametersDto()->rows = $value; - } - catch (Exception $ex) - { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - /** - * Height/Width ratio of 2D BarCode module. - */ - public function getAspectRatio(): float - { - try - { - return $this->getDataMatrixParametersDto()->aspectRatio; - } - catch (Exception $ex) - { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - /** - * Height/Width ratio of 2D BarCode module. - */ - public function setAspectRatio(float $value): void - { - try - { - $this->getDataMatrixParametersDto()->aspectRatio = $value; - } - catch (Exception $ex) - { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - /** - *- * Gets ECI encoding. Used when DataMatrixEncodeMode is Auto. - * Default value: ISO-8859-1 - *
- */ - public function getECIEncoding() : int - { - return $this->getDataMatrixParametersDto()->eCIEncoding; - } - /** - *- * Sets ECI encoding. Used when DataMatrixEncodeMode is Auto. - * Default value: ISO-8859-1 - *
- */ - public function setECIEncoding(int $value) : void - { - $this->getDataMatrixParametersDto()->eCIEncoding = $value; - } - - /** - * Returns a human-readable string representation of this DataMatrixParameters. - * - * @return string presentation of this DataMatrixParameters. - */ - public function toString(): string - { - $thriftConnection = new ThriftConnection(); - $client = $thriftConnection->openConnection(); - $str = $client->DataMatrixParameters_toString($this->getDataMatrixParametersDto()); - $thriftConnection->closeConnection(); - - return $str; - } - -} - -/** - * Code16K parameters. - */ -class Code16KParameters implements Communicator -{ - private $code16KParametersDto; - - private function getCode16KParametersDto(): Code16KParametersDTO - { - return $this->code16KParametersDto; - } - - private function setCode16KParametersDto(Code16KParametersDTO $code16KParametersDto): void - { - $this->code16KParametersDto = $code16KParametersDto; - } - - function __construct(Code16KParametersDTO $code16KParametersDto) - { - $this->code16KParametersDto = $code16KParametersDto; - $this->obtainDto(); - $this->initFieldsFromDto(); - } - - public function obtainDto(...$args) - { - } - - public function initFieldsFromDto(): void - { - } - - /** - * Height/Width ratio of 2D BarCode module. - */ - public function getAspectRatio(): float - { - try - { - return $this->getCode16KParametersDto()->aspectRatio; - } - catch (Exception $ex) - { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - /** - * Height/Width ratio of 2D BarCode module. - */ - public function setAspectRatio($value): void - { - try - { - $this->getCode16KParametersDto()->aspectRatio = $value; - } - catch (Exception $ex) - { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - /** - * Size of the left quiet zone in xDimension. - * Default value: 10, meaning if xDimension = 2px than left quiet zone will be 20px. - */ - public function getQuietZoneLeftCoef(): int - { - try - { - return $this->getCode16KParametersDto()->quietZoneLeftCoef; - } - catch (Exception $ex) - { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - /** - * Size of the left quiet zone in xDimension. - * Default value: 10, meaning if xDimension = 2px than left quiet zone will be 20px. - */ - public function setQuietZoneLeftCoef(int $value): void - { - try - { - $this->getCode16KParametersDto()->quietZoneLeftCoef = $value; - } - catch (Exception $ex) - { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - /** - * Size of the right quiet zone in xDimension. - * Default value: 1, meaning if xDimension = 2px than right quiet zone will be 2px. - */ - public function getQuietZoneRightCoef(): int - { - try - { - return $this->getCode16KParametersDto()->quietZoneRightCoef; - } - catch (Exception $ex) - { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - /** - * Size of the right quiet zone in xDimension. - * Default value: 1, meaning if xDimension = 2px than right quiet zone will be 2px. - */ - public function setQuietZoneRightCoef(int $value): void - { - try - { - $this->getCode16KParametersDto()->quietZoneRightCoef = $value; - } - catch (Exception $ex) - { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - /** - * Returns a human-readable string representation of this Code16KParameters. - * - * @return string A string that represents this Code16KParameters. - */ - public function toString(): string - { - $thriftConnection = new ThriftConnection(); - $client = $thriftConnection->openConnection(); - $str = $client->Code16KParameters_toString($this->getCode16KParametersDto()); - $thriftConnection->closeConnection(); - - return $str; - } -} - -/** - * DotCode parameters. - */ -class DotCodeParameters implements Communicator -{ - private $dotCodeParametersDto; - - private function getDotCodeParametersDto(): DotCodeParametersDTO - { - return $this->dotCodeParametersDto; - } - - private function setDotCodeParametersDto(DotCodeParametersDTO $dotCodeParametersDto): void - { - $this->dotCodeParametersDto = $dotCodeParametersDto; - } - - function __construct(DotCodeParametersDTO $dotCodeParametersDto) - { - $this->dotCodeParametersDto = $dotCodeParametersDto; - $this->obtainDto(); - $this->initFieldsFromDto(); - } - - public function obtainDto(...$args) - { - } - - public function initFieldsFromDto(): void - { - } - - /** - *- * Identifies DotCode encode mode. - * Default value: Auto. - *
- */ - public function getDotCodeEncodeMode() : int - { - return $this->getDotCodeParametersDto()->dotCodeEncodeMode; - } - /** - *- * Identifies DotCode encode mode. - * Default value: Auto. - *
- */ - public function setDotCodeEncodeMode(int $value) : void - { - $this->getDotCodeParametersDto()->dotCodeEncodeMode = $value; - } - - /** - *- * Indicates whether code is used for instruct reader to interpret the following data as instructions for initialization or reprogramming of the bar code reader. - * Default value is false. - *
- */ - public function isReaderInitialization() : bool - { return $this->getDotCodeParametersDto()->isReaderInitialization; } - /** - *- * Indicates whether code is used for instruct reader to interpret the following data as instructions for initialization or reprogramming of the bar code reader. - * Default value is false. - *
- */ - public function setReaderInitialization(bool $value) : void - { $this->getDotCodeParametersDto()->isReaderInitialization = $value; } - - /** - *- * Identifies the ID of the DotCode structured append mode barcode. ID starts from 1 and must be less or equal to barcodes count. Default value is -1. - *
- */ - public function getDotCodeStructuredAppendModeBarcodeId() : int - { return $this->getDotCodeParametersDto()->dotCodeStructuredAppendModeBarcodeId; } - /** - *- * Identifies the ID of the DotCode structured append mode barcode. ID starts from 1 and must be less or equal to barcodes count. Default value is -1. - *
- */ - public function setDotCodeStructuredAppendModeBarcodeId(int $value) - { $this->getDotCodeParametersDto()->dotCodeStructuredAppendModeBarcodeId = $value; } - - /** - *- * Identifies DotCode structured append mode barcodes count. Default value is -1. Count must be a value from 1 to 35. - *
- */ - public function getDotCodeStructuredAppendModeBarcodesCount() : int - { return $this->getDotCodeParametersDto()->dotCodeStructuredAppendModeBarcodesCount; } - /** - *- * Identifies DotCode structured append mode barcodes count. Default value is -1. Count must be a value from 1 to 35. - *
- */ - public function setDotCodeStructuredAppendModeBarcodesCount(int $value) : void - { $this->getDotCodeParametersDto()->dotCodeStructuredAppendModeBarcodesCount = $value; } - - /** - *- * Identifies ECI encoding. Used when DotCodeEncodeMode is Auto. - * Default value: ISO-8859-1 - *
- */ - public function getECIEncoding() : int - { return $this->getDotCodeParametersDto()->eCIEncoding; } - /** - *- * Identifies ECI encoding. Used when DotCodeEncodeMode is Auto. - * Default value: ISO-8859-1 - *
- */ - public function setECIEncoding(int $value) : void - { $this->getDotCodeParametersDto()->eCIEncoding = $value; } - - /** - *- * Identifies rows count. Sum of the number of rows plus the number of columns of a DotCode symbol must be odd. Number of rows must be at least 5. - * Default value: -1 - *
- */ - public function getRows() : int - { return $this->getDotCodeParametersDto()->rows; } - /** - *- * Identifies rows count. Sum of the number of rows plus the number of columns of a DotCode symbol must be odd. Number of rows must be at least 5. - * Default value: -1 - *
- */ - public function setRows(int $value) : void - { - $this->getDotCodeParametersDto()->rows = $value; - } - - /** - *- * Identifies columns count. Sum of the number of rows plus the number of columns of a DotCode symbol must be odd. Number of columns must be at least 5. - * Default value: -1 - *
- */ - public function getColumns() : int - { - return $this->getDotCodeParametersDto()->columns; - } - /** - *- * Identifies columns count. Sum of the number of rows plus the number of columns of a DotCode symbol must be odd. Number of columns must be at least 5. - * Default value: -1 - *
- */ - public function setColumns(int $value) : void - { - $this->getDotCodeParametersDto()->columns = $value; - } - - /** - * Height/Width ratio of 2D BarCode module. - */ - public function getAspectRatio(): float - { - try - { - return $this->getDotCodeParametersDto()->aspectRatio; - } - catch (Exception $ex) - { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - /** - * Height/Width ratio of 2D BarCode module. - */ - public function setAspectRatio(float $value): void - { - try - { - $this->getDotCodeParametersDto()->aspectRatio = $value; - } - catch (Exception $ex) - { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - /** - * Returns a human-readable string representation of this DotCodeParameters. - * - * @return string that represents this DotCodeParameters. - */ - public function toString(): string - { - $thriftConnection = new ThriftConnection(); - $client = $thriftConnection->openConnection(); - $str = $client->DotCodeParameters_toString($this->getDotCodeParametersDto()); - $thriftConnection->closeConnection(); - - return $str; - } -} - -/** - * GS1 Composite bar parameters. - */ -class GS1CompositeBarParameters implements Communicator -{ - private $gs1CompositeBarParametersDto; - - function getGS1CompositeBarParametersDto(): GS1CompositeBarParametersDTO - { - return $this->gs1CompositeBarParametersDto; - } - - private function setGS1CompositeBarParametersDto(GS1CompositeBarParametersDTO $gs1CompositeBarParametersDto): void - { - $this->gs1CompositeBarParametersDto = $gs1CompositeBarParametersDto; - } - - function __construct(GS1CompositeBarParametersDTO $gs1CompositeBarParametersDto) - { - $this->gs1CompositeBarParametersDto = $gs1CompositeBarParametersDto; - $this->obtainDto(); - $this->initFieldsFromDto(); - } - - public function obtainDto(...$args) - { - } - - public function initFieldsFromDto(): void - { - } - - /** - * Linear component type: GS1Code128, UPCE, EAN8, UPCA, EAN13, DatabarStacked, DatabarStackedOmniDirectional, DatabarLimited, DatabarOmniDirectional, DatabarExpanded, DatabarExpandedStacked - */ - public function getLinearComponentType():int - { - return $this->getGS1CompositeBarParametersDto()->linearComponentType; - } - - /** - * Linear component type: GS1Code128, UPCE, EAN8, UPCA, EAN13, DatabarStacked, DatabarStackedOmniDirectional, DatabarLimited, DatabarOmniDirectional, DatabarExpanded, DatabarExpandedStacked - */ - public function setLinearComponentType(int $value): void - { - $this->getGS1CompositeBarParametersDto()->linearComponentType = $value; - } - - /** - * 2D component type - */ - public function getTwoDComponentType(): int - { - return $this->getGS1CompositeBarParametersDto()->twoDComponentType; - } - - /** - * 2D component type - */ - public function setTwoDComponentType(int $value) : void - { - $this->getGS1CompositeBarParametersDto()->twoDComponentType = $value; - } - - /** - *- * If this flag is set, it allows only GS1 encoding standard for GS1CompositeBar 2D Component - *
- */ - public function isAllowOnlyGS1Encoding() : bool - { - return $this->getGS1CompositeBarParametersDto()->isAllowOnlyGS1Encoding; - } - - /** - *- * If this flag is set, it allows only GS1 encoding standard for GS1CompositeBar 2D Component - *
- */ - public function setAllowOnlyGS1Encoding(bool $value) : void - { - $this->getGS1CompositeBarParametersDto()->isAllowOnlyGS1Encoding = $value; - } - - /** - * Returns a human-readable string representation of this- * Version of MicroQR Code. From version M1 to version M4. - * Default value is MicroQRVersion.Auto. - *
- */ - public function getMicroQRVersion() : int - { - return $this->getQrParametersDto()->microQRVersion; - } - /** - *- * Version of MicroQR Code. From version M1 to version M4. - * Default value is MicroQRVersion.Auto. - *
- */ - public function setMicroQRVersion(int $value) : void - { - $this->getQrParametersDto()->microQRVersion = $value; - } - - /** - *- * Version of RectMicroQR Code. From version R7x59 to version R17x139. - * Default value is RectMicroQRVersion.Auto. - *
- */ - public function getRectMicroQrVersion() : int - { - return $this->getQrParametersDto()->rectMicroQrVersion; - } - /** - *- * Version of RectMicroQR Code. From version R7x59 to version R17x139. - * Default value is RectMicroQRVersion.Auto. - *
- */ - public function setRectMicroQrVersion(int $value) : void - { - $this->getQrParametersDto()->rectMicroQrVersion = $value; - } - - /** - * Height/Width ratio of 2D BarCode module. - */ - public function getAspectRatio(): float - { - try - { - return $this->getQrParametersDto()->aspectRatio; - } - catch (Exception $ex) - { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - /** - * Height/Width ratio of 2D BarCode module. - */ - public function setAspectRatio(float $value): void - { - try - { - $this->getQrParametersDto()->aspectRatio = $value; - } - catch (Exception $ex) - { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - /** - * Returns a human-readable string representation of this QrParameters. - * - * @return string that represents this QrParameters. - */ - public function toString(): string - { - $thriftConnection = new ThriftConnection(); - $client = $thriftConnection->openConnection(); - $str = $client->QrParameters_toString($this->getQrParametersDto()); - $thriftConnection->closeConnection(); - - return $str; - } -} - -/** - * QR structured append parameters. - */ -class QrStructuredAppendParameters implements Communicator -{ - private $qrStructuredAppendParametersDto; - - function getQrStructuredAppendParametersDto(): QrStructuredAppendParametersDTO - { - return $this->qrStructuredAppendParametersDto; - } - - private function setQrStructuredAppendParametersDto(QrStructuredAppendParametersDTO $qrStructuredAppendParametersDto): void - { - $this->qrStructuredAppendParametersDto = $qrStructuredAppendParametersDto; - } - - function __construct(QrStructuredAppendParametersDTO $qrStructuredAppendParametersDto) - { - $this->qrStructuredAppendParametersDto = $qrStructuredAppendParametersDto; - $this->obtainDto(); - $this->initFieldsFromDto(); - } - - public function obtainDto(...$args) - { - } - - public function initFieldsFromDto(): void - { - } - - /** - * Gets the QR structured append mode parity data. - */ - public function getParityByte(): int - { - try - { - return $this->getQrStructuredAppendParametersDto()->parityByte; - } - catch (Exception $ex) - { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - /** - * Sets the QR structured append mode parity data. - */ - public function setParityByte(int $value) - { - try - { - $this->getQrStructuredAppendParametersDto()->parityByte = $value; - } - catch (Exception $ex) - { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - /** - * Gets the index of the QR structured append mode barcode. Index starts from 0. - */ - public function getSequenceIndicator(): int - { - try - { - return $this->getQrStructuredAppendParametersDto()->sequenceIndicator; - } - catch (Exception $ex) - { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - /** - * Sets the index of the QR structured append mode barcode. Index starts from 0. - */ - public function setSequenceIndicator(int $value) - { - try - { - $this->getQrStructuredAppendParametersDto()->sequenceIndicator = $value; - } - catch (Exception $ex) - { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - /** - * Gets the QR structured append mode barcodes quantity. Max value is 16. - */ - public function getTotalCount(): int - { - try - { - return $this->getQrStructuredAppendParametersDto()->totalCount; - } - catch (Exception $ex) - { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - /** - * Sets the QR structured append mode barcodes quantity. Max value is 16. - */ - public function setTotalCount(int $value) - { - try - { - $this->getQrStructuredAppendParametersDto()->totalCount = $value; - } - catch (Exception $ex) - { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } -} - - -/** - *- * PDF417 parameters. Contains PDF417, MacroPDF417, MicroPDF417 and GS1MicroPdf417 parameters. - * MacroPDF417 requires two fields: Pdf417MacroFileID and Pdf417MacroSegmentID. All other fields are optional. - * MicroPDF417 in Structured Append mode (same as MacroPDF417 mode) requires two fields: Pdf417MacroFileID and Pdf417MacroSegmentID. All other fields are optional. - *
- * These samples show how to encode UCC/EAN-128 non Linked modes in GS1MicroPdf417 - *- * - */ -class Pdf417Parameters implements Communicator -{ - private $pdf417ParametersDto; - - private function getPdf417ParametersDto(): Pdf417ParametersDTO - { - return $this->pdf417ParametersDto; - } - - private function setPdf417ParametersDto(Pdf417ParametersDTO $pdf417ParametersDto): void - { - $this->pdf417ParametersDto = $pdf417ParametersDto; - } - - function __construct(Pdf417ParametersDTO $pdf417ParametersDto) - { - $this->pdf417ParametersDto = $pdf417ParametersDto; - $this->obtainDto(); - $this->initFieldsFromDto(); - } - - public function obtainDto(...$args) - { - } - - public function initFieldsFromDto(): void - { - } - - /** - * Pdf417 symbology type of BarCode's compaction mode. - * Default value: Pdf417CompactionMode::AUTO. - * @deprecated This property is obsolete and will be removed in future releases. Instead, use the Pdf417EncodeMode property. - */ - public function getPdf417CompactionMode(): int - { - try - { - return $this->getPdf417ParametersDto()->pdf417CompactionMode; - } - catch (Exception $ex) - { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - /** - * Pdf417 symbology type of BarCode's compaction mode. - * Default value: Pdf417CompactionMode::AUTO. - * @deprecated This property is obsolete and will be removed in future releases. Instead, use the Pdf417EncodeMode property. - */ - public function setPdf417CompactionMode(int $value): void - { - try - { - $this->getPdf417ParametersDto()->pdf417CompactionMode = $value; - } - catch (Exception $ex) - { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - /** - * Identifies Pdf417 encode mode. - * Default value: Auto. - */ - public function getPdf417EncodeMode() : int - { - return $this->getPdf417ParametersDto()->pdf417EncodeMode; - } - - /** - * Identifies Pdf417 encode mode. - * Default value: Auto. - */ - public function setPdf417EncodeMode(int $value) : void - { - $this->getPdf417ParametersDto()->pdf417EncodeMode = $value; - } - - /** - * Gets Pdf417 symbology type of BarCode's error correction level - * ranging from level0 to level8, level0 means no error correction info, - * level8 means best error correction which means a larger picture. - */ - public function getPdf417ErrorLevel(): int - { - try - { - return $this->getPdf417ParametersDto()->pdf417ErrorLevel; - } - catch (Exception $ex) - { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - /** - * Sets Pdf417 symbology type of BarCode's error correction level - * ranging from level0 to level8, level0 means no error correction info, - * level8 means best error correction which means a larger picture. - */ - public function setPdf417ErrorLevel(int $value): void - { - try - { - $this->getPdf417ParametersDto()->pdf417ErrorLevel = $value; - } - catch (Exception $ex) - { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - /** - * Whether Pdf417 symbology type of BarCode is truncated (to reduce space). - */ - public function getPdf417Truncate(): bool - { - try - { - return $this->getPdf417ParametersDto()->pdf417Truncate; - } - catch (Exception $ex) - { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - /** - * Whether Pdf417 symbology type of BarCode is truncated (to reduce space). - */ - public function setPdf417Truncate(bool $value): void - { - try - { - $this->getPdf417ParametersDto()->pdf417Truncate = $value; - } - catch (Exception $ex) - { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - /** - * Columns count. - */ - public function getColumns(): int - { - try - { - return $this->getPdf417ParametersDto()->columns; - } - catch (Exception $ex) - { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - /** - * Columns count. - */ - public function setColumns(int $value): void - { - try - { - $this->getPdf417ParametersDto()->columns = $value; - } - catch (Exception $ex) - { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - /** - * Rows count. - */ - public function getRows(): int - { - try - { - return $this->getPdf417ParametersDto()->rows; - } - catch (Exception $ex) - { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - /** - * Rows count. - */ - public function setRows(int $value): void - { - try - { - $this->getPdf417ParametersDto()->rows = $value; - } - catch (Exception $ex) - { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - /** - * Height/Width ratio of 2D BarCode module. - */ - public function getAspectRatio(): float - { - try - { - return $this->getPdf417ParametersDto()->aspectRatio; - } - catch (Exception $ex) - { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - /** - * Height/Width ratio of 2D BarCode module. - */ - public function setAspectRatio(float $value): void - { - try - { - $this->getPdf417ParametersDto()->aspectRatio = $value; - } - catch (Exception $ex) - { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - /** - * Getsmacro Pdf417 barcode's file ID. - * Used for MacroPdf417. - */ - public function getPdf417MacroFileID(): int - { - try - { - return $this->getPdf417ParametersDto()->pdf417MacroFileID; - } - catch (Exception $ex) - { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - /** - * Sets macro Pdf417 barcode's file ID. - * Used for MacroPdf417. - */ - public function setPdf417MacroFileID(int $value): void - { - try - { - $this->getPdf417ParametersDto()->pdf417MacroFileID = $value; - } - catch (Exception $ex) - { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - /** - * Gets macro Pdf417 barcode's segment ID, which starts from 0, to MacroSegmentsCount - 1. - */ - public function getPdf417MacroSegmentID(): int - { - try - { - return $this->getPdf417ParametersDto()->pdf417MacroSegmentID; - } - catch (Exception $ex) - { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - /** - * Sets macro Pdf417 barcode's segment ID, which starts from 0, to MacroSegmentsCount - 1. - */ - public function setPdf417MacroSegmentID(int $value): void - { - try - { - $this->getPdf417ParametersDto()->pdf417MacroSegmentID = $value; - } - catch (Exception $ex) - { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - /** - * Gets macro Pdf417 barcode segments count. - */ - public function getPdf417MacroSegmentsCount(): int - { - try - { - return $this->getPdf417ParametersDto()->pdf417MacroSegmentsCount; - } - catch (Exception $ex) - { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - /** - * Sets macro Pdf417 barcode segments count. - */ - public function setPdf417MacroSegmentsCount(int $value): void - { - try - { - $this->getPdf417ParametersDto()->pdf417MacroSegmentsCount = $value; - } - catch (Exception $ex) - { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - /** - * Gets macro Pdf417 barcode file name. - * @return - */ - public function getPdf417MacroFileName(): string - { - try - { - return $this->getPdf417ParametersDto()->pdf417MacroFileName; - } - catch (Exception $ex) - { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - /** - * Sets macro Pdf417 barcode file name. - * @param string $value - */ - public function setPdf417MacroFileName(string $value) - { - try - { - $this->getPdf417ParametersDto()->pdf417MacroFileName = $value; - } - catch (Exception $ex) - { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - /** - * Gets macro Pdf417 barcode time stamp. - */ - public function getPdf417MacroTimeStamp(): DateTime - { - try - { - return new DateTime('@' . $this->getPdf417ParametersDto()->pdf417MacroTimeStamp); - } - catch (Exception $ex) - { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - /** - * Sets macro Pdf417 barcode time stamp. - */ - public function setPdf417MacroTimeStamp(DateTime $value) - { - try - { - $this->getPdf417ParametersDto()->pdf417MacroTimeStamp = $value->getTimestamp() . ""; - } - catch (Exception $ex) - { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - /** - * Gets macro Pdf417 barcode sender name. - */ - public function getPdf417MacroSender(): string - { - try - { - return $this->getPdf417ParametersDto()->pdf417MacroSender; - } - catch (Exception $ex) - { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - /** - * Sets macro Pdf417 barcode sender name. - */ - public function setPdf417MacroSender(string $value) - { - try - { - $this->getPdf417ParametersDto()->pdf417MacroSender = $value; - } - catch (Exception $ex) - { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - /** - * Gets macro Pdf417 barcode addressee name. - */ - public function getPdf417MacroAddressee(): string - { - try - { - return $this->getPdf417ParametersDto()->pdf417MacroAddressee; - } - catch (Exception $ex) - { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - /** - * Sets macro Pdf417 barcode addressee name. - */ - public function setPdf417MacroAddressee(string $value) - { - try - { - $this->getPdf417ParametersDto()->pdf417MacroAddressee = $value; - } - catch (Exception $ex) - { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - /** - * Gets macro Pdf417 file size. - * @return int file size field contains the size in bytes of the entire source file. - */ - public function getPdf417MacroFileSize(): int - { - try - { - return $this->getPdf417ParametersDto()->pdf417MacroFileSize; - } - catch (Exception $ex) - { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - /** - * Sets macro Pdf417 file size. - * @param int $value The file size field contains the size in bytes of the entire source file. - */ - public function setPdf417MacroFileSize(int $value) - { - try - { - $this->getPdf417ParametersDto()->pdf417MacroFileSize = $value; - } - catch (Exception $ex) - { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - /** - * Gets macro Pdf417 barcode checksum. - * @return int checksum field contains the value of the 16-bit (2 bytes) CRC checksum using the CCITT-16 polynomial. - */ - public function getPdf417MacroChecksum(): int - { - try - { - return $this->getPdf417ParametersDto()->pdf417MacroChecksum; - } - catch (Exception $ex) - { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - /** - * Sets macro Pdf417 barcode checksum. - * @param int $value The checksum field contains the value of the 16-bit (2 bytes) CRC checksum using the CCITT-16 polynomial. - */ - public function setPdf417MacroChecksum(int $value) - { - try - { - $this->getPdf417ParametersDto()->pdf417MacroChecksum = $value; - } - catch (Exception $ex) - { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - /** - * Extended Channel Interpretation Identifiers. It is used to tell the barcode reader details - * about the used references for encoding the data in the symbol. Not applied for Macro PDF417 text fields. - * Current implementation consists all well known charset encodings. - */ - public function getPdf417ECIEncoding(): int - { - try - { - return $this->getPdf417ParametersDto()->pdf417ECIEncoding; - } - catch (Exception $ex) - { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - /** - * Extended Channel Interpretation Identifiers. It is used to tell the barcode reader details - * about the used references for encoding the data in the symbol. Not applied for Macro PDF417 text fields. - * Current implementation consists all well known charset encodings. - */ - public function setPdf417ECIEncoding(int $value): void - { - try - { - $this->getPdf417ParametersDto()->pdf417ECIEncoding = $value; - } - catch (Exception $ex) - { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - /** - * Extended Channel Interpretation Identifiers. Applies for Macro PDF417 text fields. - */ - public function getPdf417MacroECIEncoding(): int - { - try - { - return $this->getPdf417ParametersDto()->pdf417MacroECIEncoding; - } - catch (Exception $ex) - { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - /** - * Extended Channel Interpretation Identifiers. Applies for Macro PDF417 text fields. - */ - public function setPdf417MacroECIEncoding(int $value) - { - try - { - $this->getPdf417ParametersDto()->pdf417MacroECIEncoding = $value; - } - catch (Exception $ex) - { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - /** - * Used to tell the encoder whether to add Macro PDF417 Terminator (codeword 922) to the segment. - * Applied only for Macro PDF417. - */ - public function getPdf417MacroTerminator(): int - { - try - { - return $this->getPdf417ParametersDto()->pdf417MacroTerminator; - } - catch (Exception $ex) - { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - /** - * Used to tell the encoder whether to add Macro PDF417 Terminator (codeword 922) to the segment. - * Applied only for Macro PDF417. - */ - public function setPdf417MacroTerminator(int $value) - { - try - { - $this->getPdf417ParametersDto()->pdf417MacroTerminator = $value; - } - catch (Exception $ex) - { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - /** - * Used to instruct the reader to interpret the data contained within the symbol - * as programming for reader initialization - * @return - */ - public function isReaderInitialization(): bool - { - try - { - return $this->getPdf417ParametersDto()->isReaderInitialization; - } - catch (Exception $ex) - { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - /** - * Used to instruct the reader to interpret the data contained within the symbol - * as programming for reader initialization - * @param bool $value - */ - public function setReaderInitialization(bool $value): void - { - try - { - $this->getPdf417ParametersDto()->isReaderInitialization = $value; - } - catch (Exception $ex) - { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - /** - *- * - * # Encodes GS1 UCC/EAN-128 non Linked mode 905 with AI 01 (GTIN) - * $generator = new BarcodeGenerator(EncodeTypes::GS_1_MICRO_PDF_417, "(01)12345678901231"); - * $reader = new BarCodeReader($generator->generateBarCodeImage(BarcodeImageFormat::PNG), null, DecodeType::GS_1_MICRO_PDF_417); - * foreach ($reader->readBarCodes() as $result) - * echo $result->getCodeText(); - * - * # Encodes GS1 UCC/EAN-128 non Linked modes 903, 904 with any AI - * $generator = new BarcodeGenerator(EncodeTypes::GS_1_MICRO_PDF_417, "(241)123456789012345(241)ABCD123456789012345"); - * $reader = new BarCodeReader($generator->generateBarCodeImage(BarcodeImageFormat::PNG), null, DecodeType::GS_1_MICRO_PDF_417); - * foreach ($reader->readBarCodes() as $result) - * echo $result->getCodeText(); - *- *
- * Macro Characters 05 and 06 values are used to obtain more compact encoding in special modes. - * Can be used only with MicroPdf417 and encodes 916 and 917 MicroPdf417 modes - * Default value: MacroCharacters.None. - *
- */ - public function getMacroCharacters() : int - { - return $this->getPdf417ParametersDto()->macroCharacters; - } - - /** - *- * These samples show how to encode Macro Characters in MicroPdf417 - *- * @code - * # Encodes MicroPdf417 with 05 Macro the string: "[)>\u001E05\u001Dabcde1234\u001E\u0004" - * $generator = new BarcodeGenerator(EncodeTypes::MICRO_PDF_417, "abcde1234"); - * $generator->getParameters()->getBarcode()->getPdf417()->setMacroCharacters(MacroCharacter::MACRO_05); - * $reader = new BarCodeReader($generator->generateBarCodeImage(BarcodeImageFormat::PNG), null, DecodeType::MICRO_PDF_417); - * foreach($reader->readBarCodes() as $result) - * echo $result->getCodeText(); - * @endcode - * - * @code - * # Encodes MicroPdf417 with 06 Macro the string: "[)>\u001E06\u001Dabcde1234\u001E\u0004" - * $generator = new BarcodeGenerator(EncodeTypes::MICRO_PDF_417, "abcde1234"); - * $generator->getParameters()->getBarcode()->getPdf417()->setMacroCharacters(MacroCharacter::MACRO_06); - * $reader = new BarCodeReader($generator->generateBarCodeImage(BarcodeImageFormat::PNG), null, DecodeType::MICRO_PDF_417); - * foreach($reader->readBarCodes() as $result) - * echo $result->getCodeText()); - * @endcode - *- *
- * Macro Characters 05 and 06 values are used to obtain more compact encoding in special modes. - * Can be used only with MicroPdf417 and encodes 916 and 917 MicroPdf417 modes - * Default value: MacroCharacters.None. - *
- */ - public function setMacroCharacters(int $value) : void - { - $this->getPdf417ParametersDto()->macroCharacters = $value; - } - - /** - *- * These samples show how to encode Macro Characters in MicroPdf417 - *- * @code - * # Encodes MicroPdf417 with 05 Macro the string: "[)>\u001E05\u001Dabcde1234\u001E\u0004" - * $generator = new BarcodeGenerator(EncodeTypes::MICRO_PDF_417, "abcde1234"); - * $generator->getParameters()->getBarcode()->getPdf417()->setMacroCharacters(MacroCharacter::MACRO_05); - * $reader = new BarCodeReader($generator->generateBarCodeImage(BarcodeImageFormat::PNG), null, DecodeType::MICRO_PDF_417); - * foreach($reader->readBarCodes() as $result) - * echo $result->getCodeText(); - * - * @endcode - * @code - * - * # Encodes MicroPdf417 with 06 Macro the string: "[)>\u001E06\u001Dabcde1234\u001E\u0004" - * $generator = new BarcodeGenerator(EncodeTypes::MICRO_PDF_417, "abcde1234"); - * $generator->getParameters()->getBarcode()->getPdf417()->setMacroCharacters(MacroCharacter::MACRO_06); - * $reader = new BarCodeReader($generator->generateBarCodeImage(BarcodeImageFormat::PNG), null, DecodeType::MICRO_PDF_417); - * foreach($reader->readBarCodes() as $result) - * echo $result->getCodeText(); - * @endcode - *- *
- * Defines linked modes with GS1MicroPdf417, MicroPdf417 and Pdf417 barcodes - * With GS1MicroPdf417 symbology encodes 906, 907, 912, 913, 914, 915 "Linked" UCC/EAN-128 modes - * With MicroPdf417 and Pdf417 symbologies encodes 918 linkage flag to associated linear component other than an EAN.UCC - *
- */ - public function isLinked() : bool - { - return $this->getPdf417ParametersDto()->isLinked; - } - /** - *- * These samples show how to encode "Linked" UCC/EAN-128 modes in GS1MicroPdf417 and Linkage Flag (918) in MicroPdf417 and Pdf417 barcodes - *- * @code - * # Encodes GS1 Linked mode 912 with date field AI 11 (Production date) and AI 10 (Lot number) - * $generator = new BarcodeGenerator(EncodeTypes::GS_1_MICRO_PDF_417, "(11)991231(10)ABCD"); - * $generator->getParameters()->getBarcode()->getPdf417()->setLinked(true); - * $reader = new BarCodeReader($generator->generateBarCodeImage(BarcodeImageFormat::PNG), null, DecodeType::GS_1_MICRO_PDF_417); - * foreach($reader->readBarCodes() as $result) - * echo $result->getCodeText() . " IsLinked:" . $result->getExtended()->getPdf417()->isLinked(); - * - * @endcode - * @code - * # Encodes GS1 Linked mode 912 with date field AI 13 (Packaging date) and AI 21 (Serial number) - * $generator = new BarcodeGenerator(EncodeTypes::GS_1_MICRO_PDF_417, "(13)991231(21)ABCD"); - * $generator->getParameters()->getBarcode()->getPdf417()->setLinked(true); - * $reader = new BarCodeReader($generator->generateBarCodeImage(BarcodeImageFormat::PNG), null, DecodeType::GS_1_MICRO_PDF_417); - * foreach($reader->readBarCodes() as $result) - * echo $result->getCodeText() . " IsLinked:" . $result->getExtended()->getPdf417()->isLinked(); - * - * @endcode - * @code - * # Encodes GS1 Linked mode 912 with date field AI 15 (Sell-by date) and AI 10 (Lot number) - * $generator = new BarcodeGenerator(EncodeTypes::GS_1_MICRO_PDF_417, "(15)991231(10)ABCD"); - * $generator->getParameters()->getBarcode()->getPdf417()->setLinked(true); - * $reader = new BarCodeReader($generator->generateBarCodeImage(BarcodeImageFormat::PNG), null, DecodeType::GS_1_MICRO_PDF_417); - * foreach($reader->readBarCodes() as $result) - * echo $result->getCodeText() . " IsLinked:" . $result->getExtended()->getPdf417()->isLinked(); - * - * @endcode - * @code - * # Encodes GS1 Linked mode 912 with date field AI 17 (Expiration date) and AI 21 (Serial number) - * $generator = new BarcodeGenerator(EncodeTypes::GS_1_MICRO_PDF_417, "(17)991231(21)ABCD"); - * $generator->getParameters()->getBarcode()->getPdf417()->setLinked(true); - * $reader = new BarCodeReader($generator->generateBarCodeImage(BarcodeImageFormat::PNG), null, DecodeType::GS_1_MICRO_PDF_417); - * foreach($reader->readBarCodes() as $result) - * echo $result->getCodeText() . " IsLinked:" . $result->getExtended()->getPdf417()->isLinked(); - * - * @endcode - * @code - * # Encodes GS1 Linked mode 914 with AI 10 (Lot number) - * $generator = new BarcodeGenerator(EncodeTypes::GS_1_MICRO_PDF_417, "(10)ABCD12345"); - * $generator->getParameters()->getBarcode()->getPdf417()->setLinked(true); - * $reader = new BarCodeReader($generator->generateBarCodeImage(BarcodeImageFormat::PNG), null, DecodeType::GS_1_MICRO_PDF_417); - * foreach($reader->readBarCodes() as $result) - * echo $result->getCodeText() . " IsLinked:" . $result->getExtended()->getPdf417()->isLinked(); - * - * @endcode - * @code - * # Encodes GS1 Linked mode 915 with AI 21 (Serial number) - * $generator = new BarcodeGenerator(EncodeTypes::GS_1_MICRO_PDF_417, "(21)ABCD12345"); - * $generator->getParameters()->getBarcode()->getPdf417()->setLinked(true); - * $reader = new BarCodeReader($generator->generateBarCodeImage(BarcodeImageFormat::PNG), null, DecodeType::GS_1_MICRO_PDF_417); - * foreach($reader->readBarCodes() as $result) - * echo $result->getCodeText() . " IsLinked:" . $result->getExtended()->getPdf417()->isLinked(); - * - * @endcode - * @code - * # Encodes GS1 Linked modes 906, 907 with any AI - * $generator = new BarcodeGenerator(EncodeTypes::GS_1_MICRO_PDF_417, "(240)123456789012345"); - * $generator->getParameters()->getBarcode()->getPdf417()->setLinked(true); - * $reader = new BarCodeReader($generator->generateBarCodeImage(BarcodeImageFormat::PNG), null, DecodeType::GS_1_MICRO_PDF_417); - * foreach($reader->readBarCodes() as $result) - * echo $result->getCodeText() . " IsLinked:" . $result->getExtended()->getPdf417()->isLinked(); - * - * @endcode - * @code - * # Encodes MicroPdf417 NON EAN.UCC Linked mode 918 - * $generator = new BarcodeGenerator(EncodeTypes::MICRO_PDF_417, "ABCDE123456789012345678"); - * $generator->getParameters()->getBarcode()->getPdf417()->setLinked(true); - * $reader = new BarCodeReader($generator->generateBarCodeImage(BarcodeImageFormat::PNG), null, DecodeType::MICRO_PDF_417); - * foreach($reader->readBarCodes() as $result) - * echo $result->getCodeText() . " IsLinked:" . $result->getExtended()->getPdf417()->isLinked(); - * - * @endcode - * @code - * # Encodes Pdf417 NON EAN.UCC Linked mode 918 - * $generator = new BarcodeGenerator(EncodeTypes::PDF_417, "ABCDE123456789012345678"); - * $generator->getParameters()->getBarcode()->getPdf417()->setLinked(true); - * $reader = new BarCodeReader($generator->generateBarCodeImage(BarcodeImageFormat::PNG), null, DecodeType::PDF_417); - * foreach($reader->readBarCodes() as $result) - * echo $result->getCodeText() . " IsLinked:" . $result->getExtended()->getPdf417()->isLinked(); - * - * @endcode - *- *
- * Defines linked modes with GS1MicroPdf417, MicroPdf417 and Pdf417 barcodes - * With GS1MicroPdf417 symbology encodes 906, 907, 912, 913, 914, 915 "Linked" UCC/EAN-128 modes - * With MicroPdf417 and Pdf417 symbologies encodes 918 linkage flag to associated linear component other than an EAN.UCC - *
- */ - public function setLinked(bool $value) : void - { - $this->getPdf417ParametersDto()->isLinked = $value; - } - - /** - *- * These samples show how to encode "Linked" UCC/EAN-128 modes in GS1MicroPdf417 and Linkage Flag (918) in MicroPdf417 and Pdf417 barcodes - *- * - * @code - * # Encodes GS1 Linked mode 912 with date field AI 11 (Production date) and AI 10 (Lot number) - * $generator = new BarcodeGenerator(EncodeTypes::GS_1_MICRO_PDF_417, "(11)991231(10)ABCD"); - * $generator->getParameters()->getBarcode()->getPdf417()->setLinked(true); - * $reader = new BarCodeReader($generator->generateBarCodeImage(BarcodeImageFormat::PNG), null, DecodeType::GS_1_MICRO_PDF_417); - * foreach($reader->readBarCodes() as $result) - * echo $result->getCodeText() . " IsLinked:" . $result->getExtended()->getPdf417()->isLinked(); - * # Encodes GS1 Linked mode 912 with date field AI 13 (Packaging date) and AI 21 (Serial number) - * @endcode - * @code - * $generator = new BarcodeGenerator(EncodeTypes::GS_1_MICRO_PDF_417, "(13)991231(21)ABCD"); - * $generator->getParameters()->getBarcode()->getPdf417()->setLinked(true); - * $reader = new BarCodeReader($generator->generateBarCodeImage(BarcodeImageFormat::PNG), null, DecodeType::GS_1_MICRO_PDF_417); - * foreach($reader->readBarCodes() as $result) - * echo $result->getCodeText() . " IsLinked:" . $result->getExtended()->getPdf417()->isLinked(); - * @endcode - * @code - * # Encodes GS1 Linked mode 912 with date field AI 15 (Sell-by date) and AI 10 (Lot number) - * $generator = new BarcodeGenerator(EncodeTypes::GS_1_MICRO_PDF_417, "(15)991231(10)ABCD"); - * $generator->getParameters()->getBarcode()->getPdf417()->setLinked(true); - * $reader = new BarCodeReader($generator->generateBarCodeImage(BarcodeImageFormat::PNG), null, DecodeType::GS_1_MICRO_PDF_417); - * foreach($reader->readBarCodes() as $result) - * echo $result->getCodeText() . " IsLinked:" . $result->getExtended()->getPdf417()->isLinked(); - * @endcode - * @code - * # Encodes GS1 Linked mode 912 with date field AI 17 (Expiration date) and AI 21 (Serial number) - * $generator = new BarcodeGenerator(EncodeTypes::GS_1_MICRO_PDF_417, "(17)991231(21)ABCD"); - * $generator->getParameters()->getBarcode()->getPdf417()->setLinked(true); - * $reader = new BarCodeReader($generator->generateBarCodeImage(BarcodeImageFormat::PNG), null, DecodeType::GS_1_MICRO_PDF_417); - * foreach($reader->readBarCodes() as $result) - * echo $result->getCodeText() . " IsLinked:" . $result->getExtended()->getPdf417()->isLinked(); - * @endcode - * @code - * # Encodes GS1 Linked mode 914 with AI 10 (Lot number) - * $generator = new BarcodeGenerator(EncodeTypes::GS_1_MICRO_PDF_417, "(10)ABCD12345"); - * $generator->getParameters()->getBarcode()->getPdf417()->setLinked(true); - * $reader = new BarCodeReader($generator->generateBarCodeImage(BarcodeImageFormat::PNG), null, DecodeType::GS_1_MICRO_PDF_417); - * foreach($reader->readBarCodes() as $result) - * echo $result->getCodeText() . " IsLinked:" . $result->getExtended()->getPdf417()->isLinked(); - * @endcode - * @code - * # Encodes GS1 Linked mode 915 with AI 21 (Serial number) - * $generator = new BarcodeGenerator(EncodeTypes::GS_1_MICRO_PDF_417, "(21)ABCD12345"); - * $generator->getParameters()->getBarcode()->getPdf417()->setLinked(true); - * $reader = new BarCodeReader($generator->generateBarCodeImage(BarcodeImageFormat::PNG), null, DecodeType::GS_1_MICRO_PDF_417); - * foreach($reader->readBarCodes() as $result) - * echo $result->getCodeText() . " IsLinked:" . $result->getExtended()->getPdf417()->isLinked(); - * @endcode - * @code - * # Encodes GS1 Linked modes 906, 907 with any AI - * $generator = new BarcodeGenerator(EncodeTypes::GS_1_MICRO_PDF_417, "(240)123456789012345"); - * $generator->getParameters()->getBarcode()->getPdf417()->setLinked(true); - * $reader = new BarCodeReader($generator->generateBarCodeImage(BarcodeImageFormat::PNG), null, DecodeType::GS_1_MICRO_PDF_417); - * foreach($reader->readBarCodes() as $result) - * echo $result->getCodeText() . " IsLinked:" . $result->getExtended()->getPdf417()->isLinked(); - * @endcode - * @code - * # Encodes MicroPdf417 NON EAN.UCC Linked mode 918 - * $generator = new BarcodeGenerator(EncodeTypes::MICRO_PDF_417, "ABCDE123456789012345678"); - * $generator->getParameters()->getBarcode()->getPdf417()->setLinked(true); - * $reader = new BarCodeReader($generator->generateBarCodeImage(BarcodeImageFormat::PNG), null, DecodeType::MICRO_PDF_417); - * foreach($reader->readBarCodes() as $result) - * echo $result->getCodeText() . " IsLinked:" . $result->getExtended()->getPdf417()->isLinked(); - * @endcode - * @code - * # Encodes Pdf417 NON EAN.UCC Linked mode 918 - * $generator = new BarcodeGenerator(EncodeTypes::PDF_417, "ABCDE123456789012345678"); - * $generator->getParameters()->getBarcode()->getPdf417()->setLinked(true); - * $reader = new BarCodeReader($generator->generateBarCodeImage(BarcodeImageFormat::PNG), null, DecodeType::PDF_417); - * foreach($reader->readBarCodes() as $result) - * echo $result->getCodeText() . " IsLinked:" . $result->getExtended()->getPdf417()->isLinked(); - * @endcode - *- *
- * Can be used only with MicroPdf417 and encodes Code 128 emulation modes - * Can encode FNC1 in second position modes 908 and 909, also can encode 910 and 911 which just indicate that recognized MicroPdf417 can be interpret as Code 128 - *
- */ - public function isCode128Emulation() : bool - { - return $this->getPdf417ParametersDto()->isCode128Emulation; - } - - /** - *- * These samples show how to encode Code 128 emulation modes with FNC1 in second position and without. In this way MicroPdf417 can be decoded as Code 128 barcode - *- * - * @code - * # Encodes MicroPdf417 in Code 128 emulation mode with FNC1 in second position and Application Indicator "a", mode 908. - * $generator = new BarcodeGenerator(EncodeTypes::MICRO_PDF_417, "a\u001d1222322323"); - * $generator->getParameters()->getBarcode()->getPdf417()->setCode128Emulation(true); - * $reader = new BarCodeReader($generator->generateBarCodeImage(BarcodeImageFormat::PNG), null, DecodeType::MICRO_PDF_417); - * foreach($reader->readBarCodes() as $result) - * echo $result->getCodeText() . " IsCode128Emulation:" . $result->getExtended()->getPdf417()->isCode128Emulation(); - * @endcode - * @code - * # Encodes MicroPdf417 in Code 128 emulation mode with FNC1 in second position and Application Indicator "99", mode 909. - * $generator = new BarcodeGenerator(EncodeTypes::MICRO_PDF_417, "99\u001d1222322323"); - * $generator->getParameters()->getBarcode()->getPdf417()->setCode128Emulation(true); - * $reader = new BarCodeReader($generator->generateBarCodeImage(BarcodeImageFormat::PNG), null, DecodeType::MICRO_PDF_417); - * foreach($reader->readBarCodes() as $result) - * echo $result->getCodeText() . " IsCode128Emulation:" . $result->getExtended()->getPdf417()->isCode128Emulation(); - * @endcode - * @code - * # Encodes MicroPdf417 in Code 128 emulation mode, modes 910, 911 - * $generator = new BarcodeGenerator(EncodeTypes::MICRO_PDF_417, "123456789012345678"); - * $generator->getParameters()->getBarcode()->getPdf417()->setCode128Emulation(true); - * $reader = new BarCodeReader($generator->generateBarCodeImage(BarcodeImageFormat::PNG), null, DecodeType::MICRO_PDF_417); - * foreach($reader->readBarCodes() as $result) - * echo $result->getCodeText() . " IsCode128Emulation:" + result.Extended.Pdf417.IsCode128Emulation().toString()); - * @endcode - *- *
- * Can be used only with MicroPdf417 and encodes Code 128 emulation modes - * Can encode FNC1 in second position modes 908 and 909, also can encode 910 and 911 which just indicate that recognized MicroPdf417 can be interpret as Code 128 - *
- */ - public function setCode128Emulation(bool $value) : void - { - $this->getPdf417ParametersDto()->isCode128Emulation = $value; - } - - /** - * Returns a human-readable string representation of this Pdf417Parameters. - * - * @return string that represents this Pdf417Parameters. - */ - public function toString(): string - { - $thriftConnection = new ThriftConnection(); - $client = $thriftConnection->openConnection(); - $str = $client->Pdf417Parameters_toString($this->getPdf417ParametersDto()); - $thriftConnection->closeConnection(); - - return $str; - } -} - -/** - * Supplement parameters. Used for Interleaved2of5, Standard2of5, EAN13, EAN8, UPCA, UPCE, ISBN, ISSN, ISMN. - */ -class SupplementParameters implements Communicator -{ - private $supplementParametersDto; - - private function getSupplementParametersDto(): SupplementParametersDTO - { - return $this->supplementParametersDto; - } - - private function setSupplementParametersDto(SupplementParametersDTO $supplementParametersDto): void - { - $this->supplementParametersDto = $supplementParametersDto; - } - private $_space; - - function __construct(SupplementParametersDTO $supplementParametersDto) - { - $this->supplementParametersDto = $supplementParametersDto; - $this->obtainDto(); - $this->initFieldsFromDto(); - } - - public function obtainDto(...$args) - { - } - - public function initFieldsFromDto(): void - { - try - { - $this->_space = new Unit($this->getSupplementParametersDto()->supplementSpace); - } - catch (Exception $ex) - { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - /** - * Supplement data following BarCode. - */ - public function getSupplementData(): ?string - { - try - { - $SupplementData = $this->getSupplementParametersDto()->supplementData; - if ($SupplementData == "null") - { - return null; - } - return $SupplementData; - } - catch (Exception $ex) - { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - /** - * Supplement data following BarCode. - */ - public function setSupplementData(string $value): void - { - try - { - $this->getSupplementParametersDto()->supplementData = $value; - } - catch (Exception $ex) - { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - /** - * Space between main the BarCode and supplement BarCode in Unit value. - * - * @exception IllegalArgumentException - * The Space parameter value is less than 0. - */ - public function getSupplementSpace(): Unit - { - return $this->_space; - } - - /** - * Returns a human-readable string representation of this SupplementParameters. - * - * @return string that represents this SupplementParameters. - */ - public function toString(): string - { - $thriftConnection = new ThriftConnection(); - $client = $thriftConnection->openConnection(); - $str = $client->SupplementParameters_toString($this->getSupplementParametersDto()); - $thriftConnection->closeConnection(); - - return $str; - } -} - -/** - * MaxiCode parameters. - */ -class MaxiCodeParameters implements Communicator -{ - private $maxiCodeParametersDto; - - private function getMaxiCodeParametersDto(): MaxiCodeParametersDTO - { - return $this->maxiCodeParametersDto; - } - - private function setMaxiCodeParametersDto(MaxiCodeParametersDTO $maxiCodeParametersDto): void - { - $this->maxiCodeParametersDto = $maxiCodeParametersDto; - } - - function __construct(MaxiCodeParametersDTO $maxiCodeParametersDto) - { - $this->maxiCodeParametersDto = $maxiCodeParametersDto; - $this->obtainDto(); - $this->initFieldsFromDto(); - } - - public function obtainDto(...$args) - { - } - - public function initFieldsFromDto(): void - { - } - - /** - * Gets a MaxiCode encode mode. - */ - public function getMaxiCodeMode() : int - { - return $this->getMaxiCodeParametersDto()->maxiCodeMode; - } - - /** - * Sets a MaxiCode encode mode. - */ - public function setMaxiCodeMode(int $maxiCodeMode) : void - { - $this->getMaxiCodeParametersDto()->maxiCodeMode = $maxiCodeMode; - } - - /** - * Gets a MaxiCode encode mode. - */ - public function getMaxiCodeEncodeMode(): int - { - try - { - return $this->getMaxiCodeParametersDto()->maxiCodeEncodeMode; - } - catch (Exception $ex) - { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - /** - * Sets a MaxiCode encode mode. - */ - public function setMaxiCodeEncodeMode(int $value): void - { - try - { - $this->getMaxiCodeParametersDto()->maxiCodeEncodeMode = $value; - } - catch (Exception $ex) - { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - /** - * Gets ECI encoding. Used when MaxiCodeEncodeMode is AUTO. - * Default value: ISO-8859-1 - */ - public function getECIEncoding() : int - { - return $this->getMaxiCodeParametersDto()->eCIEncoding; - } - - /** - * Sets ECI encoding. Used when MaxiCodeEncodeMode is AUTO. - * Default value: ISO-8859-1 - */ - public function setECIEncoding(int $ECIEncoding) : void - { - $this->getMaxiCodeParametersDto()->eCIEncoding = $ECIEncoding; - } - - /** - * Gets a MaxiCode barcode id in structured append mode. - * ID must be a value between 1 and 8. - * Default value: 0 - */ - public function getMaxiCodeStructuredAppendModeBarcodeId() : int - { - return $this->getMaxiCodeParametersDto()->maxiCodeStructuredAppendModeBarcodeId; - } - - /** - * Sets a MaxiCode barcode id in structured append mode. - * ID must be a value between 1 and 8. - * Default value: 0 - */ - public function setMaxiCodeStructuredAppendModeBarcodeId(int $maxiCodeStructuredAppendModeBarcodeId) : void - { - $this->getMaxiCodeParametersDto()->maxiCodeStructuredAppendModeBarcodeId = $maxiCodeStructuredAppendModeBarcodeId; - } - - /** - * Gets a MaxiCode barcodes count in structured append mode. - * Count number must be a value between 2 and 8 (maximum barcodes count). - * Default value: -1 - */ - public function getMaxiCodeStructuredAppendModeBarcodesCount() : int - { - return $this->getMaxiCodeParametersDto()->maxiCodeStructuredAppendModeBarcodesCount; - } - - /** - * Sets a MaxiCode barcodes count in structured append mode. - * Count number must be a value between 2 and 8 (maximum barcodes count). - * Default value: -1 - */ - public function setMaxiCodeStructuredAppendModeBarcodesCount(int $maxiCodeStructuredAppendModeBarcodesCount) : void - { - $this->getMaxiCodeParametersDto()->maxiCodeStructuredAppendModeBarcodesCount = $maxiCodeStructuredAppendModeBarcodesCount; - } - - /** - * Height/Width ratio of 2D BarCode module. - */ - public function getAspectRatio(): float - { - try - { - return $this->getMaxiCodeParametersDto()->aspectRatio; - } - catch (Exception $ex) - { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - /** - * Height/Width ratio of 2D BarCode module. - */ - public function setAspectRatio(float $value): void - { - try - { - $this->getMaxiCodeParametersDto()->aspectRatio = $value; - } - catch (Exception $ex) - { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - /** - * Returns a human-readable string representation of this MaxiCodeParameters. - * - * @return string that represents this MaxiCodeParameters. - */ - public function toString(): string - { - $thriftConnection = new ThriftConnection(); - $client = $thriftConnection->openConnection(); - $str = $client->MaxiCodeParameters_toString($this->getMaxiCodeParametersDto()); - $thriftConnection->closeConnection(); - - return $str; - } -} - - -/** - * PatchCode parameters. - */ -class PatchCodeParameters implements Communicator -{ - private $patchCodeParametersDto; - - function getPatchCodeParametersDto(): PatchCodeParametersDTO - { - return $this->patchCodeParametersDto; - } - - private function setPatchCodeParametersDto(PatchCodeParametersDTO $patchCodeParametersDto): void - { - $this->patchCodeParametersDto = $patchCodeParametersDto; - } - - function __construct(PatchCodeParametersDTO $patchCodeParametersDto) - { - $this->patchCodeParametersDto = $patchCodeParametersDto; - $this->obtainDto(); - $this->initFieldsFromDto(); - } - - public function obtainDto(...$args) - { - } - - public function initFieldsFromDto(): void - { - } - - /** - * Specifies codetext for an extra QR barcode, when PatchCode is generated in page mode. - */ - public function getExtraBarcodeText(): ?string - { - try - { - $ExtraBarcodeText = $this->getPatchCodeParametersDto()->extraBarcodeText; - if ($ExtraBarcodeText == "null") - { - return null; - } - return $ExtraBarcodeText; - } - catch (Exception $ex) - { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - /** - * Specifies codetext for an extra QR barcode, when PatchCode is generated in page mode. - */ - public function setExtraBarcodeText(string $value): void - { - try - { - $this->getPatchCodeParametersDto()->extraBarcodeText = $value; - } - catch (Exception $ex) - { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - /** - * PatchCode format. Choose PatchOnly to generate single PatchCode. Use page format to generate Patch page with PatchCodes as borders. - * Default value: PatchFormat::PATCH_ONLY - * - * @return - */ - public function getPatchFormat(): int - { - try - { - return $this->getPatchCodeParametersDto()->patchFormat; - } - catch (Exception $ex) - { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - /** - * PatchCode format. Choose PatchOnly to generate single PatchCode. Use page format to generate Patch page with PatchCodes as borders. - * Default value: PatchFormat::PATCH_ONLY - */ - public function setPatchFormat(int $value): void - { - try - { - $this->getPatchCodeParametersDto()->patchFormat = $value; - } - catch (Exception $ex) - { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - /** - * Returns a human-readable string representation of this PatchCodeParameters. - * @return string A string that represents this PatchCodeParameters. - */ - public function toString(): string - { - $thriftConnection = new ThriftConnection(); - $client = $thriftConnection->openConnection(); - $str = $client->PatchCodeParameters_toString($this->getPatchCodeParametersDto()); - $thriftConnection->closeConnection(); - - return $str; - } -} - -/** - * Code128 parameters. - */ -class Code128Parameters implements Communicator -{ - private $code128ParametersDto; - - private function getCode128ParametersDto(): Code128ParametersDTO - { - return $this->code128ParametersDto; - } - - private function setCode128ParametersDto(Code128ParametersDTO $code128ParametersDto): void - { - $this->code128ParametersDto = $code128ParametersDto; - } - - function __construct(Code128ParametersDTO $code128ParametersDto) - { - $this->code128ParametersDto = $code128ParametersDto; - $this->obtainDto(); - $this->initFieldsFromDto(); - } - - public function obtainDto(...$args) - { - } - - public function initFieldsFromDto(): void - { - } - - /** - *- * These samples show how to encode Code 128 emulation modes with FNC1 in second position and without. In this way MicroPdf417 can be decoded as Code 128 barcode - *- * - * @code - * # Encodes MicroPdf417 in Code 128 emulation mode with FNC1 in second position and Application Indicator "a", mode 908. - * $generator = new BarcodeGenerator(EncodeTypes::MICRO_PDF_417, "a\u001d1222322323"); - * $generator->getParameters()->getBarcode()->getPdf417()->setCode128Emulation(true); - * $reader = new BarCodeReader($generator->generateBarCodeImage(BarcodeImageFormat::PNG), null, DecodeType::MICRO_PDF_417); - * foreach($reader->readBarCodes() as $result) - * echo $result->getCodeText() . " IsCode128Emulation:" + result.Extended.Pdf417.IisCode128Emulation().toString()); - * @endcode - * @code - * # Encodes MicroPdf417 in Code 128 emulation mode with FNC1 in second position and Application Indicator "99", mode 909. - * $generator = new BarcodeGenerator(EncodeTypes::MICRO_PDF_417, "99\u001d1222322323"); - * $generator->getParameters()->getBarcode()->getPdf417()->setCode128Emulation(true); - * $reader = new BarCodeReader($generator->generateBarCodeImage(BarcodeImageFormat::PNG), null, DecodeType::MICRO_PDF_417); - * foreach($reader->readBarCodes() as $result) - * echo $result->getCodeText() . " IsCode128Emulation:" . $result->getExtended()->getPdf417()->isCode128Emulation(); - * @endcode - * @code - * # Encodes MicroPdf417 in Code 128 emulation mode, modes 910, 911 - * $generator = new BarcodeGenerator(EncodeTypes::MICRO_PDF_417, "123456789012345678"); - * $generator->getParameters()->getBarcode()->getPdf417()->setCode128Emulation(true); - * $reader = new BarCodeReader($generator->generateBarCodeImage(BarcodeImageFormat::PNG), null, DecodeType::MICRO_PDF_417); - * foreach($reader->readBarCodes() as $result) - * echo $result->getCodeText() . " IsCode128Emulation:" . $result->getExtended()->getPdf417()->isCode128Emulation())); - * @endcode - *- *
- * Gets a Code128 encode mode. - * Default value: Code128EncodeMode.Auto - *
- */ - public function getCode128EncodeMode() : int - { - try - { - return $this->getCode128ParametersDto()->code128EncodeMode; - } - catch (Exception $ex) - { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - /** - *- * Sets a Code128 encode mode. - * Default value: Code128EncodeMode.Auto - *
- */ - public function setCode128EncodeMode(int $value) - { - try - { - $this->getCode128ParametersDto()->code128EncodeMode = $value; - } - catch (Exception $ex) - { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - /** - * Returns a human-readable string representation of this PatchCodeParameters. - * @return string A string that represents this PatchCodeParameters. - */ - public function toString(): string - { - $thriftConnection = new ThriftConnection(); - $client = $thriftConnection->openConnection(); - $str = $client->Code128Parameters_toString($this->getCode128ParametersDto()); - $thriftConnection->closeConnection(); - - return $str; - } -} - - -/** - *- * Han Xin parameters. - *
- */ -class HanXinParameters implements Communicator -{ - private $hanXinParametersDto; - - private function getHanXinParametersDto(): HanXinParametersDTO - { - return $this->hanXinParametersDto; - } - - private function setHanXinParametersDto(HanXinParametersDTO $hanXinParametersDto): void - { - $this->hanXinParametersDto = $hanXinParametersDto; - } - - function __construct(HanXinParametersDTO $hanXinParametersDto) - { - $this->hanXinParametersDto = $hanXinParametersDto; - $this->obtainDto(); - $this->initFieldsFromDto(); - } - - public function obtainDto(...$args) - { - } - - public function initFieldsFromDto(): void - { - } - - /** - *- * Version of HanXin Code. - * From Version01 to Version84 for Han Xin code. - * Default value is HanXinVersion.Auto. - *
- */ - public function getHanXinVersion() : int - { - return $this->getHanXinParametersDto()->hanXinVersion; - } - /** - *- * Version of HanXin Code. - * From Version01 to Version84 for Han Xin code. - * Default value is HanXinVersion.Auto. - *
- */ - public function setHanXinVersion(int $value) : void - { - $this->getHanXinParametersDto()->hanXinVersion = $value; - } - - /** - *- * Level of Reed-Solomon error correction for Han Xin barcode. - * From low to high: L1, L2, L3, L4. see HanXinErrorLevel. - *
- */ - public function getHanXinErrorLevel() : int - { - return $this->getHanXinParametersDto()->hanXinErrorLevel; - } - /** - *- * Level of Reed-Solomon error correction for Han Xin barcode. - * From low to high: L1, L2, L3, L4. see HanXinErrorLevel. - *
- */ - public function setHanXinErrorLevel(int $value) :void - { - $this->getHanXinParametersDto()->hanXinErrorLevel = $value; - } - - /** - *- * HanXin encoding mode. - * Default value: HanXinEncodeMode::Mixed. - *
- */ - public function getHanXinEncodeMode() : int - { - return $this->getHanXinParametersDto()->hanXinEncodeMode; - } - /** - *- * HanXin encoding mode. - * Default value: HanXinEncodeMode::Mixed. - *
- */ - public function setHanXinEncodeMode(int $value) :void - { - $this->getHanXinParametersDto()->hanXinEncodeMode = $value; - } - - /** - *- * Extended Channel Interpretation Identifiers. It is used to tell the barcode reader details - * about the used references for encoding the data in the symbol. - * Current implementation consists all well known charset encodings. - *
- */ - public function getHanXinECIEncoding() :int - { - return $this->getHanXinParametersDto()->hanXinECIEncoding; - } - /** - *- * Extended Channel Interpretation Identifiers. It is used to tell the barcode reader details - * about the used references for encoding the data in the symbol. - * Current implementation consists all well known charset encodings. - *
- */ - public function setHanXinECIEncoding(int $value) :void - { - $this->getHanXinParametersDto()->hanXinECIEncoding = $value; - } - - - /** - *- * Returns a human-readable string representation of this {@code HanXinParameters}. - *
- * @return string that represents this {@code HanXinParameters}. - */ - public function toString() :string - { - $thriftConnection = new ThriftConnection(); - $client = $thriftConnection->openConnection(); - $str = $client->HanXinParameters_toString($this->getHanXinParametersDto()); - $thriftConnection->closeConnection(); - - return $str; - } -} - -/** - * Aztec parameters. - */ -class AztecParameters implements Communicator -{ - private $aztecParametersDto; - - private function getAztecParametersDto(): AztecParametersDTO - { - return $this->aztecParametersDto; - } - - private function setAztecParametersDto(AztecParametersDTO $aztecParametersDto): void - { - $this->aztecParametersDto = $aztecParametersDto; - } - - function __construct(AztecParametersDTO $aztecParametersDto) - { - $this->aztecParametersDto = $aztecParametersDto; - $this->obtainDto(); - $this->initFieldsFromDto(); - } - - public function obtainDto(...$args) - { - } - - public function initFieldsFromDto(): void - { - } - - /** - *- * Gets a Aztec encode mode. - * Default value: Auto. - *
- */ - public function getAztecEncodeMode() : int - { - return $this->getAztecParametersDto()->aztecEncodeMode; - } - - /** - *- * Sets a Aztec encode mode. - * Default value: Auto. - *
- */ - public function setAztecEncodeMode(int $value) : void - { - $this->getAztecParametersDto()->aztecEncodeMode = $value; - } - - /** - *- * Gets ECI encoding. Used when AztecEncodeMode is Auto. - * Default value: ISO-8859-1 - *
- */ - public function getECIEncoding() : int - { - return $this->getAztecParametersDto()->ECIEncoding; - } - /** - *- * Gets ECI encoding. Used when AztecEncodeMode is Auto. - * Default value: ISO-8859-1 - *
- */ - public function setECIEncoding(int $value) : void - { - $this->getAztecParametersDto()->ECIEncoding = $value; - } - - /** - *- * Barcode ID for Structured Append mode of Aztec barcode. Barcode ID should be in range from 1 to barcodes count. - * Default value: 0 - *
- */ - public function getStructuredAppendBarcodeId() : int - { - return $this->getAztecParametersDto()->structuredAppendBarcodeId; - } - /** - *- * Barcode ID for Structured Append mode of Aztec barcode. Barcode ID should be in range from 1 to barcodes count. - * Default value: 0 - *
- */ - public function setStructuredAppendBarcodeId(int $value) : void - { - $this->getAztecParametersDto()->structuredAppendBarcodeId = $value; - } - - /** - *- * Barcodes count for Structured Append mode of Aztec barcode. Barcodes count should be in range from 1 to 26. - * Default value: 0 - *
- */ - public function getStructuredAppendBarcodesCount() : int - { - return $this->getAztecParametersDto()->structuredAppendBarcodesCount; - } - /** - *- * Barcodes count for Structured Append mode of Aztec barcode. Barcodes count should be in range from 1 to 26. - * Default value: 0 - *
- */ - public function setStructuredAppendBarcodesCount(int $value) : void - { - $this->getAztecParametersDto()->structuredAppendBarcodesCount = $value; - } - - /** - *- * File ID for Structured Append mode of Aztec barcode (optional field). File ID should not contain spaces. - * Default value: empty string - *
- */ - public function getStructuredAppendFileId() : string - { - return $this->getAztecParametersDto()->structuredAppendFileId; - } - /** - *- * File ID for Structured Append mode of Aztec barcode (optional field). File ID should not contain spaces. - * Default value: empty string - *
- */ - public function setStructuredAppendFileId(string $value) : void - { - $this->getAztecParametersDto()->structuredAppendFileId = $value; - } - - /** - *- * Level of error correction of Aztec types of barcode. - * Value should between 5 to 95. - *
- */ - public function getAztecErrorLevel() : int - { - return $this->getAztecParametersDto()->aztecErrorLevel; - } - /** - *- * Level of error correction of Aztec types of barcode. - * Value should between 5 to 95. - *
- */ - public function setAztecErrorLevel(int $value) : void - { - $this->getAztecParametersDto()->aztecErrorLevel = $value; - } - - /** - *- * Gets a Aztec Symbol mode. - * Default value: AztecSymbolMode.Auto. - *
- */ - public function getAztecSymbolMode() : int - { - return $this->getAztecParametersDto()->aztecSymbolMode; - } - /** - *- * Sets a Aztec Symbol mode. - * Default value: AztecSymbolMode.Auto. - *
- */ - public function setAztecSymbolMode(int $value) : void - { - $this->getAztecParametersDto()->aztecSymbolMode = $value; - } - - /** - *- * Gets layers count of Aztec symbol. Layers count should be in range from 1 to 3 for Compact mode and - * in range from 1 to 32 for Full Range mode. - * Default value: 0 (auto). - *
- */ - public function getLayersCount() : int - { - return $this->getAztecParametersDto()->layersCount; - } - /** - *- * Sets layers count of Aztec symbol. Layers count should be in range from 1 to 3 for Compact mode and - * in range from 1 to 32 for Full Range mode. - * Default value: 0 (auto). - *
- */ - public function setLayersCount(int $value) : void - { - $this->getAztecParametersDto()->layersCount = $value; - } - - /** - *- * Used to instruct the reader to interpret the data contained within the symbol - * as programming for reader initialization. - *
- */ - public function isReaderInitialization() : bool - { - return $this->getAztecParametersDto()->isReaderInitialization; - } - - /** - *- * Used to instruct the reader to interpret the data contained within the symbol - * as programming for reader initialization. - *
- */ - public function setReaderInitialization(bool $value) : void - { - $this->getAztecParametersDto()->isReaderInitialization = $value; - } - - /** - *- * Height/Width ratio of 2D BarCode module. - *
- */ - public function getAspectRatio() : float - { - return $this->getAztecParametersDto()->aspectRatio; - } - /** - *- * Height/Width ratio of 2D BarCode module. - *
- */ - public function setAspectRatio(float $value) : void - { - $this->getAztecParametersDto()->aspectRatio = $value; - } - - /** - *- * Returns a human-readable string representation of this {@code AztecParameters}. - *
- * @return string that represents this {@code AztecParameters}. - */ - public function toString() : string - { - $thriftConnection = new ThriftConnection(); - $client = $thriftConnection->openConnection(); - $str = $client->AztecParameters_toString($this->getAztecParametersDto()); - $thriftConnection->closeConnection(); - - return $str; - } -} - -/** - * Codabar parameters. - */ -class CodabarParameters implements Communicator -{ - private $codabarParametersDto; - - private function getCodabarParametersDto(): CodabarParametersDTO - { - return $this->codabarParametersDto; - } - - private function setCodabarParametersDto(CodabarParametersDTO $codabarParametersDto): void - { - $this->codabarParametersDto = $codabarParametersDto; - } - - function __construct(CodabarParametersDTO $codabarParametersDto) - { - $this->codabarParametersDto = $codabarParametersDto; - $this->obtainDto(); - $this->initFieldsFromDto(); - } - - public function obtainDto(...$args) - { - } - - public function initFieldsFromDto(): void - { - } - - /** - * Get the checksum algorithm for Codabar barcodes. - * Default value: CodabarChecksumMode::MOD_16. - * To enable checksum calculation set value EnableChecksum::YES to property EnableChecksum. - * @see CodabarChecksumMode. - */ - public function getCodabarChecksumMode(): int - { - try - { - return $this->getCodabarParametersDto()->codabarChecksumMode; - } - catch (Exception $ex) - { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - /** - * Set the checksum algorithm for Codabar barcodes. - * Default value: CodabarChecksumMode::MOD_16. - * To enable checksum calculation set value EnableChecksum::YES to property EnableChecksum. - * @see CodabarChecksumMode. - */ - public function setCodabarChecksumMode(int $value): void - { - try - { - $this->getCodabarParametersDto()->codabarChecksumMode = $value; - } - catch (Exception $ex) - { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - /** - * Start symbol (character) of Codabar symbology. - * Default value: CodabarSymbol::A - */ - public function getCodabarStartSymbol(): int - { - try - { - return $this->getCodabarParametersDto()->codabarStartSymbol; - } - catch (Exception $ex) - { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - /** - * Start symbol (character) of Codabar symbology. - * Default value: CodabarSymbol::A - */ - public function setCodabarStartSymbol(int $value): void - { - try - { - $this->getCodabarParametersDto()->codabarStartSymbol = $value; - } - catch (Exception $ex) - { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - /** - * Stop symbol (character) of Codabar symbology. - * Default value: CodabarSymbol::A - */ - public function getCodabarStopSymbol(): int - { - try - { - return $this->getCodabarParametersDto()->codabarStopSymbol; - } - catch (Exception $ex) - { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - /** - * Stop symbol (character) of Codabar symbology. - * Default value: CodabarSymbol::A - */ - public function setCodabarStopSymbol(int $value): void - { - try - { - $this->getCodabarParametersDto()->codabarStopSymbol = $value; - } - catch (Exception $ex) - { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - /** - * Returns a human-readable string representation of this CodabarParameters. - * - * @return string that represents this CodabarParameters. - */ - public function toString(): string - { - $thriftConnection = new ThriftConnection(); - $client = $thriftConnection->openConnection(); - $str = $client->CodabarParameters_toString($this->getCodabarParametersDto()); - $thriftConnection->closeConnection(); - - return $str; - } -} - -/** - * Coupon parameters. Used for UpcaGs1DatabarCoupon, UpcaGs1Code128Coupon. - */ -class CouponParameters implements Communicator -{ - private $couponParametersDto; - - private function getCouponParametersDto(): CouponParametersDTO - { - return $this->couponParametersDto; - } - - private function setCouponParametersDto(CouponParametersDTO $couponParametersDto): void - { - $this->couponParametersDto = $couponParametersDto; - } - - private $_space; - - function __construct(CouponParametersDTO $couponParametersDto) - { - $this->couponParametersDto = $couponParametersDto; - $this->obtainDto(); - $this->initFieldsFromDto(); - } - - public function obtainDto(...$args) - { - } - - public function initFieldsFromDto(): void - { - try - { - $this->_space = new Unit($this->getCouponParametersDto()->supplementSpace); - } - catch (Exception $ex) - { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - /** - * Space between main the BarCode and supplement BarCode in Unit value. - * - * @exception IllegalArgumentException - * The Space parameter value is less than 0. - */ - public function getSupplementSpace(): Unit - { - return $this->_space; - } - - /** - * Space between main the BarCode and supplement BarCode in Unit value. - * - * @exception IllegalArgumentException - * The Space parameter value is less than 0. - */ - public function setSupplementSpace(Unit $value): void - { - try - { - $this->getCouponParametersDto()->supplementSpace = $value->getUnitDto(); - $this->_space = $value; - } - catch (Exception $ex) - { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - /** - * Returns a human-readable string representation of this CouponParameters. - * - * @return string that represents this CouponParameters. - */ - public function toString(): string - { - $thriftConnection = new ThriftConnection(); - $client = $thriftConnection->openConnection(); - $str = $client->CouponParameters_toString($this->getCouponParametersDto()); - $thriftConnection->closeConnection(); - - return $str; - } -} - -/** - * Caption parameters. - */ -class CaptionParameters implements Communicator -{ - private $captionParametersDto; - - function getCaptionParametersDto(): CaptionParametersDTO - { - return $this->captionParametersDto; - } - - private function setCaptionParametersDto(CaptionParametersDTO $captionParametersDto): void - { - $this->captionParametersDto = $captionParametersDto; - } - - private $font; - private $padding; - - function __construct(CaptionParametersDTO $captionParametersDto) - { - $this->captionParametersDto = $captionParametersDto; - $this->obtainDto(); - $this->initFieldsFromDto(); - } - - public function obtainDto(...$args) - { - } - - public function initFieldsFromDto(): void - { - try - { - $this->padding = new Padding($this->getCaptionParametersDto()->padding); - $this->font = new FontUnit($this->getCaptionParametersDto()->font); - } - catch (Exception $ex) - { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - /** - * Caption text. - * Default value: empty string. - */ - public function getText(): string - { - try - { - return $this->getCaptionParametersDto()->text; - } - catch (Exception $ex) - { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - /** - * Caption text. - * Default value: empty string. - */ - public function setText(string $value): void - { - try - { - $this->getCaptionParametersDto()->text = $value; - } - catch (Exception $ex) - { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - /** - * Caption font. - * Default value: Arial 8pt regular. - */ - public function getFont(): FontUnit - { - try - { - return $this->font; - } - catch (Exception $ex) - { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - /** - * Caption text visibility. - * Default value: false. - */ - public function getVisible(): bool - { - try - { - return $this->getCaptionParametersDto()->visible; - } - catch (Exception $ex) - { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - /** - * Caption text visibility. - * Default value: false. - */ - public function setVisible(bool $value): void - { - try - { - $this->getCaptionParametersDto()->visible = $value; - } - catch (Exception $ex) - { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - /** - * Caption text color. - * Default value BLACK. - */ - public function getTextColor(): string - { - try - { - $hexColor = strtoupper(dechex($this->getCaptionParametersDto()->textColor)); - while (strlen($hexColor) < 6) - { - $hexColor = "0" . $hexColor; - } - $hexColor = "#" . $hexColor; - return $hexColor; - } - catch (Exception $ex) - { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - /** - * Caption text color. - * Default value BLACK. - */ - public function setTextColor(string $value): void - { - try - { - if(substr($value, 0, 1) == '#') - $value = substr($value, 1, strlen($value) - 1); - $this->getCaptionParametersDto()->textColor = hexdec($value); - } - catch (Exception $ex) - { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - /** - * Captions paddings. - * Default value for CaptionAbove: 5pt 5pt 0 5pt. - * Default value for CaptionBelow: 0 5pt 5pt 5pt. - */ - public function getPadding(): Padding - { - return $this->padding; - } - - /** - * Captions paddings. - * Default value for CaptionAbove: 5pt 5pt 0 5pt. - * Default value for CaptionBelow: 0 5pt 5pt 5pt. - */ - public function setPadding(Padding $value): void - { - try - { - $this->getCaptionParametersDto()->padding = $value->getPaddingDto(); - $this->padding = $value; - } - catch (Exception $ex) - { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - /** - * Caption test horizontal alignment. - * Default value: StringAlignment.Center. - */ - public function getAlignment(): int - { - try - { - return $this->getCaptionParametersDto()->alignment; - } - catch (Exception $ex) - { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - /** - * Caption test horizontal alignment. - * Default value: StringAlignment.CENTER. - */ - public function setAlignment(int $value): void - { - try - { - $this->getCaptionParametersDto()->alignment = $value; - } - catch (Exception $ex) - { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - /* - * Specify word wraps (line breaks) within text. - * @return bool - */ - public function getNoWrap(): bool - { - try - { - return $this->getCaptionParametersDto()->noWrap; - } - catch (Exception $ex) - { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - /* - * Specify word wraps (line breaks) within text. - */ - public function setNoWrap(bool $value): void - { - try - { - $this->getCaptionParametersDto()->noWrap = $value; - } - catch (Exception $ex) - { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } -} - -/** - * Specifies the size value in different units (Pixel, Inches, etc.). - * - * This sample shows how to create and save a BarCode image. - * @code - * $generator = new BarcodeGenerator(EncodeTypes::CODE_128); - * $generator->getParameters()->getBarcode()->getBarHeight()->setMillimeters(10); - * $generator->save("test.png", BarcodeImageFormat::PNG); - * @endcode - */ -class Unit implements Communicator -{ - private $unitDto; - - function getUnitDto(): UnitDTO - { - return $this->unitDto; - } - - private function setUnitDto(UnitDTO $unitDto): void - { - $this->unitDto = $unitDto; - } - - public function __construct($source) - { - try - { - $this->unitDto = self::initUnit($source); - $this->obtainDto(); - $this->initFieldsFromDto(); - } - catch (Exception $ex) - { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - static function initUnit($source) - { - if ($source instanceof Unit) - { - return $source->getUnitDto(); - } - elseif ($source instanceof UnitDTO) - return $source; - throw new InvalidArgumentException(); - } - - public function obtainDto(...$args) - { - } - - public function initFieldsFromDto(): void - { - // TODO: Implement init() method. - } - - /** - * Gets size value in pixels. - */ - public function getPixels(): float - { - $thriftConnection = new ThriftConnection(); - $client = $thriftConnection->openConnection(); - $pixels = $client->Unit_getPixels($this->getUnitDto()); - $thriftConnection->closeConnection(); - - return $pixels; - } - - /** - * Sets size value in pixels. - */ - public function setPixels(float $value): void - { - try - { - $this->getUnitDto()->units = $value; - $this->getUnitDto()->graphicsUnit = GraphicsUnit::PIXEL; - } - catch (Exception $ex) - { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - /** - * Gets size value in inches. - */ - public function getInches(): float - { - $thriftConnection = new ThriftConnection(); - $client = $thriftConnection->openConnection(); - $inches = $client->Unit_getInches($this->getUnitDto()); - $thriftConnection->closeConnection(); - - return $inches; - } - - /** - * Sets size value in inches. - */ - public function setInches(float $value): void - { - try - { - $this->getUnitDto()->units = $value; - $this->getUnitDto()->graphicsUnit = GraphicsUnit::INCH; - } - catch (Exception $ex) - { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - /** - * Gets size value in millimeters. - */ - public function getMillimeters(): float - { - $thriftConnection = new ThriftConnection(); - $client = $thriftConnection->openConnection(); - $millimeters = $client->Unit_getMillimeters($this->getUnitDto()); - $thriftConnection->closeConnection(); - - return $millimeters; - } - - /** - * Sets size value in millimeters. - */ - public function setMillimeters(float $value): void - { - try - { - $this->getUnitDto()->units = $value; - $this->getUnitDto()->graphicsUnit = GraphicsUnit::MILLIMETER; - } - catch (Exception $ex) - { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - /** - * Gets size value in point. - */ - public function getPoint(): float - { - $thriftConnection = new ThriftConnection(); - $client = $thriftConnection->openConnection(); - $point = $client->Unit_getPoint($this->getUnitDto()); - $thriftConnection->closeConnection(); - - return $point; - } - - /** - * Sets size value in point. - */ - public function setPoint(float $value): void - { - try - { - $this->getUnitDto()->units = $value; - $this->getUnitDto()->graphicsUnit = GraphicsUnit::POINT; - } - catch (Exception $ex) - { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - /** - * Gets size value in document units. - */ - public function getDocument(): float - { - $thriftConnection = new ThriftConnection(); - $client = $thriftConnection->openConnection(); - $document = $client->Unit_getDocument($this->getUnitDto()); - $thriftConnection->closeConnection(); - - return $document; - } - - /** - * Sets size value in document units. - */ - public function setDocument(float $value): void - { - try - { - $this->getUnitDto()->units = $value; - $this->getUnitDto()->graphicsUnit = GraphicsUnit::DOCUMENT; - } - catch (Exception $ex) - { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - /** - * Returns a human-readable string representation of this Unit. - * - * @return string that represents this Unit. - */ - public function toString(): string - { - $thriftConnection = new ThriftConnection(); - $client = $thriftConnection->openConnection(); - $str = $client->Unit_toString($this->getUnitDto()); - $thriftConnection->closeConnection(); - - return $str; - } - - /** - * Determines whether this instance and a specified object, - * which must also be a Unit object, have the same value. - * - * @param Unit $obj The Unit to compare to this instance. - * @return true if obj is a Unit and its value is the same as this instance; - * otherwise, false. If obj is null, the method returns false. - */ - public function equals(Unit $obj): bool - { - $thriftConnection = new ThriftConnection(); - $client = $thriftConnection->openConnection(); - $isEquals = $client->Unit_equals($this->getUnitDTO(), $obj->getUnitDTO()); - $thriftConnection->closeConnection(); - - return $isEquals; - } -} - - -/** - * - * Defines a particular format for text, including font face, size, and style attributes - * where size in Unit value property. - * - * This sample shows how to create and save a BarCode image. - * @code - * $generator = new BarcodeGenerator(EncodeTypes::CODE_128); - * $generator->getParameters()->getCaptionAbove()->setText("CAPTION ABOOVE"); - * $generator->getParameters()->getCaptionAbove()->setVisible(true); - * $generator->getParameters()->getCaptionAbove()->getFont()->setStyle(FontStyle::ITALIC); - * $generator->getParameters()->getCaptionAbove()->getFont()->getSize()->setPoint(25); - * @endcode - */ -final class FontUnit implements Communicator -{ - private $fontUnitDto; - - function getFontUnitDto(): FontUnitDTO - { - return $this->fontUnitDto; - } - - private function setFontUnitDto(FontUnitDTO $fontUnitDto): void - { - $this->fontUnitDto = $fontUnitDto; - } - - private $_size; - - public function __construct($source) - { - $this->fontUnitDto = self::initFontUnit($source); - $this->obtainDto(); - $this->initFieldsFromDto(); - } - - private static function initFontUnit($source) - { - if ($source instanceof FontUnit) - { - return $source->getFontUnitDto(); - } - elseif ($source instanceof FontUnitDTO) - return $source; - throw new InvalidArgumentException(); - } - - public function obtainDto(...$args) - { - } - - public function initFieldsFromDto(): void - { - try - { - $this->_size = new Unit($this->getFontUnitDto()->size); - } - catch (Exception $ex) - { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - /** - * Gets the face name of this Font. - */ - public function getFamilyName(): string - { - try - { - return $this->getFontUnitDto()->familyName; - } - catch (Exception $ex) - { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - /** - * Sets the face name of this Font. - */ - public function setFamilyName(string $value): void - { - try - { - $this->getFontUnitDto()->familyName = $value; - } - catch (Exception $ex) - { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - /** - * Gets style information for this FontUnit. - */ - public function getStyle(): int - { - try - { - return $this->getFontUnitDto()->style; - } - catch (Exception $ex) - { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - /** - * Sets style information for this FontUnit. - */ - public function setStyle(int $value): void - { - try - { - $this->getFontUnitDto()->style = $value; - } - catch (Exception $ex) - { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - /** - * Gets size of this FontUnit in Unit value. - * - * @exception IllegalArgumentException - * The Size parameter value is less than or equal to 0. - */ - public function getSize(): Unit - { - return $this->_size; - } -} - -/** - * Paddings parameters. - */ -class Padding implements Communicator -{ - private $paddingDto; - - function getPaddingDto(): PaddingDTO - { - return $this->paddingDto; - } - - private function setPaddingDto(PaddingDTO $paddingDto): void - { - $this->paddingDto = $paddingDto; - } - - private $top; - private $bottom; - private $right; - private $left; - - function __construct(PaddingDTO $paddingDto) - { - $this->paddingDto = $paddingDto; - $this->obtainDto(); - $this->initFieldsFromDto(); - } - - public function obtainDto(...$args) - { - } - - public function initFieldsFromDto(): void - { - $this->top = new Unit($this->getPaddingDto()->top); - $this->bottom = new Unit($this->getPaddingDto()->bottom); - $this->right = new Unit($this->getPaddingDto()->right); - $this->left = new Unit($this->getPaddingDto()->left); - } - - /** - * Top padding. - */ - public function getTop(): Unit - { - return $this->top; - } - - /** - * Top padding. - */ - public function setTop(Unit $value): void - { - try - { - $this->getPaddingDto()->top = $value->getUnitDto(); - $this->top = $value; - } - catch (Exception $ex) - { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - /** - * Bottom padding. - */ - public function getBottom(): Unit - { - return $this->bottom; - } - - /** - * Bottom padding. - */ - public function setBottom(Unit $value): void - { - try - { - $this->getPaddingDto()->bottom = $value->getUnitDto(); - $this->bottom = $value; - } - catch (Exception $ex) - { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - /** - * Right padding. - */ - public function getRight(): Unit - { - return $this->right; - } - - /** - * Right padding. - */ - public function setRight(Unit $value): void - { - try - { - $this->getPaddingDto()->right = $value->getUnitDto(); - $this->right = $value; - } - catch (Exception $ex) - { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - /** - * Left padding. - */ - public function getLeft(): Unit - { - return $this->left; - } - - /** - * Left padding. - */ - public function setLeft(Unit $value): void - { - try - { - $this->getPaddingDto()->left = $value->getUnitDto(); - $this->left = $value; - } - catch (Exception $ex) - { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - /** - * Returns a human-readable string representation of this Padding. - * - * @return string A string that represents this Padding. - */ - public function toString(): string - { - $thriftConnection = new ThriftConnection(); - $client = $thriftConnection->openConnection(); - $str = $client->Padding_toString($this->getPaddingDto()); - $thriftConnection->closeConnection(); - - return $str; - } -} - - -/** - * Barcode image border parameters - */ -class BorderParameters implements Communicator -{ - private $borderParametersDto; - - private function getBorderParametersDto(): BorderParametersDTO - { - return $this->borderParametersDto; - } - - private function setBorderParametersDto(BorderParametersDTO $borderParametersDto): void - { - $this->borderParametersDto = $borderParametersDto; - } - - private $width; - - function __construct(BorderParametersDTO $borderParametersDto) - { - $this->borderParametersDto = $borderParametersDto; - $this->obtainDto(); - $this->initFieldsFromDto(); - } - - public function obtainDto(...$args) - { - } - - public function initFieldsFromDto(): void - { - try - { - $this->width = new Unit($this->getBorderParametersDto()->width); - } - catch (Exception $ex) - { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - /** - * Border visibility. If false than parameter Width is always ignored (0). - * Default value: false. - */ - public function getVisible(): bool - { - try - { - return $this->getBorderParametersDto()->visible; - } - catch (Exception $ex) - { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - /** - * Border visibility. If false than parameter Width is always ignored (0). - * Default value: false. - */ - public function setVisible(bool $value): void - { - try - { - $this->getBorderParametersDto()->visible = $value; - } - catch (Exception $ex) - { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - /** - * Border width. - * Default value: 0. - * Ignored if Visible is set to false. - */ - public function getWidth(): Unit - { - return $this->width; - } - - /** - * Border width. - * Default value: 0. - * Ignored if Visible is set to false. - *public - */ - public function setWidth(Unit $value): void - { - try - { - $this->getBorderParametersDto()->width = $value->getUnitDto(); - $this->width = $value; - } - catch (Exception $ex) - { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - /** - * Returns a human-readable string representation of this BorderParameters. - * - * @return string A string that represents this BorderParameters. - */ - public function toString(): string - { - $thriftConnection = new ThriftConnection(); - $client = $thriftConnection->openConnection(); - $str = $client->BorderParameters_toString($this->getBorderParametersDto()); - $thriftConnection->closeConnection(); - - return $str; - } - - /** - * Border dash style. - * Default value: BorderDashStyle::SOLID. - */ - public function getDashStyle(): int - { - try - { - return $this->getBorderParametersDto()->dashStyle; - } - catch (Exception $ex) - { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - /** - * Border dash style. - * Default value: BorderDashStyle::SOLID. - */ - public function setDashStyle(int $value): void - { - try - { - $this->getBorderParametersDto()->dashStyle = $value; - } - catch (Exception $ex) - { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - /** - * Border color. - * Default value: #000000 - */ - public function getColor(): string - { - try - { - $hexColor = strtoupper(dechex($this->getBorderParametersDto()->color)); - while (strlen($hexColor) < 6) - { - $hexColor = "0" . $hexColor; - } - $hexColor = "#" . $hexColor; - return $hexColor; - } - catch (Exception $ex) - { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - /** - * Border color. - * Default value: #000000 - */ - public function setColor(string $hexValue): void - { - try - { - if(substr($hexValue, 0, 1) == '#') - $hexValue = substr($hexValue, 1, strlen($hexValue) - 1); - $this->getBorderParametersDto()->color = hexdec($hexValue); - } - catch (Exception $ex) - { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } -} - - -/** - * Image parameters. - */ -class ImageParameters implements Communicator -{ - private $imageParametersDto; - - private function getImageParametersDto(): ImageParametersDTO - { - return $this->imageParametersDto; - } - - private function setImageParametersDto(ImageParametersDTO $imageParametersDto): void - { - $this->imageParametersDto = $imageParametersDto; - } - - private $svg; - private $pdf; - - function __construct(ImageParametersDTO $imageParametersDto) - { - $this->imageParametersDto = $imageParametersDto; - $this->obtainDto(); - $this->initFieldsFromDto(); - } - - public function obtainDto(...$args) - { - } - - public function initFieldsFromDto(): void - { - $this->svg = new SvgParameters($this->getImageParametersDto()->svg); - $this->pdf = new PdfParameters($this->getImageParametersDto()->pdf); - } - - /** - * SVG parameters - */ - function getSvg() : SvgParameters - { - return $this->svg; - } - - /** - * SVG parameters - */ - function setSvg(SvgParameters $svg) : void - { - $this->svg = $svg; - $this->getImageParametersDto()->svg = $svg->getSvgParametersDto(); - } - - /** - *- * PDF parameters - *
- */ - function getPdf() - { - return $this->pdf; - } - /** - *- * PDF parameters - *
- */ - function setPdf(PdfParameters $value) - { - $this->pdf = $value; - $this->getImageParametersDto()->pdf = $value->getPdfParametersDto(); - } -} - -/** - * SVG parameters. - */ -class SvgParameters implements Communicator -{ - private $svgParametersDto; - - function getSvgParametersDto(): SvgParametersDTO - { - return $this->svgParametersDto; - } - - private function setSvgParametersDto(SvgParametersDTO $svgParametersDto): void - { - $this->svgParametersDto = $svgParametersDto; - } - - function __construct(SvgParametersDTO $svgParametersDto) - { - $this->svgParametersDto = $svgParametersDto; - $this->obtainDto(); - $this->initFieldsFromDto(); - } - - public function obtainDto(...$args) - { - } - - public function initFieldsFromDto(): void - { - } - - /** - * Does SVG image contain explicit size in pixels (recommended) - * Default value: true. - */ - function isExplicitSizeInPixels() : bool - { - return $this->getSvgParametersDto()->isExplicitSizeInPixels; - } - - /** - * Does SVG image contain explicit size in pixels (recommended) - * Default value: true. - */ - function setExplicitSizeInPixels(bool $explicitSizeInPixels) : void - { - $this->getSvgParametersDto()->isExplicitSizeInPixels = $explicitSizeInPixels; - } - - /** - * Does SVG image contain text as text element rather than paths (recommended) - * Default value: true. - */ - function isTextDrawnInTextElement() : bool - { - return $this->getSvgParametersDto()->isTextDrawnInTextElement; - } - - /** - * Does SVG image contain text as text element rather than paths (recommended) - * Default value: true. - */ - function setTextDrawnInTextElement(bool $isTextDrawnInTextElement) : void - { - $this->getSvgParametersDto()->isTextDrawnInTextElement = $isTextDrawnInTextElement; - } - - - /** - *- * Possible modes for filling color in svg file, RGB is default and supported by SVG 1.1. - * RGBA, HSL, HSLA is allowed in SVG 2.0 standard. - * Even in RGB opacity will be set through "fill-opacity" parameter - *
- */ - function setSvgColorMode(int $svgColorMode) : void - { - $this->getSvgParametersDto()->svgColorMode = $svgColorMode; - } - - - /** - * Possible modes for filling color in svg file, RGB is default and supported by SVG 1.1. - * RGBA, HSL, HSLA is allowed in SVG 2.0 standard. - * Even in RGB opacity will be set through "fill-opacity" parameter - */ - function getSvgColorMode() : int - { - return $this->getSvgParametersDto()->svgColorMode; - } -} - -/** - * PDF parameters wrapper. - * Expects an underlying `javaClass` instance that provides - * the corresponding getter/setter methods returning/accepting - * CMYK strings like "30_100_0_30" or `null`. - */ -class PdfParameters implements Communicator -{ - private $pdfParametersDto; - - function getPdfParametersDto(): PdfParametersDTO - { - return $this->pdfParametersDto; - } - - private function setPdfParametersDto(PdfParametersDTO $pdfParametersDto): void - { - $this->pdfParametersDto = $pdfParametersDto; - } - - function __construct(PdfParametersDTO $pdfParametersDto) - { - $this->pdfParametersDto = $pdfParametersDto; - $this->obtainDto(); - $this->initFieldsFromDto(); - } - - public function obtainDto(...$args) - { - } - - public function initFieldsFromDto(): void - { - } - /** - *- * Nullable. CMYK color value of bar code. Null means CMYK color is not used, instead normal RGB color is used. - *
- */ - function getCMYKBarColor() : CMYKColor - { - return CMYKColor::parseCMYK($this->getPdfParametersDto()->cmykBarColor); - } - /** - *- * Nullable. CMYK color value of bar code. Null means CMYK color is not used, instead normal RGB color is used. - *
- */ - function setCMYKBarColor(CMYKColor $value) : void - { - $this->getPdfParametersDto()->cmykBarColor = $value != null ? $value->formatCMYK() : null; - } - - /** - *- * Nullable. CMYK back color value. Null means CMYK color is not used, instead normal RGB color is used. - *
- */ - public function getCMYKBackColor() : CMYKColor - { - return CMYKColor::parseCMYK($this->getPdfParametersDto()->cmykBackColor); - } - /** - *- * Nullable. CMYK back color value. Null means CMYK color is not used, instead normal RGB color is used. - *
- */ - public function setCMYKBackColor(CMYKColor $value) : void - { - $this->getPdfParametersDto()->cmykBackColor = ($value != null ? $value->formatCMYK() : null); - } - - /** - *- * Nullable. CMYK color value of Codetext. Null means CMYK color is not used, instead normal RGB color is used. - *
- */ - public function getCMYKCodetextColor() : CMYKColor - { - return CMYKColor::parseCMYK($this->getPdfParametersDto()->cmykCodetextColor); - } - - /** - *- * Nullable. CMYK color value of Codetext. Null means CMYK color is not used, instead normal RGB color is used. - *
- */ - public function setCMYKCodetextColor(CMYKColor $value) : void - { - $this->getPdfParametersDto()->cmykCodetextColor = $value != null ? $value->formatCMYK() : null; - } - - /** - *- * Nullable. CMYK color value of caption above. Null means CMYK color is not used, instead normal RGB color is used. - *
- */ - public function getCMYKCaptionAboveColor() : CMYKColor - { - return CMYKColor::parseCMYK($this->getPdfParametersDto()->cmykCaptionAboveColor); - } - /** - *- * Nullable. CMYK color value of caption above. Null means CMYK color is not used, instead normal RGB color is used. - *
- */ - public function setCMYKCaptionAboveColor(CMYKColor $value) : void - { - $this->getPdfParametersDto()->cmykCaptionAboveColor = $value != null ? $value->formatCMYK() : null; - } - - /** - *- * Nullable. CMYK color value of caption below. Null means CMYK color is not used, instead normal RGB color is used. - *
- */ - public function getCMYKCaptionBelowColor() : CMYKColor - { - return CMYKColor::parseCMYK($this->getPdfParametersDto()->cmykCaptionBelowColor); - } - /** - *- * Nullable. CMYK color value of caption below. Null means CMYK color is not used, instead normal RGB color is used. - *
- */ - public function setCMYKCaptionBelowColor(CMYKColor $value) : void - { - $this->getPdfParametersDto()->cmykCaptionBelowColor = $value->formatCMYK(); - } - - /** - *- * Are paths used instead of text (use if Unicode characters are not displayed) - * Default value: false. - *
- */ - public function isTextAsPath() : bool - { - return $this->getPdfParametersDto()->textAsPath; - } - - /** - *- * Are paths used instead of text (use if Unicode characters are not displayed) - * Default value: false. - *
- */ - public function setTextAsPath(bool $value) : void - { - $this->getPdfParametersDto()->textAsPath = $value; - } -} - -/** - * Class for CMYK color. A null instance means CMYK is not used, - * and default RGB color is in use. - */ -class CMYKColor -{ - /** @var float Cyan component (0.0–1.0) */ - public float $C; - - /** @var float Magenta component (0.0–1.0) */ - public float $M; - - /** @var float Yellow component (0.0–1.0) */ - public float $Y; - - /** @var float Black component (0.0–1.0) */ - public float $K; - - /** - * Initializes a new instance of the CMYKColor class from CMYK values. - * CMYK values are expected in the range 0–100. - * - * @param int $c Cyan value [0, 100] - * @param int $m Magenta value [0, 100] - * @param int $y Yellow value [0, 100] - * @param int $k Black value [0, 100] - */ - public function __construct(int $c,int $m,int $y,int $k) - { - // Clamp to [0, 100] and store as fractions [0.0, 1.0] - $this->C = min(100, max(0, $c)) / 100.0; - $this->M = min(100, max(0, $m)) / 100.0; - $this->Y = min(100, max(0, $y)) / 100.0; - $this->K = min(100, max(0, $k)) / 100.0; - } - - /** - * Parse a CMYK string of the form "C_M_Y_K" into a CMYKColor instance. - * - * @param string $str a string like "30_100_0_30" - * @return CMYKColor - * @throws InvalidArgumentException if the format is invalid or values are not numeric - */ - public static function parseCMYK(string $str): CMYKColor - { - $parts = explode('_', $str); - if (count($parts) !== 4) { - throw new InvalidArgumentException("Invalid CMYK string: expected 4 parts but got " . count($parts)); - } - - $nums = []; - foreach ($parts as $i => $s) { - if (!is_numeric($s)) { - throw new InvalidArgumentException("Invalid number in CMYK string at index $i: \"$s\""); - } - // PHP does not auto-convert to float in this context - $nums[] = floatval($s); - } - - return new CMYKColor($nums[0], $nums[1], $nums[2], $nums[3]); - } - - /** - * Format this CMYKColor into a string "C_M_Y_K", - * multiplying each internal component (0–1) by 100 and rounding. - * - * @return string e.g. "30_100_0_30" - */ - public function formatCMYK(): string - { - $c = round($this->C * 100); - $m = round($this->M * 100); - $y = round($this->Y * 100); - $k = round($this->K * 100); - return "{$c}_{$m}_{$y}_{$k}"; - } - - /** - * Optional: a human-readable representation. - * - * @return string - */ - public function __toString(): string - { - $c = round($this->C * 100); - $m = round($this->M * 100); - $y = round($this->Y * 100); - $k = round($this->K * 100); - return "CMYKColor(C={$c}%, M={$m}%, Y={$y}%, K={$k}%)"; - } -} - -/** - *- * Class for representing HSLA color (Hue, Saturation, Lightness, Alpha) - *
- */ -class HslaColor -{ - /** - *- * Hue [0, 360] - *
- */ - public $H; - - /** - *- * Saturation [0, 100] - *
- */ - public $S; - - /** - *- * Lightness [0, 100] - *
- */ - public $L; - - /** - *- * Alpha (opacity) [0.0f, 1.0f] - *
- */ - public $A = 0.0; - - - /** - *- * Constructor for HslaColor - *
- * - * @param $h Hue [0, 360] - * @param $s Saturation [0, 100] - * @param $l Lightness [0, 100] - * @param $a Alpha (opacity) [0.0f, 1.0f] - */ - public function __construct(int $h, int $s, int $l, float $a) { -// $this->checkHue($h); - self::checkHue($h); - self::checkSatLight($s); - self::checkSatLight($l); - self::checkAlpha($a); - - $this->H = $h; - $this->S = $s; - $this->L = $l; - $this->A = $a; - } - - private static function checkHue(int $value) - { - if ($value < 0 || $value > 360) { - throw new Exception("Wrong color value"); - } - } - - private static function checkSatLight(int $value) - { - if ($value < 0 || $value > 100) { - throw new Exception("Wrong color value"); - } - } - - private static function checkAlpha(float $value) - { - if ($value < 0.0 || $value > 1.0) - { - throw new Exception("Wrong color value"); - } - } - - /** - *- * Uses https://en.wikipedia.org/wiki/HSL_and_HSV#HSL_to_RGB - *
- * - * @param hslaColor HSLA color to convert - * @return string with RGBA values - */ - public static function convertHslaToRgba(HslaColor $hslaColor) : string - { - $r = 0; $g = 0; $b = 0; - - $hueF = $hslaColor->H / 360.0; - $satF = $hslaColor->S / 100.0; - $lightF = $hslaColor->L / 100.0; - - if ($satF == 0) { - $r = $g = $b = $lightF; - } else { - $q = $lightF < 0.5 ? $lightF * (1 + $satF) : $lightF + $satF - $lightF * $satF; - $p = 2 * $lightF - $q; - - $r = HslaColor::hueToRgb($p, $q, $hueF + 1.0 / 3.0); - $g = HslaColor::hueToRgb($p, $q, $hueF); - $b = HslaColor::hueToRgb($p, $q, $hueF - 1.0 / 3.0); - } - - $rI = intval($r * 255 + 0.5); - $gI = intval($g * 255 + 0.5); - $bI = intval($b * 255 + 0.5); - $aI = intval($hslaColor->A * 255 + 0.5); - - return sprintf("#%02X%02X%02X%02X", $rI, $gI, $bI, $aI); - } - - private static function hueToRgb(float $p, float $q, float $t) : float - { - if ($t < 0.0) $t += 1.0; - if ($t > 1.0) $t -= 1.0; - if ($t < 1.0 / 6.0) return $p + ($q - $p) * 6.0 * $t; - if ($t < 1.0 / 2.0) return $q; - if ($t < 2.0 / 3.0) return $p + ($q - $p) * (2.0 / 3.0 - $t) * 6.0; - return $p; - } -} - - -/** - * Helper class for automatic codetext generation of the Extended Codetext Mode - */ -abstract class ExtCodetextBuilder -{ - protected $_list; - - function __construct() - { - $this->_list = array(); - } - - function init(): void - { - } - - /** - * Clears extended codetext items - */ - public function clear(): void - { - try - { - array_splice($this->_list, 0); - } - catch (Exception $ex) - { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - /** - * Adds plain codetext to the extended codetext items - * - * @param string $codetext Codetext in unicode to add as extended codetext item - */ - public function addPlainCodetext(string $codetext): void - { - try - { - $extCodeItemDTO = new \Aspose\Barcode\Bridge\ExtCodeItemDTO(); - $extCodeItemDTO->extCodeItemType = ExtCodeItemType::PLAIN_CODETEXT; - $extCodeItemDTO->arguments = array($codetext); - array_push($this->_list, $extCodeItemDTO); - } - catch (Exception $ex) - { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - /** - * Adds codetext with Extended Channel Identifier - * - * @param int ECIEncoding Extended Channel Identifier - * @param string codetext Codetext in unicode to add as extended codetext item with Extended Channel Identifier - */ - public function addECICodetext(int $ECIEncoding, string $codetext): void - { - try - { - $extCodeItemDTO = new \Aspose\Barcode\Bridge\ExtCodeItemDTO(); - $extCodeItemDTO->extCodeItemType = ExtCodeItemType::ECI_CODETEXT; - $extCodeItemDTO->arguments = array($ECIEncoding, $codetext); - array_push($this->_list, $extCodeItemDTO); - } - catch (Exception $ex) - { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - /** - * Generate extended codetext from generation items list - * - * @return string Return string of extended codetext - */ - public final function getExtendedCodetext(): string - { - try - { - $thriftConnection = new ThriftConnection(); - $client = $thriftConnection->openConnection(); - $extendedCodetext = $client->ExtCodetextBuilder_getExtendedCodetext($this->getExtCodetextBuilderType(), $this->_list); - $thriftConnection->closeConnection(); - return $extendedCodetext; - } - catch (Exception $ex) - { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - protected abstract function getExtCodetextBuilderType() : int; -} - -/** - * Extended codetext generator for 2D QR barcodes for ExtendedCodetext Mode of QREncodeMode - * Use Display2DText property of BarCodeBuilder to set visible text to removing managing characters. - * - * Example how to generate FNC1 first position for Extended Mode - * @code - * //create codetext - * $lTextBuilder = new QrExtCodetextBuilder(); - * $lTextBuilder->addFNC1FirstPosition(); - * $lTextBuilder->addPlainCodetext("000%89%%0"); - * $lTextBuilder->addFNC1GroupSeparator(); - * $lTextBuilder->addPlainCodetext("12345<FNC1>"); - * //generate codetext - * $lCodetext = lTextBuilder->getExtendedCodetext(); - * @endcode - * - * Example how to generate FNC1 second position for Extended Mode - * @code - * //create codetext - * $lTextBuilder = new QrExtCodetextBuilder(); - * $lTextBuilder->addFNC1SecondPosition("12"); - * $lTextBuilder->addPlainCodetext("TRUE3456"); - * //generate codetext - * $lCodetext = lTextBuilder->getExtendedCodetext(); - * @endcode - * - * Example how to generate multi ECI mode for Extended Mode - * @code - * //create codetext - * $lTextBuilder = new QrExtCodetextBuilder(); - * $lTextBuilder->addECICodetext(ECIEncodings::Win1251, "Will"); - * $lTextBuilder->addECICodetext(ECIEncodings::UTF8, "Right"); - * $lTextBuilder->addECICodetext(ECIEncodings::UTF16BE, "Power"); - * $lTextBuilder->addPlainCodetext("t\\e\\\\st"); - * //generate codetext - * $lCodetext = $lTextBuilder->getExtendedCodetext(); - * @endcode - */ -class QrExtCodetextBuilder extends ExtCodetextBuilder -{ - function __construct() - { - try - { - parent::__construct(); - } - catch (Exception $ex) - { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - function init(): void - { - } - - /** - * Adds FNC1 in first position to the extended codetext items - */ - function addFNC1FirstPosition(): void - { - try - { - $extCodeItemDTO = new \Aspose\Barcode\Bridge\ExtCodeItemDTO(); - $extCodeItemDTO->extCodeItemType = ExtCodeItemType::FNC_1_FIRST_POSITION; - $extCodeItemDTO->arguments = array(); - array_push($this->_list, $extCodeItemDTO); - } - catch (Exception $ex) - { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - /** - * Adds FNC1 in second position to the extended codetext items - * - * @param string $codetext Value of the FNC1 in the second position - */ - function addFNC1SecondPosition(string $codetext): void - { - try - { - $extCodeItemDTO = new \Aspose\Barcode\Bridge\ExtCodeItemDTO(); - $extCodeItemDTO->extCodeItemType = ExtCodeItemType::FNC_1_SECOND_POSITION; - $extCodeItemDTO->arguments = array($codetext); - array_push($this->_list, $extCodeItemDTO); - } - catch (Exception $ex) - { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - /** - * Adds Group Separator (GS - '\\u001D') to the extended codetext items - */ - function addFNC1GroupSeparator(): void - { - try - { - $extCodeItemDTO = new \Aspose\Barcode\Bridge\ExtCodeItemDTO(); - $extCodeItemDTO->extCodeItemType = ExtCodeItemType::FNC_1_GROUP_SEPARATOR; - $extCodeItemDTO->arguments = array(); - array_push($this->_list, $extCodeItemDTO); - } - catch (Exception $ex) - { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - protected function getExtCodetextBuilderType() : int - { - return ExtCodetextBuilderType::QR_EXT_CODETEXT_BUILDER; - } -} - -/** - *- *
Extended codetext generator for Aztec barcodes for ExtendedCodetext Mode of AztecEncodeMode
- *Use TwoDDisplayText property of BarcodeGenerator to set visible text to removing managing characters.
- *- * This sample shows how to use AztecExtCodetextBuilder in Extended Mode. - *- * @code - * //create codetext - * $textBuilder = new AztecExtCodetextBuilder(); - * $textBuilder->addECICodetext(ECIEncodings::Win1251, "Will"); - * $textBuilder->addECICodetext(ECIEncodings::UTF8, "犬Right狗"); - * $textBuilder->addECICodetext(ECIEncodings::UTF16BE, "犬Power狗"); - * $textBuilder->addPlainCodetext("Plain text"); - * //generate codetext - * $codetext = $textBuilder->getExtendedCodetext(); - * //generate - * $generator = new BarcodeGenerator(EncodeTypes::AZTEC, $codetext); - * $generator->getParameters()->getBarcode()->getCodeTextParameters()->setwoDDisplayText("My Text"); - * $generator->save("test.bmp", BarcodeImageFormat::BMP); - */ -class AztecExtCodetextBuilder extends ExtCodetextBuilder -{ - function __construct() - { - try - { - parent::__construct(); - } - catch (Exception $ex) - { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - public function init() : void - { - } - - protected function getExtCodetextBuilderType() : int - { - return ExtCodetextBuilderType::AZTEC_EXT_CODETEXT_BUILDER; - } -} - -/** - *- *
Extended codetext generator for 2D DataMatrix barcodes for ExtendedCodetext Mode of DataMatrixEncodeMode
- *- */ -class DataMatrixExtCodetextBuilder extends ExtCodetextBuilder -{ - function __construct() - { - try - { - parent::__construct(); - } - catch (Exception $ex) - { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - function init(): void - { - } - /** - *- *- * //Extended codetext mode - * //create codetext - * $textBuilder = new DataMatrixExtCodetextBuilder(); - * $codetextBuilder->addECICodetextWithEncodeMode(ECIEncodings::Win1251, DataMatrixEncodeMode::BYTES, "World"); - * $codetextBuilder->addPlainCodetext("Will"); - * $codetextBuilder->addECICodetext(ECIEncodings::UTF_8, "犬Right狗"); - * $codetextBuilder->addCodetextWithEncodeMode(DataMatrixEncodeMode::C_40, "ABCDE"); - * //generate codetext - * $codetext = $textBuilder->getExtendedCodetext(); - * //generate - * $generator = new BarcodeGenerator(EncodeTypes::DATA_MATRIX, null, $codetext); - * $generator->getParameters()->getBarcode()->getDataMatrix()->setDataMatrixEncodeMode(DataMatrixEncodeMode::EXTENDED_CODETEXT); - * $generator->save("test.bmp", BarcodeImageFormat::BMP); - *- *- * Adds codetext with Extended Channel Identifier with defined encode mode - *
- * @param ECIEncoding Extended Channel Identifier - * @param encodeMode Encode mode value - * @param codetext Codetext in unicode to add as extended codetext item with Extended Channel Identifier with defined encode mode - */ - public function addECICodetextWithEncodeMode(int $ECIEncoding, int $encodeMode, string $codetext) : void - { - $extCodeItemDTO = new \Aspose\Barcode\Bridge\ExtCodeItemDTO(); - $extCodeItemDTO->extCodeItemType = ExtCodeItemType::ECI_CODETEXT_WITH_ENCODE_MODE; - $extCodeItemDTO->arguments = array($ECIEncoding, $encodeMode, $codetext); - array_push($this->_list, $extCodeItemDTO); - } - - /** - *- * Adds codetext with defined encode mode to the extended codetext items - *
- * @param encodeMode Encode mode value - * @param codetext Codetext in unicode to add as extended codetext item - */ - public function addCodetextWithEncodeMode(int $encodeMode, string $codetext) : void - { - $extCodeItemDTO = new \Aspose\Barcode\Bridge\ExtCodeItemDTO(); - $extCodeItemDTO->extCodeItemType = ExtCodeItemType::CODETEXT_WITH_ENCODE_MODE; - $extCodeItemDTO->arguments = array($encodeMode, $codetext); - array_push($this->_list, $extCodeItemDTO); - } - - protected function getExtCodetextBuilderType() : int - { - return ExtCodetextBuilderType::DATA_MATRIX_EXT_CODETEXT_BUILDER; - } -} - -/** - *- *
Extended codetext generator for 2D DotCode barcodes for ExtendedCodetext Mode of DotCodeEncodeMode
- *- */ -class DotCodeExtCodetextBuilder extends ExtCodetextBuilder -{ - function __construct() - { - try - { - parent::__construct(); - } - catch (Exception $ex) - { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - /** - *- *- * - * //Extended codetext mode - * //create codetext - * $textBuilder = new DotCodeExtCodetextBuilder(); - * $textBuilder->addFNC1FormatIdentifier(); - * $textBuilder->addECICodetext(ECIEncodings::Win1251, "Will"); - * $textBuilder->addFNC1FormatIdentifier(); - * $textBuilder->addECICodetext(ECIEncodings::UTF8, "犬Right狗"); - * $textBuilder->addFNC1FormatIdentifier(); - * $textBuilder->addECICodetext(ECIEncodings::UTF16BE, "犬Power狗"); - * $textBuilder->addPlainCodetext("Plain text"); - * $textBuilder->addFNC3SymbolSeparator(); - * $textBuilder->addFNC3ReaderInitialization(); - * $textBuilder->addPlainCodetext("Reader initialization info"); - * //generate codetext - * $codetext = $textBuilder->getExtendedCodetext(); - * //generate - * $generator = new BarcodeGenerator(EncodeTypes::DOT_CODE, $codetext); - * { - * $generator->getParameters()->getBarcode()->getDotCode()->setDotCodeEncodeMode(DotCodeEncodeMode::EXTENDED_CODETEXT); - * $generator->save("test.bmp", BarCodeImageFormat::BMP); - * } - *- *- * Adds FNC1 format identifier to the extended codetext items - *
- */ - public function addFNC1FormatIdentifier() : void - { - $extCodeItemDTO = new \Aspose\Barcode\Bridge\ExtCodeItemDTO(); - $extCodeItemDTO->extCodeItemType = ExtCodeItemType::FNC_1_FORMAT_IDENTIFIER; - $extCodeItemDTO->arguments = array(); - array_push($this->_list, $extCodeItemDTO); - } - - /** - *- * Adds FNC3 symbol separator to the extended codetext items - *
- */ - public function addFNC3SymbolSeparator() : void - { - $extCodeItemDTO = new \Aspose\Barcode\Bridge\ExtCodeItemDTO(); - $extCodeItemDTO->extCodeItemType = ExtCodeItemType::FNC_3_SYMBOL_SEPARATOR; - $extCodeItemDTO->arguments = array(); - array_push($this->_list, $extCodeItemDTO); - } - - /** - *- * Adds FNC3 reader initialization to the extended codetext items - *
- */ - public function addFNC3ReaderInitialization() : void - { - $extCodeItemDTO = new \Aspose\Barcode\Bridge\ExtCodeItemDTO(); - $extCodeItemDTO->extCodeItemType = ExtCodeItemType::FNC_3_RRADER_INITILIZATION; - $extCodeItemDTO->arguments = array(); - array_push($this->_list, $extCodeItemDTO); - } - - /** - *- * Adds structured append mode to the extended codetext items - *
- * @param int barcodeId ID of barcode - * @param int barcodesCount Barcodes count - */ - public function addStructuredAppendMode(int $barcodeId, int $barcodesCount) : void - { - $extCodeItemDTO = new \Aspose\Barcode\Bridge\ExtCodeItemDTO(); - $extCodeItemDTO->extCodeItemType = ExtCodeItemType::STRUCTURE_APPEND_MODE; - $extCodeItemDTO->arguments = array($barcodeId, $barcodesCount); - array_push($this->_list, $extCodeItemDTO); - } - - protected function getExtCodetextBuilderType() : int - { - return ExtCodetextBuilderType::DOT_CODE_EXT_CODETEXT_BUILDER; - } - - public function init() : void {} -} - -/** - * Extended codetext generator for MaxiCode barcodes for ExtendedCodetext Mode of MaxiCodeEncodeMode - * Use TwoDDisplayText property of BarcodeGenerator to set visible text to removing managing characters. - * - * This sample shows how to use MaxiCodeExtCodetextBuilder in Extended Mode. - * - * @code - * //create codetext - * $textBuilder = new MaxiCodeExtCodetextBuilder(); - * $textBuilder->addECICodetext(ECIEncodings::Win1251, "Will"); - * $textBuilder->addECICodetext(ECIEncodings::UTF8, "犬Right狗"); - * $textBuilder->addECICodetext(ECIEncodings::UTF16BE, "犬Power狗"); - * $textBuilder->addPlainCodetext("Plain text"); - * - * //generate codetext - * $codetext = $textBuilder->getExtendedCodetext(); - * - * //generate - * $generator = new BarcodeGenerator(EncodeTypes::MAXI_CODE, $codetext); - * $generator->getParameters()->getBarcode()->getCodeTextParameters()->setTwoDDisplayText("My Text"); - * $generator->save("test.bmp", BarcodeImageFormat.BMP); - * @endcode - */ -class MaxiCodeExtCodetextBuilder extends ExtCodetextBuilder -{ - function __construct() - { - try - { - parent::__construct(); - } - catch (Exception $ex) - { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - function init(): void - { - } - - protected function getExtCodetextBuilderType() : int - { - return ExtCodetextBuilderType::MAXICODE_EXT_CODETEXT_BUILDER; - } -} - -class HanXinExtCodetextBuilderType -{ - const ECI = 0; - const Auto = 1; - const Binary = 2; - const URI = 3; - const Text = 4; - const Numeric = 5; - const Unicode = 6; - const CommonChineseRegionOne = 7; - const CommonChineseRegionTwo = 8; - const GB18030TwoByte = 9; - const GB18030FourByte = 10; - const GS1 = 11; -} - -/** - *- *
Extended codetext generator for Han Xin Code for Extended Mode of HanXinEncodeMode
- *- */ -class HanXinExtCodetextBuilder -{ - - protected $_list; - function __construct() - { - $this->_list = array(); - } - - function init(): void - { - } - - /** - *- *- * - * //Extended codetext mode - * //create codetext - * $codeTextBuilder = new HanXinExtCodetextBuilder(); - * $codeTextBuilder->addGB18030TwoByte("漄"); - * $codeTextBuilder->addGB18030FourByte("㐁"); - * $codeTextBuilder->addCommonChineseRegionOne("全"); - * $codeTextBuilder->addCommonChineseRegionTwo("螅"); - * $codeTextBuilder->addNumeric("123"); - * $codeTextBuilder->addText("qwe"); - * $codeTextBuilder->addUnicode("ıntəˈnæʃənəl"); - * $codeTextBuilder->addECI("ΑΒΓΔΕ", 9); - * $codeTextBuilder->addAuto("abc"); - * $codeTextBuilder->addBinary("abc"); - * $codeTextBuilder->addURI("backslashes_should_be_doubled\000555:test"); - * $codeTextBuilder->addGS1("(01)03453120000011(17)191125(10)ABCD1234(21)10"); - * $expectedStr = "漄㐁全螅123qweıntəˈnæʃənəlΑΒΓΔΕabcabcbackslashes_should_be_doubled\000555:test(01)03453120000011(17)191125(10)ABCD1234(21)10"; - * //generate codetext - * $str = $codeTextBuilder->getExtendedCodetext(); - * //generate - * $bg = new BarcodeGenerator(EncodeTypes::HAN_XIN, $str); - * $bg->getParameters()->getBarcode()->getHanXin()->setHanXinEncodeMode(HanXinEncodeMode::EXTENDED); - * $img = $bg->generateBarCodeImage(BarcodeImageFormat::PNG); - * $r = new BarCodeReader($img, null, DecodeType::HAN_XIN)) - * $found = $r->readBarCodes(); - * Assert::assertEquals(1, sizeof(found)); - * Assert::assertEquals($expectedStr, $found[0]->getCodeText()); - *- *- * Adds codetext fragment in ECI mode - *
- * @param string text Codetext string - * @param int encoding ECI encoding in integer format - */ - public function addECI(string $text, int $encoding) : void - { - $extCodeItemDTO = new ExtCodeItemDTO(); - $extCodeItemDTO->extCodeItemType = HanXinExtCodetextBuilderType::ECI; - $extCodeItemDTO->arguments = array($text, $encoding); - $this->_list[] = $extCodeItemDTO; - } - - /** - *- * Adds codetext fragment in Auto mode - *
- * @param string text Codetext string - */ - public function addAuto(string $text) : void - { - $extCodeItemDTO = new \Aspose\Barcode\Bridge\ExtCodeItemDTO(); - $extCodeItemDTO->extCodeItemType = HanXinExtCodetextBuilderType::Auto; - $extCodeItemDTO->arguments = array($text); - array_push($this->_list, $extCodeItemDTO); - } - - /** - *- * Adds codetext fragment in Binary mode - *
- * @param text Codetext string - */ - public function addBinary(string $text) : void - { - $extCodeItemDTO = new \Aspose\Barcode\Bridge\ExtCodeItemDTO(); - $extCodeItemDTO->extCodeItemType = HanXinExtCodetextBuilderType::Binary; - $extCodeItemDTO->arguments = array($text); - array_push($this->_list, $extCodeItemDTO); - } - - /** - *- * Adds codetext fragment in URI mode - *
- * @param text Codetext string - */ - public function addURI(string $text) : void - { - $extCodeItemDTO = new \Aspose\Barcode\Bridge\ExtCodeItemDTO(); - $extCodeItemDTO->extCodeItemType = HanXinExtCodetextBuilderType::URI; - $extCodeItemDTO->arguments = array($text); - array_push($this->_list, $extCodeItemDTO); - } - - /** - *- * Adds codetext fragment in Text mode - *
- * @param text Codetext string - */ - public function addText(string $text) : void - { - $extCodeItemDTO = new \Aspose\Barcode\Bridge\ExtCodeItemDTO(); - $extCodeItemDTO->extCodeItemType = HanXinExtCodetextBuilderType::Text; - $extCodeItemDTO->arguments = array($text); - array_push($this->_list, $extCodeItemDTO); - } - - /** - *- * Adds codetext fragment in Numeric mode - *
- * @param text Codetext string - */ - public function addNumeric(string $text) : void - { - $extCodeItemDTO = new \Aspose\Barcode\Bridge\ExtCodeItemDTO(); - $extCodeItemDTO->extCodeItemType = HanXinExtCodetextBuilderType::Numeric; - $extCodeItemDTO->arguments = array($text); - array_push($this->_list, $extCodeItemDTO); - } - - /** - *- * Adds codetext fragment in Unicode mode - *
- * @param text Codetext string - */ - public function addUnicode(string $text) : void - { - $extCodeItemDTO = new \Aspose\Barcode\Bridge\ExtCodeItemDTO(); - $extCodeItemDTO->extCodeItemType = HanXinExtCodetextBuilderType::Unicode; - $extCodeItemDTO->arguments = array($text); - array_push($this->_list, $extCodeItemDTO); - } - - /** - *- * Adds codetext fragment in Common Chinese Region One mode - *
- * @param text Codetext string - */ - public function addCommonChineseRegionOne(string $text) : void - { - $extCodeItemDTO = new \Aspose\Barcode\Bridge\ExtCodeItemDTO(); - $extCodeItemDTO->extCodeItemType = HanXinExtCodetextBuilderType::CommonChineseRegionOne; - $extCodeItemDTO->arguments = array($text); - array_push($this->_list, $extCodeItemDTO); - } - - /** - *- * Adds codetext fragment in Common Chinese Region Two mode - *
- * @param text Codetext string - */ - public function addCommonChineseRegionTwo(string $text) : void - { - $extCodeItemDTO = new \Aspose\Barcode\Bridge\ExtCodeItemDTO(); - $extCodeItemDTO->extCodeItemType = HanXinExtCodetextBuilderType::CommonChineseRegionTwo; - $extCodeItemDTO->arguments = array($text); - array_push($this->_list, $extCodeItemDTO); - } - - /** - *- * Adds codetext fragment in GB18030 Two Byte mode - *
- * @param text Codetext string - */ - public function addGB18030TwoByte(string $text) : void - { - $extCodeItemDTO = new \Aspose\Barcode\Bridge\ExtCodeItemDTO(); - $extCodeItemDTO->extCodeItemType = HanXinExtCodetextBuilderType::GB18030TwoByte; - $extCodeItemDTO->arguments = array($text); - array_push($this->_list, $extCodeItemDTO); - } - - /** - *- * Adds codetext fragment in GB18030 Four Byte mode - *
- * @param text Codetext string - */ - public function addGB18030FourByte(string $text) : void - { - $extCodeItemDTO = new \Aspose\Barcode\Bridge\ExtCodeItemDTO(); - $extCodeItemDTO->extCodeItemType = HanXinExtCodetextBuilderType::GB18030FourByte; - $extCodeItemDTO->arguments = array($text); - array_push($this->_list, $extCodeItemDTO); - } - - /** - *- * Adds codetext fragment in GS1 mode - *
- * @param text Codetext string - */ - public function addGS1(string $text) : void - { - $extCodeItemDTO = new \Aspose\Barcode\Bridge\ExtCodeItemDTO(); - $extCodeItemDTO->extCodeItemType = HanXinExtCodetextBuilderType::GS1; - $extCodeItemDTO->arguments = array($text); - array_push($this->_list, $extCodeItemDTO); - } - - /** - *- * Returns codetext from Extended mode codetext builder - *
- * @return string Codetext in Extended mode - */ - public function getExtendedCodetext() : string - { - try - { - $thriftConnection = new ThriftConnection(); - $client = $thriftConnection->openConnection(); - $extendedCodetext = $client->HanXinExtCodetextBuilder_getExtendedCodetext($this->_list); - $thriftConnection->closeConnection(); - return $extendedCodetext; - } - catch (Exception $ex) - { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } -} - -class ExtCodetextBuilderType -{ - const AZTEC_EXT_CODETEXT_BUILDER = 0; - const DATA_MATRIX_EXT_CODETEXT_BUILDER = 1; - const DOT_CODE_EXT_CODETEXT_BUILDER = 2; - const MAXICODE_EXT_CODETEXT_BUILDER = 3; - const QR_EXT_CODETEXT_BUILDER = 4; -} - -class ExtCodeItemType -{ - const ECI_CODETEXT = 0; - const PLAIN_CODETEXT = 1; - const FNC_1_FIRST_POSITION = 3; - const FNC_1_SECOND_POSITION = 4; - const FNC_1_GROUP_SEPARATOR = 5; - const ECI_CODETEXT_WITH_ENCODE_MODE = 6; - const CODETEXT_WITH_ENCODE_MODE = 7; - const FNC_1_FORMAT_IDENTIFIER = 8; - const FNC_3_SYMBOL_SEPARATOR = 9; - const FNC_3_RRADER_INITILIZATION = 10; - const STRUCTURE_APPEND_MODE = 11; -} - -/** - * Specifies style information applied to text. - */ -final class FontStyle -{ - /** - * Normal text - */ - const REGULAR = 0; - /** - * Bold text - */ - const BOLD = 1; - /** - * Italic text - */ - const ITALIC = 2; - /** - * Underlined text - */ - const UNDERLINE = 4; - /** - * Text with a line through the middle - */ - const STRIKEOUT = 8; -} - -/** - * Specifies the style of dashed border lines. - */ -class BorderDashStyle -{ - /** - * Specifies a solid line. - */ - const SOLID = 0; //DashStyle.Solid - /** - * Specifies a line consisting of dashes. - */ - const DASH = 1; // DashStyle.Dash - /** - * Specifies a line consisting of dots. - */ - const DOT = 2; //(DashStyle.Dot - - /** - * Specifies a line consisting of a repeating pattern of dash-dot. - */ - const DASH_DOT = 3; //DashStyle.DashDot - /** - * Specifies a line consisting of a repeating pattern of dash-dot-dot. - */ - const DASH_DOT_DOT = 4; //DashStyle.DashDotDot -} - -/** - * PatchCode format. Choose PatchOnly to generate single PatchCode. Use page format to generate Patch page with PatchCodes as borders - */ -final class PatchFormat -{ - /** - * Generates PatchCode only - */ - const PATCH_ONLY = 0; - - /** - * Generates A4 format page with PatchCodes as borders and optional QR in the center - */ - const A4 = 1; - - /** - * Generates A4 landscape format page with PatchCodes as borders and optional QR in the center - */ - const A4_LANDSCAPE = 2; - - /** - * Generates US letter format page with PatchCodes as borders and optional QR in the center - */ - const US_LETTER = 3; - - /** - * Generates US letter landscape format page with PatchCodes as borders and optional QR in the center - */ - const US_LETTER_LANDSCAPE = 4; -} - -/** - * Encoding mode for MaxiCode barcodes. - * - * This sample shows how to genereate MaxiCode barcodes using ComplexBarcodeGenerator - * @code - * //Mode 2 with standart second message - * $maxiCodeCodetext = new MaxiCodeCodetextMode2(); - * $maxiCodeCodetext->setPostalCode("524032140"); - * $maxiCodeCodetext->setCountryCode(056); - * $maxiCodeCodetext->setServiceCategory(999); - * maxiCodeStandartSecondMessage = new MaxiCodeStandartSecondMessage(); - * $maxiCodeStandartSecondMessage->setMessage("Test message"); - * $maxiCodeCodetext->setSecondMessage($maxiCodeStandartSecondMessage); - * $complexGenerator = new ComplexBarcodeGenerator($maxiCodeCodetext); - * $complexGenerator->generateBarCodeImage(BarcodeImageFormat::PNG); - * - * //Mode 2 with structured second message - * $maxiCodeCodetext = new MaxiCodeCodetextMode2(); - * $maxiCodeCodetext->setPostalCode("524032140"); - * $maxiCodeCodetext->setCountryCode(056); - * $maxiCodeCodetext->setServiceCategory(999); - * maxiCodeStructuredSecondMessage = new MaxiCodeStructuredSecondMessage(); - * $maxiCodeStructuredSecondMessage->add("634 ALPHA DRIVE"); - * $maxiCodeStructuredSecondMessage->add("PITTSBURGH"); - * $maxiCodeStructuredSecondMessage->add("PA"); - * $maxiCodeStructuredSecondMessage->setYear(99); - * $maxiCodeCodetext->setSecondMessage($maxiCodeStructuredSecondMessage); - * $complexGenerator = new ComplexBarcodeGenerator($maxiCodeCodetext); - * $complexGenerator->generateBarCodeImage(BarcodeImageFormat::PNG); - * - * //Mode 3 with standart second message - * $maxiCodeCodetext = new MaxiCodeCodetextMode3(); - * $maxiCodeCodetext->setPostalCode("B1050"); - * $maxiCodeCodetext->setCountryCode(056); - * $maxiCodeCodetext->setServiceCategory(999); - * $maxiCodeStandartSecondMessage = new MaxiCodeStandartSecondMessage(); - * $maxiCodeStandartSecondMessage->setMessage("Test message"); - * $maxiCodeCodetext->setSecondMessage($maxiCodeStandartSecondMessage); - * $complexGenerator = new ComplexBarcodeGenerator($maxiCodeCodetext); - * $complexGenerator->generateBarCodeImage(BarcodeImageFormat::PNG); - * - * //Mode 3 with structured second message - * $maxiCodeCodetext = new MaxiCodeCodetextMode3(); - * $maxiCodeCodetext->setPostalCode("B1050"); - * $maxiCodeCodetext->setCountryCode(056); - * $maxiCodeCodetext->setServiceCategory(999); - * $maxiCodeStructuredSecondMessage = new MaxiCodeStructuredSecondMessage(); - * $maxiCodeStructuredSecondMessage->add("634 ALPHA DRIVE"); - * $maxiCodeStructuredSecondMessage->add("PITTSBURGH"); - * $maxiCodeStructuredSecondMessage->add("PA"); - * $maxiCodeStructuredSecondMessage->setYear(99); - * $maxiCodeCodetext->setSecondMessage($maxiCodeStructuredSecondMessage); - * $complexGenerator = new ComplexBarcodeGenerator($maxiCodeCodetext->getConstructedCodetext(); - * $complexGenerator->generateBarCodeImage(BarcodeImageFormat::PNG); - * - * //Mode 4 - * $maxiCodeCodetext = new MaxiCodeStandardCodetext(); - * $maxiCodeCodetext->setMode(MaxiCodeMode::MODE_4); - * $maxiCodeCodetext->setMessage("Test message"); - * $complexGenerator = new ComplexBarcodeGenerator($maxiCodeCodetext->getConstructedCodetext(); - * $complexGenerator->generateBarCodeImage(BarcodeImageFormat::PNG); - * - * //Mode 5 - * $maxiCodeCodetext = new MaxiCodeStandardCodetext(); - * $maxiCodeCodetext->setMode(MaxiCodeMode::MODE_5); - * $maxiCodeCodetext->setMessage("Test message"); - * $complexGenerator = new ComplexBarcodeGenerator($maxiCodeCodetext->getConstructedCodetext()) - * $complexGenerator->generateBarCodeImage(BarcodeImageFormat::PNG); - * - * //Mode 6 - * $maxiCodeCodetext = new MaxiCodeStandardCodetext(); - * $maxiCodeCodetext->setMode(MaxiCodeMode::MODE_6); - * $maxiCodeCodetext->setMessage("Test message"); - * $complexGenerator = new ComplexBarcodeGenerator($maxiCodeCodetext->getConstructedCodetext(); - * $complexGenerator->generateBarCodeImage(BarcodeImageFormat::PNG); - * @endcode - */ -class MaxiCodeMode -{ - /** - * Mode 2 encodes postal information in first message and data in second message. - * Has 9 digits postal code (used only in USA). - */ - const MODE_2 = 2; - - /** - * Mode 3 encodes postal information in first message and data in second message. - * Has 6 alphanumeric postal code, used in the world. - */ - const MODE_3 = 3; - - /** - * Mode 4 encodes data in first and second message, with short ECC correction. - */ - const MODE_4 = 4; - - /** - * Mode 5 encodes data in first and second message, with long ECC correction. - */ - const MODE_5 = 5; - - /** - * Mode 6 encodes data in first and second message, with short ECC correction. - * Used to encode device. - */ - const MODE_6 = 6; -} - -/** - * - * Specifies the start or stop symbol of the Codabar barcode specification. - */ -final class CodabarSymbol -{ - private function __construct() - { - } - - /** - * Specifies character A as the start or stop symbol of the Codabar barcode specification. - */ - const A = 65; - /** - * Specifies character B as the start or stop symbol of the Codabar barcode specification. - */ - const B = 66; - /** - * Specifies character C as the start or stop symbol of the Codabar barcode specification. - */ - const C = 67; - /** - * Specifies character D as the start or stop symbol of the Codabar barcode specification. - */ - const D = 68; -} - -/** - * Specifies the checksum algorithm for Codabar - */ -class CodabarChecksumMode -{ - - /** - * Specifies Mod 10 algorithm for Codabar. - */ - const MOD_10 = "0"; - - /** - * Specifies Mod 16 algorithm for Codabar (recomended AIIM). - */ - const MOD_16 = "1"; -} - -/** - * ITF14 barcode's border type - */ -class ITF14BorderType -{ - /** - * NO border enclosing the barcode - */ - const NONE = "0"; - /** - * FRAME enclosing the barcode - */ - const FRAME = "1"; - /** - * Tow horizontal bars enclosing the barcode - */ - const BAR = "2"; - /** - * FRAME enclosing the barcode - */ - const FRAME_OUT = "3"; - /** - * Tow horizontal bars enclosing the barcode - */ - const BAR_OUT = "4"; -} - -/** - * Macro Characters 05 and 06 values are used to obtain more compact encoding in special modes. - * 05 Macro craracter is translated to "[)>\u001E05\u001D" as decoded data header and "\u001E\u0004" as decoded data trailer. - * 06 Macro craracter is translated to "[)>\u001E06\u001D" as decoded data header and "\u001E\u0004" as decoded data trailer. - *- * These samples show how to encode Macro Characters in MicroPdf417 and DataMatrix - *- */ -final class MacroCharacter -{ - /** - * None of Macro Characters are added to barcode data - */ - const NONE = 0; - - /** - * 05 Macro craracter is added to barcode data in first position. - * GS1 Data Identifier ISO 15434 - * Character is translated to "[)>\u001E05\u001D" as decoded data header and "\u001E\u0004" as decoded data trailer. - * - * @code - * //to generate autoidentified GS1 message like this "(10)123ABC(10)123ABC" in ISO 15434 format you need: - * $generator = new BarcodeGenerator(EncodeTypes::DATA_MATRIX, "10123ABC\u001D10123ABC"); - * $generator->getParameters()->getBarcode()->getDataMatrix()->setMacroCharacters(MacroCharacter::MACRO_05); - * $reader = new BarCodeReader($generator->generateBarCodeImage(BarcodeImageFormat::PNG), null, DecodeType::GS_1_DATA_MATRIX); - * foreach($reader->readBarCodes() as $result) - * print("BarCode CodeText: ".$result->getCodeText()); - * @endcode - */ - const MACRO_05 = 5; - - /** - * 06 Macro craracter is added to barcode data in first position. - * ASC MH10 Data Identifier ISO 15434 - * Character is translated to "[)>\u001E06\u001D" as decoded data header and "\u001E\u0004" as decoded data trailer. - */ - const MACRO_06 = 6; -} - -/** - * - * Specifies the Aztec symbol mode. - * - * @code - * $generator = new BarcodeGenerator(EncodeTypes::AZTEC); - * $generator->setCodeText("125"); - * $generator->getParameters()->getBarcode()->getAztec()->setAztecSymbolMode(AztecSymbolMode::RUNE); - * $generator->save("test.png", "PNG"); - * @endcode - */ -class AztecSymbolMode -{ - /** - * Specifies to automatically pick up the best symbol (COMPACT or FULL-range) for Aztec. - * This is default value. - */ - const AUTO = "0"; - /** - * Specifies the COMPACT symbol for Aztec. - * Aztec COMPACT symbol permits only 1, 2, 3 or 4 layers. - */ - const COMPACT = "1"; - /** - * Specifies the FULL-range symbol for Aztec. - * Aztec FULL-range symbol permits from 1 to 32 layers. - */ - const FULL_RANGE = "2"; - /** - * Specifies the RUNE symbol for Aztec. - * Aztec Runes are a series of small but distinct machine-readable marks. It permits only number value from 0 to 255. - */ - const RUNE = "3"; -} - -/** - *- * - * @code - * # to generate autoidentified GS1 message like this "(10)123ABC(10)123ABC" in ISO 15434 format you need: - * $generator = new BarcodeGenerator(EncodeTypes::DATA_MATRIX, "10123ABC\u001D10123ABC"); - * $generator->getParameters()->getBarcode()->getDataMatrix()->setMacroCharacters(MacroCharacter::MACRO_05); - * $reader = new BarCodeReader($generator->generateBarCodeImage(BarcodeImageFormat::PNG), null, DecodeType::GS1DataMatrix); - * foreach($reader->readBarCodes() as $result) - * echo "BarCode CodeText: " . $result->getCodeText(); - * @endcode - * @code - * # Encodes MicroPdf417 with 05 Macro the string: "[)>\u001E05\u001Dabcde1234\u001E\u0004" - * $generator = new BarcodeGenerator(EncodeTypes::MicroPdf417, "abcde1234"); - * $generator->getParameters()->getBarcode()->getPdf417()->setMacroCharacters(MacroCharacter::MACRO_05); - * $reader = new BarCodeReader($generator->generateBarCodeImage(BarcodeImageFormat::PNG), null, DecodeType::MICRO_PDF_417); - * foreach($reader->readBarCodes() as $result) - * echo $result->getCodeText(); - * @endcode - * @code - * # Encodes MicroPdf417 with 06 Macro the string: "[)>\u001E06\u001Dabcde1234\u001E\u0004" - * $generator = new BarcodeGenerator(EncodeTypes::MicroPdf417, "abcde1234"); - * $generator->getParameters()->getBarcode()->getPdf417()->setMacroCharacters(MacroCharacter::MACRO_06); - * $reader = new BarCodeReader($generator->generateBarCodeImage(BarcodeImageFormat::PNG), null, DecodeType::MICRO_PDF_417); - * foreach($reader->readBarCodes() as $result) - * echo $result->getCodeText(); - * @endcode - *- *- * DataMatrix encoder's encoding mode, default to Auto - *
- */ -class DataMatrixEncodeMode -{ - /** - * In Auto mode, the CodeText is encoded with maximum data compactness. - * Unicode characters are re-encoded in the ECIEncoding specified encoding with the insertion of an ECI identifier. - * If a character is found that is not supported by the selected ECI encoding, an exception is thrown. - */ - const AUTO = 0; - - /** - *- * This sample shows how to do codetext in Extended Mode. - *- * //Auto mode - * $codetext = "犬Right狗"; - * $generator = new BarcodeGenerator(EncodeTypes::DATA_MATRIX, $codetext); - * $generator->getParameters()->getBarcode()->getDataMatrix()->setECIEncoding(ECIEncodings::UTF8); - * $generator->save("test.bmp", BarcodeImageFormat::PNG); - * //Bytes mode - * $encodedArr = array( 0xFF, 0xFE, 0xFD, 0xFC, 0xFB, 0xFA, 0xF9 ); - * $generator = new BarcodeGenerator(EncodeTypes::DATA_MATRIX, $encodedArr); - * $generator->getParameters()->getBarcode()->getDataMatrix()->setDataMatrixEncodeMode(DataMatrixEncodeMode::BINARY); - * $generator->save("test.bmp", BarcodeImageFormat::PNG); - * //Extended codetext mode - * //create codetext - * $codetextBuilder=new DataMatrixExtCodetextBuilder(); - * $codetextBuilder->addECICodetextWithEncodeMode(ECIEncodings::Win1251,DataMatrixEncodeMode::BYTES,"World"); - * $codetextBuilder->addPlainCodetext("Will"); - * $codetextBuilder->addECICodetext(ECIEncodings::UTF8,"犬Right狗"); - * $codetextBuilder->addCodetextWithEncodeMode(DataMatrixEncodeMode::C40,"ABCDE"); - * //generate codetext - * $codetext=$codetextBuilder->getExtended(); - * //generate - * $generator=new BarcodeGenerator(EncodeTypes::DATA_MATRIX,codetext); - * $generator->getParameters()->getBarcode()->getDataMatrix()->setDataMatrixEncodeMode(DataMatrixEncodeMode::EXTENDED_CODETEXT); - * $generator->save("test.bmp", BarcodeImageFormat::PNG); - *- *- * Encodes one alphanumeric or two numeric characters per byte - *
- */ - const ASCII = 1; - - /** - * Encode 8 bit values - * @deprecated This property is obsolete and will be removed in future releases. Instead, use Base256 option. - */ - const BYTES = 6; - - /** - *- * Uses C40 encoding. Encodes Upper-case alphanumeric, Lower case and special characters - *
- */ - const C40 = 8; - - /** - *- * Uses Text encoding. Encodes Lower-case alphanumeric, Upper case and special characters - *
- */ - const TEXT = 9; - - /** - *- * Uses EDIFACT encoding. Uses six bits per character, encodes digits, upper-case letters, and many punctuation marks, but has no support for lower-case letters. - *
- */ - const EDIFACT = 10; - - /** - *- * Uses ANSI X12 encoding. - *
- */ - const ANSIX12 = 11; - - /** - *- *
ExtendedCodetext mode allows to manually switch encodation schemes and ECI encodings in codetext.
- *It is better to use DataMatrixExtCodetextBuilder for extended codetext generation.
- *Use Display2DText property to set visible text to removing managing characters.
- *ECI identifiers are set as single slash and six digits identifier "\000026" - UTF8 ECI identifier
- *All unicode characters after ECI identifier are automatically encoded into correct character codeset.
- * - *Encodation schemes are set in the next format : "\Encodation_scheme_name:text\Encodation_scheme_name:text".
- *Allowed encodation schemes are: EDIFACT, ANSIX12, ASCII, C40, Text, Auto.
- * - *All backslashes (\) must be doubled in text.
- * - * @deprecated This property is obsolete and will be removed in future releases. Instead, use the 'Extended' encode mode - */ - const EXTENDED_CODETEXT = 12; - - /** - * ExtendedCodetext mode allows to manually switch encodation schemes and ECI encodings in codetext. - * It is better to use DataMatrixExtCodetextBuilder for extended codetext generation. - * Use Display2DText property to set visible text to removing managing characters. - * ECI identifiers are set as single slash and six digits identifier "\000026" - UTF8 ECI identifier - * All unicode characters after ECI identifier are automatically encoded into correct character codeset. - * - * Encodation schemes are set in the next format : "\Encodation_scheme_name:text\Encodation_scheme_name:text". - * Allowed encodation schemes are: EDIFACT, ANSIX12, ASCII, C40, Text, Auto. - * - * All backslashes (\) must be doubled in text. - */ - const EXTENDED = 13; - - /** - * Encode 8 bit values - */ - const BASE_256 = 14; - - /** - * In Binary mode, the CodeText is encoded with maximum data compactness. - * If a Unicode character is found, an exception is thrown. - */ - const BINARY = 15; - - /** - * In ECI mode, the entire message is re-encoded in the ECIEncoding specified encoding with the insertion of an ECI identifier. - * If a character is found that is not supported by the selected ECI encoding, an exception is thrown. - * Please note that some old (pre 2006) scanners may not support this mode. - */ - const ECI = 16; -} - -/** - * Codetext location - */ -class CodeLocation -{ - /** - * Codetext below barcode. - */ - const BELOW = "0"; - - /** - * Codetext above barcode. - */ - const ABOVE = "1"; - - /** - * Hide codetext. - */ - const NONE = "2"; -} - -/** - * Font size mode. - */ -class FontMode -{ - /** - * Automatically calculate Font size based on barcode size. - */ - const AUTO = "0"; - - /** - * Use Font sized defined by user. - */ - const MANUAL = "1"; -} - -/** - * Text alignment. - */ -class TextAlignment -{ - /** - * Left position. - */ - const LEFT = "0"; - - /** - * Center position. - */ - const CENTER = "1"; - - /** - * Right position. - */ - const RIGHT = "2"; -} - -/** - * Specify the type of the ECC to encode. - */ -class DataMatrixEccType -{ - /** - * Specifies that encoded Ecc type is defined by default Reed-Solomon error correction or ECC 200. - */ - const ECC_AUTO = "0"; - /** - * Specifies that encoded Ecc type is defined ECC 000. - */ - const ECC_000 = "1"; - /** - * Specifies that encoded Ecc type is defined ECC 050. - */ - const ECC_050 = "2"; - /** - * Specifies that encoded Ecc type is defined ECC 080. - */ - const ECC_080 = "3"; - /** - * Specifies that encoded Ecc type is defined ECC 100. - */ - const ECC_100 = "4"; - /** - * Specifies that encoded Ecc type is defined ECC 140. - */ - const ECC_140 = "5"; - /** - * Specifies that encoded Ecc type is defined ECC 200. Recommended to use. - */ - const ECC_200 = "6"; -} - -/** - * QR / MicroQR selector mode. Select FORCE_QR for standard QR symbols, AUTO for MicroQR. - * FORCE_MICRO_QR is used for strongly MicroQR symbol generation if it is possible. - */ -class QREncodeType -{ - /** - * Mode starts barcode version negotiation from MicroQR V1 - */ - const AUTO = "0"; - /** - * Mode starts barcode version negotiation from QR V1 - */ - const FORCE_QR = "1"; - /** - * Mode starts barcode version negotiation from from MicroQR V1 to V4. If data cannot be encoded into MicroQR, exception is thrown. - */ - const FORCE_MICRO_QR = "2"; -} - -/** - * Version of QR Code. - * From Version1 to Version40 for QR code and from M1 to M4 for MicroQr. - */ -class QRVersion -{ - /** - * Specifies to automatically pick up the best version for QR. - * This is default value. - */ - const AUTO = "0"; - - /** - * Specifies version 1 with 21 x 21 modules. - */ - const VERSION_01 = "1"; - - /** - * Specifies version 2 with 25 x 25 modules. - */ - const VERSION_02 = "2"; - - /** - * Specifies version 3 with 29 x 29 modules. - */ - const VERSION_03 = "3"; - - /** - * Specifies version 4 with 33 x 33 modules. - */ - const VERSION_04 = "4"; - - /** - * Specifies version 5 with 37 x 37 modules. - */ - const VERSION_05 = "5"; - - /** - * Specifies version 6 with 41 x 41 modules. - */ - const VERSION_06 = "6"; - - /** - * Specifies version 7 with 45 x 45 modules. - */ - const VERSION_07 = "7"; - - /** - * Specifies version 8 with 49 x 49 modules. - */ - const VERSION_08 = "8"; - - /** - * Specifies version 9 with 53 x 53 modules. - */ - const VERSION_09 = "9"; - - /** - * Specifies version 10 with 57 x 57 modules. - */ - const VERSION_10 = "10"; - - /** - * Specifies version 11 with 61 x 61 modules. - */ - const VERSION_11 = "11"; - - /** - * Specifies version 12 with 65 x 65 modules. - */ - const VERSION_12 = "12"; - - /** - * Specifies version 13 with 69 x 69 modules. - */ - const VERSION_13 = "13"; - - /** - * Specifies version 14 with 73 x 73 modules. - */ - const VERSION_14 = "14"; - - /** - * Specifies version 15 with 77 x 77 modules. - */ - const VERSION_15 = "15"; - - /** - * Specifies version 16 with 81 x 81 modules. - */ - const VERSION_16 = "16"; - - /** - * Specifies version 17 with 85 x 85 modules. - */ - const VERSION_17 = "17"; - - /** - * Specifies version 18 with 89 x 89 modules. - */ - const VERSION_18 = "18"; - - /** - * Specifies version 19 with 93 x 93 modules. - */ - const VERSION_19 = "19"; - - /** - * Specifies version 20 with 97 x 97 modules. - */ - const VERSION_20 = "20"; - - /** - * Specifies version 21 with 101 x 101 modules. - */ - const VERSION_21 = "21"; - - /** - * Specifies version 22 with 105 x 105 modules. - */ - const VERSION_22 = "22"; - - /** - * Specifies version 23 with 109 x 109 modules. - */ - const VERSION_23 = "23"; - - /** - * Specifies version 24 with 113 x 113 modules. - */ - const VERSION_24 = "24"; - - /** - * Specifies version 25 with 117 x 117 modules. - */ - const VERSION_25 = "25"; - - /** - * Specifies version 26 with 121 x 121 modules. - */ - const VERSION_26 = "26"; - - /** - * Specifies version 27 with 125 x 125 modules. - */ - const VERSION_27 = "27"; - - /** - * Specifies version 28 with 129 x 129 modules. - */ - const VERSION_28 = "28"; - - /** - * Specifies version 29 with 133 x 133 modules. - */ - const VERSION_29 = "29"; - - /** - * Specifies version 30 with 137 x 137 modules. - */ - const VERSION_30 = "30"; - - /** - * Specifies version 31 with 141 x 141 modules. - */ - const VERSION_31 = "31"; - - /** - * Specifies version 32 with 145 x 145 modules. - */ - const VERSION_32 = "32"; - - /** - * Specifies version 33 with 149 x 149 modules. - */ - const VERSION_33 = "33"; - - /** - * Specifies version 34 with 153 x 153 modules. - */ - const VERSION_34 = "34"; - - /** - * Specifies version 35 with 157 x 157 modules. - */ - const VERSION_35 = "35"; - - /** - * Specifies version 36 with 161 x 161 modules. - */ - const VERSION_36 = "36"; - - /** - * Specifies version 37 with 165 x 165 modules. - */ - const VERSION_37 = "37"; - - /** - * Specifies version 38 with 169 x 169 modules. - */ - const VERSION_38 = "38"; - - /** - * Specifies version 39 with 173 x 173 modules. - */ - const VERSION_39 = "39"; - - /** - * Specifies version 40 with 177 x 177 modules. - */ - const VERSION_40 = "40"; - - /** - * Specifies version M1 for Micro QR with 11 x 11 modules. - */ - const VERSION_M1 = "101"; - - /** - * Specifies version M2 for Micro QR with 13 x 13 modules. - */ - const VERSION_M2 = "102"; - - /** - * Specifies version M3 for Micro QR with 15 x 15 modules. - */ - const VERSION_M3 = "103"; - - /** - * Specifies version M4 for Micro QR with 17 x 17 modules. - */ - const VERSION_M4 = "104"; -} - -/** - * Level of Reed-Solomon error correction. From low to high: LEVEL_L, LEVEL_M, LEVEL_Q, LEVEL_H. - */ -class QRErrorLevel -{ - /** - * Allows recovery of 7% of the code text - */ - const LEVEL_L = "0"; - /** - * Allows recovery of 15% of the code text - */ - const LEVEL_M = "1"; - /** - * Allows recovery of 25% of the code text - */ - const LEVEL_Q = "2"; - /** - * Allows recovery of 30% of the code text - */ - const LEVEL_H = "3"; -} - -/** - *- * Encoding mode for QR barcodes. - *
- *- *- * Example how to use ECI encoding - *- * $generator = new BarcodeGenerator(EncodeTypes::QR, "12345TEXT"); - * $generator->getParameters()->getBarcode()->getQR()->setQrEncodeMode(QREncodeMode::ECI_ENCODING); - * $generator->getParameters()->getBarcode()->getQR()->setQrECIEncoding(ECIEncodings::UTF8); - * $generator->save("test.png", BarcodeImageFormat::PNG); - *- *- */ -class QREncodeMode -{ - /** - * In Auto mode, the CodeText is encoded with maximum data compactness. - * Unicode characters are encoded in kanji mode if possible, or they are re-encoded in the ECIEncoding specified encoding with the insertion of an ECI identifier. - * If a character is found that is not supported by the selected ECI encoding, an exception is thrown. - */ - - const AUTO = 0; - /** - * Encode codetext as plain bytes. If it detects any Unicode character, the character will be encoded as two bytes, lower byte first. - * @deprecated This property is obsolete and will be removed in future releases. Instead, use the 'SetCodeText' method to convert the message to byte array with specified encoding. - */ - const BYTES = 1; - - /** - * Encode codetext with UTF8 encoding with first ByteOfMark character. - * @deprecated This property is obsolete and will be removed in future releases. Instead, use the 'SetCodeText' method with UTF8 encoding to add a byte order mark (BOM) and encode the message. After that, the CodeText can be encoded using the 'Auto' mode. - */ - const UTF_8_BOM = 2; - - - /** - * Encode codetext with UTF8 encoding with first ByteOfMark character. It can be problems with some barcode scanners. - * @deprecated This property is obsolete and will be removed in future releases. Instead, use the 'SetCodeText' method with BigEndianUnicode encoding to add a byte order mark (BOM) and encode the message. After that, the CodeText can be encoded using the 'Auto' mode. - */ - const UTF_16_BEBOM = 3; - - /** - * Encode codetext with value set in the ECIEncoding property. It can be problems with some old (pre 2006) barcode scanners. - * This mode is not supported by MicroQR barcodes. - * @deprecated This property is obsolete and will be removed in future releases. Instead, use ECI option. - */ - const ECI_ENCODING = 4; - - /** - * Extended Channel mode which supports FNC1 first position, FNC1 second position and multi ECI modes. - * It is better to use QrExtCodetextBuilder for extended codetext generation. - * Use Display2DText property to set visible text to removing managing characters. - * Encoding Principles: - * All symbols "\" must be doubled "\\" in the codetext. - * FNC1 in first position is set in codetext as as "<FNC1>" - * FNC1 in second position is set in codetext as as "<FNC1(value)>". The value must be single symbols (a-z, A-Z) or digits from 0 to 99. - * Group Separator for FNC1 modes is set as 0x1D character '\\u001D' - * If you need to insert "<FNC1>" string into barcode write it as "<\FNC1>" - * ECI identifiers are set as single slash and six digits identifier "\000026" - UTF8 ECI identifier - * To disable current ECI mode and convert to default JIS8 mode zero mode ECI indetifier is set. "\000000" - * All unicode characters after ECI identifier are automatically encoded into correct character codeset. - * This mode is not supported by MicroQR barcodes. - * @deprecated This property is obsolete and will be removed in future releases. Instead, use the 'Extended' encode mode. - */ - const EXTENDED_CODETEXT = 5; - - /** - * Extended Channel mode which supports FNC1 first position, FNC1 second position and multi ECI modes. - * It is better to use QrExtCodetextBuilder for extended codetext generation. - * Use Display2DText property to set visible text to removing managing characters. - * Encoding Principles: - * All symbols "\" must be doubled "\\" in the codetext. - * FNC1 in first position is set in codetext as as "<FNC1>" - * FNC1 in second position is set in codetext as as "<FNC1(value)>". The value must be single symbols (a-z, A-Z) or digits from 0 to 99. - * Group Separator for FNC1 modes is set as 0x1D character '\\u001D' - * If you need to insert "<FNC1>" string into barcode write it as "<\FNC1>" - * ECI identifiers are set as single slash and six digits identifier "\000026" - UTF8 ECI identifier - * To disable current ECI mode and convert to default JIS8 mode zero mode ECI indetifier is set. "\000000" - * All unicode characters after ECI identifier are automatically encoded into correct character codeset. - * This mode is not supported by MicroQR barcodes. - */ - const EXTENDED = 6; - - /** - * In Binary mode, the CodeText is encoded with maximum data compactness. - * If a Unicode character is found, an exception is thrown. - */ - const BINARY = 7; - - /** - * In ECI mode, the entire message is re-encoded in the ECIEncoding specified encoding with the insertion of an ECI identifier. - * If a character is found that is not supported by the selected ECI encoding, an exception is thrown. - * Please note that some old (pre 2006) scanners may not support this mode. - * This mode is not supported by MicroQR barcodes. - */ - const ECI = 8; -} - -/** - * pdf417 barcode's error correction level, from level 0 to level 9, level 0 means no error correction, level 9 means best error correction - */ -class Pdf417ErrorLevel -{ - - /** - * level = 0. - */ - const LEVEL_0 = "0"; - /** - * level = 1. - */ - const LEVEL_1 = "1"; - /** - * level = 2. - */ - const LEVEL_2 = "2"; - /** - * level = 3. - */ - const LEVEL_3 = "3"; - /** - * level = 4. - */ - const LEVEL_4 = "4"; - /** - * level = 5. - */ - const LEVEL_5 = "5"; - /** - * level = 6. - */ - const LEVEL_6 = "6"; - /** - * level = 7. - */ - const LEVEL_7 = "7"; - /** - * level = 8. - */ - const LEVEL_8 = "8"; -} - -/** - * Pdf417 barcode's compation mode - */ -class Pdf417CompactionMode -{ - /** - * auto detect compation mode - */ - const AUTO = "0"; - /** - * text compaction - */ - const TEXT = "1"; - /** - * numeric compaction mode - */ - const NUMERIC = "2"; - /** - * binary compaction mode - */ - const BINARY = "3"; -} - -/** - * Extended Channel Interpretation Identifiers. It is used to tell the barcode reader details - * about the used references for encoding the data in the symbol. - * - * Example how to use ECI encoding - * @code - * $generator = new BarcodeGenerator(EncodeTypes::QR); - * $generator->setCodeText("12345TEXT"); - * $generator->getParameters()->getBarcode()->getQR()->setQrEncodeMode(QREncodeMode::ECI_ENCODING); - * $generator->getParameters()->getBarcode()->getQR()->setQrECIEncoding(ECIEncodings::UTF_8); - * $generator->save("test.png", "PNG"); - * @endcode - */ -class ECIEncodings -{ - - /** - * ISO/IEC 8859-1 Latin alphabet No. 1 encoding. ECI Id:"\000003" - */ - const ISO_8859_1 = 3; - /** - * ISO/IEC 8859-2 Latin alphabet No. 2 encoding. ECI Id:"\000004" - */ - const ISO_8859_2 = 4; - /** - * ISO/IEC 8859-3 Latin alphabet No. 3 encoding. ECI Id:"\000005" - */ - const ISO_8859_3 = 5; - /** - * ISO/IEC 8859-4 Latin alphabet No. 4 encoding. ECI Id:"\000006" - */ - const ISO_8859_4 = 6; - /** - * ISO/IEC 8859-5 Latin/Cyrillic alphabet encoding. ECI Id:"\000007" - */ - const ISO_8859_5 = 7; - /** - * ISO/IEC 8859-6 Latin/Arabic alphabet encoding. ECI Id:"\000008" - */ - const ISO_8859_6 = 8; - /** - * ISO/IEC 8859-7 Latin/Greek alphabet encoding. ECI Id:"\000009" - */ - const ISO_8859_7 = 9; - /** - * ISO/IEC 8859-8 Latin/Hebrew alphabet encoding. ECI Id:"\000010" - */ - const ISO_8859_8 = 10; - /** - * ISO/IEC 8859-9 Latin alphabet No. 5 encoding. ECI Id:"\000011" - */ - const ISO_8859_9 = 11; - /** - * ISO/IEC 8859-10 Latin alphabet No. 6 encoding. ECI Id:"\000012" - */ - const ISO_8859_10 = 12; - /** - * ISO/IEC 8859-11 Latin/Thai alphabet encoding. ECI Id:"\000013" - */ - const ISO_8859_11 = 13; - //14 is reserved - /** - * ISO/IEC 8859-13 Latin alphabet No. 7 (Baltic Rim) encoding. ECI Id:"\000015" - */ - const ISO_8859_13 = 15; - /** - * ISO/IEC 8859-14 Latin alphabet No. 8 (Celtic) encoding. ECI Id:"\000016" - */ - const ISO_8859_14 = 16; - /** - * ISO/IEC 8859-15 Latin alphabet No. 9 encoding. ECI Id:"\000017" - */ - const ISO_8859_15 = 17; - /** - * ISO/IEC 8859-16 Latin alphabet No. 10 encoding. ECI Id:"\000018" - */ - const ISO_8859_16 = 18; - //19 is reserved - /** - * Shift JIS (JIS X 0208 Annex 1 + JIS X 0201) encoding. ECI Id:"\000020" - */ - const Shift_JIS = 20; - // - /** - * Windows 1250 Latin 2 (Central Europe) encoding. ECI Id:"\000021" - */ - const Win1250 = 21; - /** - * Windows 1251 Cyrillic encoding. ECI Id:"\000022" - */ - const Win1251 = 22; - /** - * Windows 1252 Latin 1 encoding. ECI Id:"\000023" - */ - const Win1252 = 23; - /** - * Windows 1256 Arabic encoding. ECI Id:"\000024" - */ - const Win1256 = 24; - // - /** - * ISO/IEC 10646 UCS-2 (High order byte first) encoding. ECI Id:"\000025" - */ - const UTF16BE = 25; - /** - * ISO/IEC 10646 UTF-8 encoding. ECI Id:"\000026" - */ - const UTF8 = 26; - // - /** - * ISO/IEC 646:1991 International Reference Version of ISO 7-bit coded character set encoding. ECI Id:"\000027" - */ - const US_ASCII = 27; - /** - * Big 5 (Taiwan) Chinese Character Set encoding. ECI Id:"\000028" - */ - const Big5 = 28; - /** - *- * Example how to use FNC1 first position in Extended Mode - *- * $textBuilder = new QrExtCodetextBuilder(); - * $textBuilder->addPlainCodetext("000%89%%0"); - * $textBuilder->addFNC1GroupSeparator(); - * $textBuilder->addPlainCodetext("12345<FNC1>"); - * //generate barcode - * $generator = new BarcodeGenerator(EncodeTypes::QR); - * $generator->setCodeText(textBuilder->getExtended()); - * $generator->getParameters()->getBarcode()->getQR()->setQrEncodeMode(QREncodeMode::EXTENDED_CODETEXT); - * $generator->getParameters()->getBarcode()->getCodeTextParameters()->setTwoDDisplayText("My Text"); - * $generator->save("d:/test.png", BarcodeImageFormat::PNG); - *- * * - * This sample shows how to use FNC1 second position in Extended Mode. - *- * - * //create codetext - * $textBuilder = new QrExtCodetextBuilder(); - * $textBuilder->addFNC1SecondPosition("12"); - * $textBuilder->addPlainCodetext("TRUE3456"); - * //generate barcode - * $generator = new BarcodeGenerator(EncodeTypes::QR); - * $generator->setCodeText(textBuilder->getExtended()); - * $generator->getParameters()->getBarcode()->getCodeTextParameters()->setTwoDDisplayText("My Text"); - * $generator->save("d:/test.png", BarcodeImageFormat::PNG); - *- * - * This sample shows how to use multi ECI mode in Extended Mode. - *- * - * //create codetext - * $textBuilder = new QrExtCodetextBuilder(); - * $textBuilder->addECICodetext(ECIEncodings::Win1251, "Will"); - * $textBuilder->addECICodetext(ECIEncodings::UTF8, "Right"); - * $textBuilder->addECICodetext(ECIEncodings::UTF16BE, "Power"); - * $textBuilder->addPlainCodetext("t\e\\st"); - * //generate barcode - * $generator = new BarcodeGenerator(EncodeTypes::QR); - * $generator->setCodeText(textBuilder->getExtended()); - * $generator->getParameters()->getBarcode()->getQR()->setQrEncodeMode(QREncodeMode::EXTENDED_CODETEXT); - * $generator->getParameters()->getBarcode()->getCodeTextParameters()->setTwoDDisplayText("My Text"); - * $generator->save("d:/test.png", BarcodeImageFormat::PNG); - *- *GB2312 Chinese Character Set encoding. ECI Id:"\000029"
- */ - const GB2312 = 29; - /** - * Korean Character Set encoding. ECI Id:"\000030" - */ - const EUC_KR = 30; - /** - *GBK (extension of GB2312 for Simplified Chinese) encoding. ECI Id:"\000031"
- */ - const GBK = 31; - /** - *GGB18030 Chinese Character Set encoding. ECI Id:"\000032"
- */ - const GB18030 = 32; - /** - *ISO/IEC 10646 UTF-16LE encoding. ECI Id:"\000033"
- */ - const UTF16LE = 33; - /** - *ISO/IEC 10646 UTF-32BE encoding. ECI Id:"\000034"
- */ - const UTF32BE = 34; - /** - *ISO/IEC 10646 UTF-32LE encoding. ECI Id:"\000035"
- */ - const UTF32LE = 35; - /** - *ISO/IEC 646: ISO 7-bit coded character set - Invariant Characters set encoding. ECI Id:"\000170"
- */ - const INVARIANT = 170; - /** - *8-bit binary data. ECI Id:"\000899"
- */ - const BINARY = 899; - - /** - * No Extended Channel Interpretation/p> - */ - const NONE = 0; -} - -/** - * Specifies the different types of automatic sizing modes. - * Default value is AutoSizeMode::NONE. - * - * This sample shows how to create and save a BarCode image. - * @code - * $generator = new BarcodeGenerator(EncodeTypes::DATA_MATRIX); - * $generator->setAutoSizeMode(AutoSizeMode.NEAREST); - * $generator->getBarCodeWidth()->setMillimeters(50); - * $generator->getBarCodeHeight()->setInches(1.3f); - * $generator->save("test.png"); - * @endcode - */ -class AutoSizeMode -{ - /** - * Automatic resizing is disabled. Default value. - */ - const NONE = '0'; //or CUSTOM, or DEFAULT - - /** - * Barcode resizes to nearest lowest possible size - * which are specified by BarCodeWidth and BarCodeHeight properties. - */ - const NEAREST = '1'; - - /** - * Resizes barcode to specified size with little scaling - * but it can be little damaged in some cases - * because using interpolation for scaling. - * Size can be specified by BarcodeGenerator.BarCodeWidth - * and BarcodeGenerator.BarCodeHeight properties. - * - * This sample shows how to create and save a BarCode image in Scale mode. - * @code - * $generator = new BarcodeGenerator(EncodeTypes::DATA_MATRIX, ""); - * $generator->getParameters()->getBarcode()->setAutoSizeMode(AutoSizeMode::INTERPOLATION); - * $generator->getParameters()->getBarcode()->getBarCodeWidth()->setMillimeters(50); - * $generator->getParameters()->getBarcode()->getBarCodeHeight()->setInches(1.3); - * $generator->save("test.png", "PNG); - * @endcode - */ - const INTERPOLATION = '2'; -} - -/** - * Specifies the type of barcode to encode. - */ -class EncodeTypes -{ - - /** - * Unspecified encode type. - */ - const NONE = -1; - - /** - * Specifies that the data should be encoded with CODABAR barcode specification - */ - const CODABAR = 0; - - /** - * Specifies that the data should be encoded with CODE 11 barcode specification - */ - const CODE_11 = 1; - - /** - *- * Specifies that the data should be encoded with {@code Code 39} basic charset barcode specification: ISO/IEC 16388 - *
- */ - const CODE_39 = 2; - - /** - *- * Specifies that the data should be encoded with {@code Code 39} full ASCII charset barcode specification: ISO/IEC 16388 - *
- */ - const CODE_39_FULL_ASCII = 3; - - /** - *- * Specifies that the data should be encoded with {@code CODE 93} barcode specification - *
- */ - const CODE_93 = 5; - - /** - * Specifies that the data should be encoded with CODE 128 barcode specification - */ - const CODE_128 = 6; - - /** - * Specifies that the data should be encoded with GS1 Code 128 barcode specification. The codetext must contains parentheses for AI. - */ - const GS_1_CODE_128 = 7; - - /** - * Specifies that the data should be encoded with EAN-8 barcode specification - */ - const EAN_8 = 8; - - /** - * Specifies that the data should be encoded with EAN-13 barcode specification - */ - const EAN_13 = 9; - - /** - * Specifies that the data should be encoded with EAN14 barcode specification - */ - const EAN_14 = 10; - - /** - * Specifies that the data should be encoded with SCC14 barcode specification - */ - const SCC_14 = 11; - - /** - * Specifies that the data should be encoded with SSCC18 barcode specification - */ - const SSCC_18 = 12; - - /** - * Specifies that the data should be encoded with UPC-A barcode specification - */ - const UPCA = 13; - - /** - * Specifies that the data should be encoded with UPC-E barcode specification - */ - const UPCE = 14; - - /** - * Specifies that the data should be encoded with isBN barcode specification - */ - const ISBN = 15; - - /** - * Specifies that the data should be encoded with ISSN barcode specification - */ - const ISSN = 16; - - /** - * Specifies that the data should be encoded with ISMN barcode specification - */ - const ISMN = 17; - - /** - * Specifies that the data should be encoded with Standard 2 of 5 barcode specification - */ - const STANDARD_2_OF_5 = 18; - - /** - * Specifies that the data should be encoded with INTERLEAVED 2 of 5 barcode specification - */ - const INTERLEAVED_2_OF_5 = 19; - - /** - * Represents Matrix 2 of 5 BarCode - */ - const MATRIX_2_OF_5 = 20; - - /** - * Represents Italian Post 25 barcode. - */ - const ITALIAN_POST_25 = 21; - - /** - * Represents IATA 2 of 5 barcode.IATA (International Air Transport Assosiation) uses this barcode for the management of air cargo. - */ - const IATA_2_OF_5 = 22; - - /** - * Specifies that the data should be encoded with ITF14 barcode specification - */ - const ITF_14 = 23; - - /** - * Represents ITF-6 Barcode. - */ - const ITF_6 = 24; - - /** - * Specifies that the data should be encoded with MSI Plessey barcode specification - */ - const MSI = 25; - - /** - * Represents VIN (Vehicle Identification Number) Barcode. - */ - const VIN = 26; - - /** - * Represents Deutsch Post barcode, This EncodeType is also known as Identcode,CodeIdentcode,German Postal 2 of 5 Identcode, - * Deutsch Post AG Identcode, Deutsch Frachtpost Identcode, Deutsch Post AG (DHL) - */ - const DEUTSCHE_POST_IDENTCODE = 27; - - /** - * Represents Deutsch Post Leitcode Barcode,also known as German Postal 2 of 5 Leitcode, CodeLeitcode, Leitcode, Deutsch Post AG (DHL). - */ - const DEUTSCHE_POST_LEITCODE = 28; - - /** - * Represents OPC(Optical Product Code) Barcode,also known as , VCA Barcode VCA OPC, Vision Council of America OPC Barcode. - */ - const OPC = 29; - - /** - * Represents PZN barcode.This EncodeType is also known as Pharmacy central number, Pharmazentralnummer - */ - const PZN = 30; - - /** - * Represents Code 16K barcode. - */ - const CODE_16_K = 31; - - /** - * Represents Pharmacode barcode. - */ - const PHARMACODE = 32; - - /** - * 2D barcode symbology DataMatrix - */ - const DATA_MATRIX = 33; - - /** - * Specifies that the data should be encoded with QR Code barcode specification - */ - const QR = 34; - - /** - * Specifies that the data should be encoded with Aztec barcode specification - */ - const AZTEC = 35; - - /** - *- * Specifies that the data should be encoded with {@code GS1 Aztec} barcode specification. The codetext must contains parentheses for AI. - *
- */ - const GS_1_AZTEC = 81; - - /** - * Specifies that the data should be encoded with Pdf417 barcode specification - */ - const PDF_417 = 36; - - /** - * Specifies that the data should be encoded with MacroPdf417 barcode specification - */ - const MACRO_PDF_417 = 37; - - /** - * 2D barcode symbology DataMatrix with GS1 string format - */ - const GS_1_DATA_MATRIX = 48; - - /** - * Specifies that the data should be encoded with MicroPdf417 barcode specification - */ - const MICRO_PDF_417 = 55; - - /** - * Specifies that the data should be encoded with GS1MicroPdf417 barcode specification - */ - const GS_1_MICRO_PDF_417 = 82; - - /** - * 2D barcode symbology QR with GS1 string format - */ - const GS_1_QR = 56; - - /** - * Specifies that the data should be encoded with MaxiCode barcode specification - */ - const MAXI_CODE = 57; - - /** - * Specifies that the data should be encoded with DotCode barcode specification - */ - const DOT_CODE = 60; - - /** - * Represents Australia Post Customer BarCode - */ - const AUSTRALIA_POST = 38; - - /** - * Specifies that the data should be encoded with Postnet barcode specification - */ - const POSTNET = 39; - - /** - * Specifies that the data should be encoded with Planet barcode specification - */ - const PLANET = 40; - - /** - * Specifies that the data should be encoded with USPS OneCode barcode specification - */ - const ONE_CODE = 41; - - /** - * Represents RM4SCC barcode. RM4SCC (Royal Mail 4-state Customer Code) is used for automated mail sort process in UK. - */ - const RM_4_SCC = 42; - - /** - * Represents Royal Mail Mailmark barcode. - */ - const MAILMARK = 66; - - /** - * Specifies that the data should be encoded with GS1 Databar omni-directional barcode specification. - */ - const DATABAR_OMNI_DIRECTIONAL = 43; - - /** - * Specifies that the data should be encoded with GS1 Databar truncated barcode specification. - */ - const DATABAR_TRUNCATED = 44; - - /** - * Represents GS1 DATABAR limited barcode. - */ - const DATABAR_LIMITED = 45; - - /** - * Represents GS1 Databar expanded barcode. - */ - const DATABAR_EXPANDED = 46; - - /** - * Represents GS1 Databar expanded stacked barcode. - */ - const DATABAR_EXPANDED_STACKED = 52; - - /** - * Represents GS1 Databar stacked barcode. - */ - const DATABAR_STACKED = 53; - - /** - * Represents GS1 Databar stacked omni-directional barcode. - */ - const DATABAR_STACKED_OMNI_DIRECTIONAL = 54; - - /** - * Specifies that the data should be encoded with Singapore Post Barcode barcode specification - */ - const SINGAPORE_POST = 47; - - /** - * Specifies that the data should be encoded with Australian Post Domestic eParcel Barcode barcode specification - */ - const AUSTRALIAN_POSTE_PARCEL = 49; - - /** - * Specifies that the data should be encoded with Swiss Post Parcel Barcode barcode specification. Supported types: Domestic Mail, International Mail, Additional Services (new) - */ - const SWISS_POST_PARCEL = 50; - - /** - * Represents Patch code barcode - */ - const PATCH_CODE = 51; - - /** - * Specifies that the data should be encoded with Code32 barcode specification - */ - const CODE_32 = 58; - - /** - * Specifies that the data should be encoded with DataLogic 2 of 5 barcode specification - */ - const DATA_LOGIC_2_OF_5 = 59; - - /** - * Specifies that the data should be encoded with Dutch KIX barcode specification - */ - const DUTCH_KIX = 61; - - /** - * Specifies that the data should be encoded with UPC coupon with GS1-128 Extended Code barcode specification. - * An example of the input string: - * BarCodeBuilder->setCodetext("514141100906(8102)03"), - * where UPCA part is "514141100906", GS1Code128 part is (8102)03. - */ - const UPCA_GS_1_CODE_128_COUPON = 62; - - /** - * Specifies that the data should be encoded with UPC coupon with GS1 DataBar addition barcode specification. - * - * An example of the input string: - * @code - * BarcodeGenerator->setCodetext("514141100906(8110)106141416543213500110000310123196000"), - * @endcode - * where UPCA part is "514141100906", DATABAR part is "(8110)106141416543213500110000310123196000". - * To change the caption, use barCodeBuilder->getCaptionAbove()->setText("company prefix + offer code"); - */ - const UPCA_GS_1_DATABAR_COUPON = 63; - - /** - * Specifies that the data should be encoded with Codablock-F barcode specification. - */ - const CODABLOCK_F = 64; - - /** - * Specifies that the data should be encoded with GS1 Codablock-F barcode specification. The codetext must contains parentheses for AI. - */ - const GS_1_CODABLOCK_F = 65; - - /** - * Specifies that the data should be encoded with GS1 Composite Bar barcode specification. The codetext must contains parentheses for AI. 1D codetext and 2D codetext must be separated with symbol '/' - */ - const GS_1_COMPOSITE_BAR = 67; - - /** - *- * Specifies that the data should be encoded with {@code HIBC LIC Code39Standart} barcode specification. - *
- */ - const HIBC_CODE_39_LIC = 68; - - /** - *- * Specifies that the data should be encoded with {@code HIBC LIC Code128} barcode specification. - *
- */ - const HIBC_CODE_128_LIC = 69; - - /** - *- * Specifies that the data should be encoded with {@code HIBC LIC Aztec} barcode specification. - *
- */ - const HIBC_AZTEC_LIC = 70; - - /** - *- * Specifies that the data should be encoded with {@code HIBC LIC DataMatrix} barcode specification. - *
- */ - const HIBC_DATA_MATRIX_LIC = 71; - - /** - *- * Specifies that the data should be encoded with {@code HIBC LIC QR} barcode specification. - *
- */ - const HIBCQRLIC = 72; - - /** - *- * Specifies that the data should be encoded with {@code HIBC PAS Code39Standart} barcode specification. - *
- */ - const HIBC_CODE_39_PAS = 73; - - /** - *- * Specifies that the data should be encoded with {@code HIBC PAS Code128} barcode specification. - *
- */ - const HIBC_CODE_128_PAS = 74; - - /** - *- * Specifies that the data should be encoded with {@code HIBC PAS Aztec} barcode specification. - *
- */ - const HIBC_AZTEC_PAS = 75; - - /** - *- * Specifies that the data should be encoded with {@code HIBC PAS DataMatrix} barcode specification. - *
- */ - const HIBC_DATA_MATRIX_PAS = 76; - - /** - *- * Specifies that the data should be encoded with {@code HIBC PAS QR} barcode specification. - *
- */ - const HIBCQRPAS = 77; - - /** - *- * Specifies that the data should be encoded with {@code GS1 DotCode} barcode specification. The codetext must contains parentheses for AI. - *
- */ - const GS_1_DOT_CODE = 78; - - /** - * Specifies that the data should be encoded with Han Xin barcode specification - */ - const HAN_XIN = 79; - - /** - * 2D barcode symbology QR with GS1 string format - */ - const GS_1_HAN_XIN = 80; - - /** - * Specifies that the data should be encoded with MicroQR Code barcode specification - */ - const MICRO_QR = 83; - - /** - * Specifies that the data should be encoded with RectMicroQR (rMQR) Code barcode specification - */ - const RECT_MICRO_QR = 84; - - public static function parse(string $encodeTypeName) : int - { - if($encodeTypeName == "CODABAR") return 0; - - else if($encodeTypeName == "CODE_11") return 1; - - else if($encodeTypeName == "CODE_39") return 2; - - else if($encodeTypeName == "CODE_39_FULL_ASCII") return 3; - - else if($encodeTypeName == "CODE_93") return 5; - - else if($encodeTypeName == "CODE_128") return 6; - - else if($encodeTypeName == "GS_1_CODE_128") return 7; - - else if($encodeTypeName == "EAN_8") return 8; - - else if($encodeTypeName == "EAN_13") return 9; - - else if($encodeTypeName == "EAN_14") return 10; - - else if($encodeTypeName == "SCC_14") return 11; - - else if($encodeTypeName == "SSCC_18") return 12; - - else if($encodeTypeName == "UPCA") return 13; - - else if($encodeTypeName == "UPCE") return 14; - - else if($encodeTypeName == "ISBN") return 15; - - else if($encodeTypeName == "ISSN") return 16; - - else if($encodeTypeName == "ISMN") return 17; - - else if($encodeTypeName == "STANDARD_2_OF_5") return 18; - - else if($encodeTypeName == "INTERLEAVED_2_OF_5") return 19; - - else if($encodeTypeName == "MATRIX_2_OF_5") return 20; - - else if($encodeTypeName == "ITALIAN_POST_25") return 21; - - else if($encodeTypeName == "IATA_2_OF_5") return 22; - - else if($encodeTypeName == "ITF_14") return 23; - - else if($encodeTypeName == "ITF_6") return 24; - - else if($encodeTypeName == "MSI") return 25; - - else if($encodeTypeName == "VIN") return 26; - - else if($encodeTypeName == "DEUTSCHE_POST_IDENTCODE") return 27; - - else if($encodeTypeName == "DEUTSCHE_POST_LEITCODE") return 28; - - else if($encodeTypeName == "OPC") return 29; - - else if($encodeTypeName == "PZN") return 30; - - else if($encodeTypeName == "CODE_16_K") return 31; - - else if($encodeTypeName == "PHARMACODE") return 32; - - else if($encodeTypeName == "DATA_MATRIX") return 33; - - else if($encodeTypeName == "QR") return 34; - - else if($encodeTypeName == "AZTEC") return 35; - - else if($encodeTypeName == "GS_1_AZTEC") return 81; - - else if($encodeTypeName == "PDF_417") return 36; - - else if($encodeTypeName == "MACRO_PDF_417") return 37; - - else if($encodeTypeName == "GS_1_DATA_MATRIX") return 48; - - else if($encodeTypeName == "MICRO_PDF_417") return 55; - - else if($encodeTypeName == "GS_1_QR") return 56; - - else if($encodeTypeName == "MAXI_CODE") return 57; - - else if($encodeTypeName == "DOT_CODE") return 60; - - else if($encodeTypeName == "AUSTRALIA_POST") return 38; - - else if($encodeTypeName == "POSTNET") return 39; - - else if($encodeTypeName == "PLANET") return 40; - - else if($encodeTypeName == "ONE_CODE") return 41; - - else if($encodeTypeName == "RM_4_SCC") return 42; - - else if($encodeTypeName == "MAILMARK") return 66; - - else if($encodeTypeName == "DATABAR_OMNI_DIRECTIONAL") return 43; - - else if($encodeTypeName == "DATABAR_TRUNCATED") return 44; - - else if($encodeTypeName == "DATABAR_LIMITED") return 45; - - else if($encodeTypeName == "DATABAR_EXPANDED") return 46; - - else if($encodeTypeName == "DATABAR_EXPANDED_STACKED") return 52; - - else if($encodeTypeName == "DATABAR_STACKED") return 53; - - else if($encodeTypeName == "DATABAR_STACKED_OMNI_DIRECTIONAL") return 54; - - else if($encodeTypeName == "SINGAPORE_POST") return 47; - - else if($encodeTypeName == "AUSTRALIAN_POSTE_PARCEL") return 49; - - else if($encodeTypeName == "SWISS_POST_PARCEL") return 50; - - else if($encodeTypeName == "PATCH_CODE") return 51; - - else if($encodeTypeName == "CODE_32") return 58; - - else if($encodeTypeName == "DATA_LOGIC_2_OF_5") return 59; - - else if($encodeTypeName == "DUTCH_KIX") return 61; - - else if($encodeTypeName == "UPCA_GS_1_CODE_128_COUPON") return 62; - - else if($encodeTypeName == "UPCA_GS_1_DATABAR_COUPON") return 63; - - else if($encodeTypeName == "CODABLOCK_F") return 64; - - else if($encodeTypeName == "GS_1_CODABLOCK_F") return 65; - - else if($encodeTypeName == "GS_1_COMPOSITE_BAR") return 67; - - else if($encodeTypeName == "HIBC_CODE_39_LIC") return 68; - - else if($encodeTypeName == "HIBC_CODE_128_LIC") return 69; - - else if($encodeTypeName == "HIBC_AZTEC_LIC") return 70; - - else if($encodeTypeName == "HIBC_DATA_MATRIX_LIC") return 71; - - else if($encodeTypeName == "HIBCQRLIC") return 72; - - else if($encodeTypeName == "HIBC_CODE_39_PAS") return 73; - - else if($encodeTypeName == "HIBC_CODE_128_PAS") return 74; - - else if($encodeTypeName == "HIBC_AZTEC_PAS") return 75; - - else if($encodeTypeName == "HIBC_DATA_MATRIX_PAS") return 76; - - else if($encodeTypeName == "HIBCQRPAS") return 77; - - else if($encodeTypeName == "GS_1_DOT_CODE") return 78; - - else if($encodeTypeName == "HAN_XIN") return 79; - - else if($encodeTypeName == "GS_1_HAN_XIN") return 80; - - else if($encodeTypeName == "MICRO_QR") return 83; - - else if($encodeTypeName == "RECT_MICRO_QR") return 84; - - else return -1; - } -} - -/** - * Specifies the file format of the image. - */ -class BarCodeImageFormat -{ - /** - * Specifies the bitmap (BMP) image format. - */ - const BMP = 0; - - /** - * Specifies the Graphics Interchange Format (GIF) image format. - */ - const GIF = 1; - - /** - * Specifies the Joint Photographic Experts Group (JPEG) image format. - */ - const JPEG = 2; - - /** - * Specifies the W3C Portable Network Graphics (PNG) image format. - */ - const PNG = 3; - - /** - * Specifies the Tagged Image File Format (TIFF) image format. - */ - const TIFF = 4; - - - /** - * Specifies the Tagged Image File Format (TIFF) image format in CMYK color model. - */ - const TIFF_IN_CMYK = 5; - - /** - * Specifies the Enhanced Metafile (EMF) image format. - */ - const EMF = 6; - - /** - * Specifies the Scalable Vector Graphics (SVG) image format. - */ - const SVG = 7; - - /** - * Specifies the Portable Document Format (PDF) image format. - */ - const PDF = 8; -} - -/** - * Specifies the unit of measure for the given data. - */ -class GraphicsUnit -{ - /** - * Specifies the world coordinate system unit as the unit of measure. - */ - const WORLD = 0; - - /** - * Specifies the unit of measure of the display device. Typically pixels for video displays, and 1/100 inch for printers. - */ - const DISPLAY = 1; - - /** - * Specifies a device pixel as the unit of measure. - */ - const PIXEL = 2; - - /** - * Specifies a printer's point = 1/72 inch) as the unit of measure. - */ - const POINT = 3; - - /** - * Specifies the inch as the unit of measure. - */ - const INCH = 4; - - /** - * Specifies the document unit = 1/300 inch) as the unit of measure. - */ - const DOCUMENT = 5; - - /** - * Specifies the millimeter as the unit of measure. - */ - const MILLIMETER = 6; -} - -/** - *- * Version of MicroQR Code. - * From M1 to M4. - *
- */ -class MicroQRVersion -{ - /** - *- * Specifies to automatically pick up the best version for MicroQR. - * This is default value. - *
- */ - const AUTO = 0; - - /** - *- * Specifies version M1 for Micro QR with 11 x 11 modules. - *
- */ - const M1 = 1; - - /** - *- * Specifies version M2 for Micro QR with 13 x 13 modules. - *
- */ - const M2 = 2; - - /** - *- * Specifies version M3 for Micro QR with 15 x 15 modules. - *
- */ - const M3 = 3; - - /** - *- * Specifies version M4 for Micro QR with 17 x 17 modules. - *
- */ - const M4 = 4; -} - -/** - *- * Version of RectMicroQR Code. - * From version R7x43 to version R17x139. - *
- */ -class RectMicroQRVersion -{ - /** - *- * Specifies to automatically pick up the best version for RectMicroQR. - * This is default value. - *
- */ - const AUTO = 0; - - /** - *- * Specifies version with 7 x 43 modules. - *
- */ - const R7x43 = 1; - - /** - *- * Specifies version with 7 x 59 modules. - *
- */ - const R7x59 = 2; - - /** - *- * Specifies version with 7 x 77 modules. - *
- */ - const R7x77 = 3; - - /** - *- * Specifies version with 7 x 99 modules. - *
- */ - const R7x99 = 4; - - /** - *- * Specifies version with 7 x 139 modules. - *
- */ - const R7x139 = 5; - - /** - *- * Specifies version with 9 x 43 modules. - *
- */ - const R9x43 = 6; - - /** - *- * Specifies version with 9 x 59 modules. - *
- */ - const R9x59 = 7; - - /** - *- * Specifies version with 9 x 77 modules. - *
- */ - const R9x77 = 8; - - /** - *- * Specifies version with 9 x 99 modules. - *
- */ - const R9x99 = 9; - - /** - *- * Specifies version with 9 x 139 modules. - *
- */ - const R9x139 = 10; - - /** - *- * Specifies version with 11 x 27 modules. - *
- */ - const R11x27 = 11; - - /** - *- * Specifies version with 11 x 43 modules. - *
- */ - const R11x43 = 12; - - /** - *- * Specifies version with 11 x 59 modules. - *
- */ - const R11x59 = 13; - - /** - *- * Specifies version with 11 x 77 modules. - *
- */ - const R11x77 = 14; - - /** - *- * Specifies version with 11 x 99 modules. - *
- */ - const R11x99 = 15; - - /** - *- * Specifies version with 11 x 139 modules. - *
- */ - const R11x139 = 16; - - /** - *- * Specifies version with 13 x 27 modules. - *
- */ - const R13x27 = 17; - - /** - *- * Specifies version with 13 x 43 modules. - *
- */ - const R13x43 = 18; - - /** - *- * Specifies version with 13 x 59 modules. - *
- */ - const R13x59 = 19; - - /** - *- * Specifies version with 13 x 77 modules. - *
- */ - const R13x77 = 20; - - /** - *- * Specifies version with 13 x 99 modules. - *
- */ - const R13x99 = 21; - - /** - *- * Specifies version with 13 x 139 modules. - *
- */ - const R13x139 = 22; - - /** - *- * Specifies version with 15 x 43 modules. - *
- */ - const R15x43 = 23; - - /** - *- * Specifies version with 15 x 59 modules. - *
- */ - const R15x59 = 24; - - /** - *- * Specifies version with 15 x 77 modules. - *
- */ - const R15x77 = 25; - - /** - *- * Specifies version with 15 x 99 modules. - *
- */ - const R15x99 = 26; - - /** - *- * Specifies version with 15 x 139 modules. - *
- */ - const R15x139 = 27; - - /** - *- * Specifies version with 17 x 43 modules. - *
- */ - const R17x43 = 28; - - /** - *- * Specifies version with 17 x 59 modules. - *
- */ - const R17x59 = 29; - - /** - *- * Specifies version with 17 x 77 modules. - *
- */ - const R17x77 = 30; - - /** - *- * Specifies version with 17 x 99 modules. - *
- */ - const R17x99 = 31; - - /** - *- * Specifies version with 17 x 139 modules. - *
- */ - const R17x139 = 32; -} - -/** - *- * Specify the type of the ECC to encode. - *
- */ -class DataMatrixVersion -{ - /** - *- * Specifies to automatically pick up the smallest size for DataMatrix. - * This is default value. - *
- */ - const AUTO = 0; - /** - *- * Instructs to get symbol sizes from Rows And Columns parameters. Note that DataMatrix does not support - * custom rows and columns numbers. This option is not recommended to use. - *
- */ - const ROWS_COLUMNS = 1; - /** - *- * Specifies size of 9 x 9 modules for ECC000 type. - *
- */ - const ECC000_9x9 = 2; - /** - *- * Specifies size of 11 x 11 modules for ECC000-ECC050 types. - *
- */ - const ECC000_050_11x11 = 3; - /** - *- * Specifies size of 13 x 13 modules for ECC000-ECC100 types. - *
- */ - const ECC000_100_13x13 = 4; - /** - *- * Specifies size of 15 x 15 modules for ECC000-ECC100 types. - *
- */ - const ECC000_100_15x15 = 5; - /** - *- * Specifies size of 17 x 17 modules for ECC000-ECC140 types. - *
- */ - const ECC000_140_17x17 = 6; - /** - *- * Specifies size of 19 x 19 modules for ECC000-ECC140 types. - *
- */ - const ECC000_140_19x19 = 7; - /** - *- * Specifies size of 21 x 21 modules for ECC000-ECC140 types. - *
- */ - const ECC000_140_21x21 = 8; - /** - *- * Specifies size of 23 x 23 modules for ECC000-ECC140 types. - *
- */ - const ECC000_140_23x23 = 9; - /** - *- * Specifies size of 25 x 25 modules for ECC000-ECC140 types. - *
- */ - const ECC000_140_25x25 = 10; - /** - *- * Specifies size of 27 x 27 modules for ECC000-ECC140 types. - *
- */ - const ECC000_140_27x27 = 11; - /** - *- * Specifies size of 29 x 29 modules for ECC000-ECC140 types. - *
- */ - const ECC000_140_29x29 = 12; - /** - *- * Specifies size of 31 x 31 modules for ECC000-ECC140 types. - *
- */ - const ECC000_140_31x31 = 13; - /** - *- * Specifies size of 33 x 33 modules for ECC000-ECC140 types. - *
- */ - const ECC000_140_33x33 = 14; - /** - *- * Specifies size of 35 x 35 modules for ECC000-ECC140 types. - *
- */ - const ECC000_140_35x35 = 15; - /** - *- * Specifies size of 37 x 37 modules for ECC000-ECC140 types. - *
- */ - const ECC000_140_37x37 = 16; - /** - *- * Specifies size of 39 x 39 modules for ECC000-ECC140 types. - *
- */ - const ECC000_140_39x39 = 17; - /** - *- * Specifies size of 41 x 41 modules for ECC000-ECC140 types. - *
- */ - const ECC000_140_41x41 = 18; - /** - *- * Specifies size of 43 x 43 modules for ECC000-ECC140 types. - *
- */ - const ECC000_140_43x43 = 19; - /** - *- * Specifies size of 45 x 45 modules for ECC000-ECC140 types. - *
- */ - const ECC000_140_45x45 = 20; - /** - *- * Specifies size of 47 x 47 modules for ECC000-ECC140 types. - *
- */ - const ECC000_140_47x47 = 21; - /** - *- * Specifies size of 49 x 49 modules for ECC000-ECC140 types. - *
- */ - const ECC000_140_49x49 = 22; - /** - *- * Specifies size of 10 x 10 modules for ECC200 type. - *
- */ - const ECC200_10x10 = 23; - /** - *- * Specifies size of 12 x 12 modules for ECC200 type. - *
- */ - const ECC200_12x12 = 24; - /** - *- * Specifies size of 14 x 14 modules for ECC200 type. - *
- */ - const ECC200_14x14 = 25; - /** - *- * Specifies size of 16 x 16 modules for ECC200 type. - *
- */ - const ECC200_16x16 = 26; - /** - *- * Specifies size of 18 x 18 modules for ECC200 type. - *
- */ - const ECC200_18x18 = 27; - /** - *- * Specifies size of 20 x 20 modules for ECC200 type. - *
- */ - const ECC200_20x20 = 28; - /** - *- * Specifies size of 22 x 22 modules for ECC200 type. - *
- */ - const ECC200_22x22 = 29; - /** - *- * Specifies size of 24 x 24 modules for ECC200 type. - *
- */ - const ECC200_24x24 = 30; - /** - *- * Specifies size of 26 x 26 modules for ECC200 type. - *
- */ - const ECC200_26x26 = 31; - /** - *- * Specifies size of 32 x 32 modules for ECC200 type. - *
- */ - const ECC200_32x32 = 32; - /** - *- * Specifies size of 36 x 36 modules for ECC200 type. - *
- */ - const ECC200_36x36 = 33; - /** - *- * Specifies size of 40 x 40 modules for ECC200 type. - *
- */ - const ECC200_40x40 = 34; - /** - *- * Specifies size of 44 x 44 modules for ECC200 type. - *
- */ - const ECC200_44x44 = 35; - /** - *- * Specifies size of 48 x 48 modules for ECC200 type. - *
- */ - const ECC200_48x48 = 36; - /** - *- * Specifies size of 52 x 52 modules for ECC200 type. - *
- */ - const ECC200_52x52 = 37; - /** - *- * Specifies size of 64 x 64 modules for ECC200 type. - *
- */ - const ECC200_64x64 = 38; - /** - *- * Specifies size of 72 x 72 modules for ECC200 type. - *
- */ - const ECC200_72x72 = 39; - /** - *- * Specifies size of 80 x 80 modules for ECC200 type. - *
- */ - const ECC200_80x80 = 40; - /** - *- * Specifies size of 88 x 88 modules for ECC200 type. - *
- */ - const ECC200_88x88 = 41; - /** - *- * Specifies size of 96 x 96 modules for ECC200 type. - *
- */ - const ECC200_96x96 = 42; - /** - *- * Specifies size of 104 x 104 modules for ECC200 type. - *
- */ - const ECC200_104x104 = 43; - /** - *- * Specifies size of 120 x 120 modules for ECC200 type. - *
- */ - const ECC200_120x120 = 44; - /** - *- * Specifies size of 132 x 132 modules for ECC200 type. - *
- */ - const ECC200_132x132 = 45; - /** - *- * Specifies size of 144 x 144 modules for ECC200 type. - *
- */ - const ECC200_144x144 = 46; - /** - *- * Specifies size of 8 x 18 modules for ECC200 type. - *
- */ - const ECC200_8x18 = 47; - /** - *- * Specifies size of 8 x 32 modules for ECC200 type. - *
- */ - const ECC200_8x32 = 48; - /** - *- * Specifies size of 12 x 26 modules for ECC200 type. - *
- */ - const ECC200_12x26 = 49; - /** - *- * Specifies size of 12 x 36 modules for ECC200 type. - *
- */ - const ECC200_12x36 = 50; - /** - *- * Specifies size of 16 x 36 modules for ECC200 type. - *
- */ - const ECC200_16x36 = 51; - /** - *- * Specifies size of 16 x 48 modules for ECC200 type. - *
- */ - const ECC200_16x48 = 52; - /** - *- * Specifies size of 8 x 48 modules for DMRE barcodes. - *
- */ - const DMRE_8x48 = 53; - /** - *- * Specifies size of 8 x 64 modules for DMRE barcodes. - *
- */ - const DMRE_8x64 = 54; - /** - *- * Specifies size of 8 x 80 modules for DMRE barcodes. - *
- */ - const DMRE_8x80 = 55; - /** - *- * Specifies size of 8 x 96 modules for DMRE barcodes. - *
- */ - const DMRE_8x96 = 56; - /** - *- * Specifies size of 8 x 120 modules for DMRE barcodes. - *
- */ - const DMRE_8x120 = 57; - /** - *- * Specifies size of 8 x 144 modules for DMRE barcodes. - *
- */ - const DMRE_8x144 = 58; - /** - *- * Specifies size of 12 x 64 modules for DMRE barcodes. - *
- */ - const DMRE_12x64 = 59; - /** - *- * Specifies size of 12 x 88 modules for DMRE barcodes. - *
- */ - const DMRE_12x88 = 60; - /** - *- * Specifies size of 16 x 64 modules for DMRE barcodes. - *
- */ - const DMRE_16x64 = 61; - /** - *- * Specifies size of 20 x 36 modules for DMRE barcodes. - *
- */ - const DMRE_20x36 = 62; - /** - *- * Specifies size of 20 x 44 modules for DMRE barcodes. - *
- */ - const DMRE_20x44 = 63; - /** - *- * Specifies size of 20 x 64 modules for DMRE barcodes. - *
- */ - const DMRE_20x64 = 64; - /** - *- * Specifies size of 22 x 48 modules for DMRE barcodes. - *
- */ - const DMRE_22x48 = 65; - /** - *- * Specifies size of 24 x 48 modules for DMRE barcodes. - *
- */ - const DMRE_24x48 = 66; - /** - *- * Specifies size of 24 x 64 modules for DMRE barcodes. - *
- */ - const DMRE_24x64 = 67; - /** - *- * Specifies size of 26 x 40 modules for DMRE barcodes. - *
- */ - const DMRE_26x40 = 68; - /** - *- * Specifies size of 26 x 48 modules for DMRE barcodes. - *
- */ - const DMRE_26x48 = 69; - /** - *- * Specifies size of 26 x 64 modules for DMRE barcodes. - *
- */ - const DMRE_26x64 = 70; -} - -/** - *- * Encoding mode for Aztec barcodes. - *
- */ -class AztecEncodeMode -{ - /** - *- *- * - * @code - * //Auto mode - * $codetext = "犬Right狗"; - * $generator = new BarcodeGenerator(EncodeTypes::AZTEC, $codetext); - * $generator->getParameters()->getBarcode()->getAztec()->setECIEncoding(ECIEncodings::UTF_8); - * $generator->save("test.bmp", BarcodeImageFormat::BMP); - * - * @code - * //Bytes mode - * $encodedArr = [0xFF, 0xFE, 0xFD, 0xFC, 0xFB, 0xFA, 0xF9]; - * //encode array to string - * $strBld = ""; - * foreach($encodedArr as bval) - * $strBld->append(chr(bval)); - * $codetext = $strBld->toString(); - * $generator = new BarcodeGenerator(EncodeTypes::AZTEC, $codetext); - * $generator->getParameters()->getBarcode()->getAztec()->setAztecEncodeMode(AztecEncodeMode::BYTES); - * $generator->save("test.bmp", BarcodeImageFormat::BMP); - * - * @code - * //Extended codetext mode - * //create codetext - * $textBuilder = new AztecExtCodetextBuilder(); - * $textBuilder->addECICodetext(ECIEncodings::Win1251, "Will"); - * $textBuilder->addECICodetext(ECIEncodings::UTF8, "犬Right狗"); - * $textBuilder->addECICodetext(ECIEncodings::UTF16BE, "犬Power狗"); - * $textBuilder->addPlainCodetext("Plain text"); - * //generate codetext - * $codetext = $textBuilder->getExtendedCodetext(); - * //generate - * $generator = new BarcodeGenerator(EncodeTypes::AZTEC, codetext); - * $generator->getParameters()->getBarcode()->getAztec()->setAztecEncodeMode(AztecEncodeMode::EXTENDED_CODETEXT); - * $generator->getParameters()->getBarcode()->getCodeTextParameters()->setTwoDDisplayText("My Text"); - * $generator->save("test.bmp", BarcodeImageFormat::BMP); - * - *- *- * In Auto mode, the CodeText is encoded with maximum data compactness. - * Unicode characters are re-encoded in the ECIEncoding specified encoding with the insertion of an ECI identifier. - * If a character is found that is not supported by the selected ECI encoding, an exception is thrown. - *
- */ - const AUTO = 0; - - /** - *- * Encode codetext as plain bytes. If it detects any Unicode character, the character will be encoded as two bytes, lower byte first. - *
- * @deprecated - */ - const BYTES = 1; - - /** - *- *
Extended mode which supports multi ECI modes.
- *It is better to use AztecExtCodetextBuilder for extended codetext generation.
- *Use Display2DText property to set visible text to removing managing characters.
- *ECI identifiers are set as single slash and six digits identifier "\000026" - UTF8 ECI identifier
- *All unicode characters after ECI identifier are automatically encoded into correct character codeset.
- * - * @deprecated - */ - const EXTENDED_CODETEXT = 2; - /** - *- *
Extended mode which supports multi ECI modes.
- *It is better to use AztecExtCodetextBuilder for extended codetext generation.
- *Use Display2DText property to set visible text to removing managing characters.
- *ECI identifiers are set as single slash and six digits identifier "\000026" - UTF8 ECI identifier
- *All unicode characters after ECI identifier are automatically encoded into correct character codeset.
- * - */ - const EXTENDED = 3; - - /** - *- * In Binary mode, the CodeText is encoded with maximum data compactness. - * If a Unicode character is found, an exception is thrown. - *
- */ - const BINARY = 4; - - /** - *- * In ECI mode, the entire message is re-encoded in the ECIEncoding specified encoding with the insertion of an ECI identifier. - * If a character is found that is not supported by the selected ECI encoding, an exception is thrown. - * Please note that some old (pre 2006) scanners may not support this mode. - *
- */ - const ECI = 5; -} - - -/** - * Type of 2D component - * This sample shows how to create and save a GS1 Composite Bar image. - * Note that 1D codetext and 2D codetext are separated by symbol '/' - * @code - * $codetext = "(01)03212345678906/(21)A1B2C3D4E5F6G7H8"; - * $generator = new BarcodeGenerator(EncodeTypes::GS1_COMPOSITE_BAR, $codetext)) - * - * $generator->getParameters()->getBarcode()->getGS1CompositeBar()->setLinearComponentType(EncodeTypes::GS1_CODE_128); - * $generator->getParameters()->getBarcode()->getGS1CompositeBar()->setTwoDComponentType(TwoDComponentType::CC_A); - * - * // Aspect ratio of 2D component - * $generator->getParameters()->getBarcode()->getPdf417()->setAspectRatio(3); - * /// - * // X-Dimension of 1D and 2D components - * $generator->getParameters()->getBarcode()->getXDimension()->setPixels(3); - * /// - * // Height of 1D component - * $generator->getParameters()->getBarcode()->getBarHeight()->setPixels(100); - * /// - * $generator->save("test.png", BarcodeImageFormat::PNG); - * @endcode - */ -class TwoDComponentType -{ - /** - * Auto select type of 2D component - */ - const AUTO = 0; - - /** - * CC-A type of 2D component. It is a structural variant of MicroPDF417 - */ - const CC_A = 1; - - /** - * CC-B type of 2D component. It is a MicroPDF417 symbol. - */ - const CC_B = 2; - - /** - * CC-C type of 2D component. It is a PDF417 symbol. - */ - const CC_C = 3; -} - -/** - * Enable checksum during generation for 1D barcodes. - * Default is treated as Yes for symbologies which must contain checksum, as No where checksum only possible. - * Checksum never used: Codabar - * Checksum is possible: Code39 Standard/Extended, Standard2of5, Interleaved2of5, Matrix2of5, ItalianPost25, DeutschePostIdentcode, DeutschePostLeitcode, VIN - * Checksum always used: Rest symbologies - */ -class EnableChecksum -{ - /** - * If checksum is required by the specification - it will be attached. - */ - const DEFAULT = 0; - - /** - * Always use checksum if possible. - */ - const YES = 1; - - /** - * Do not use checksum. - */ - const NO = 2; -} - -/** - * Used to tell the encoder whether to add Macro PDF417 Terminator (codeword 922) to the segment. - * Applied only for Macro PDF417. - */ -class Pdf417MacroTerminator -{ - /** - * The terminator will be added automatically if the number of segments is provided - * and the current segment is the last one. In other cases, the terminator will not be added. - */ - const AUTO = 0; - - /** - * The terminator will not be added. - */ - const NONE = 1; - - /** - * The terminator will be added. - */ - const SET = 2; -} - -/** - * Encoding mode for MaxiCode barcodes. - * - * @code - * //Auto mode - * $codetext = "犬Right狗"; - * $generator = new BarcodeGenerator(EncodeTypes::MAXI_CODE, $codetext)) - * $generator->getParameters()->getBarcode()->getMaxiCode()->setECIEncoding(ECIEncodings::UTF8); - * $generator->save("test.bmp"); - * - * //Bytes mode - * $encodedArr = array( 0xFF, 0xFE, 0xFD, 0xFC, 0xFB, 0xFA, 0xF9 ); - * //encode array to string - * $strBld = ""; - * foreach($encodedArr as $bval) - * { - * $strBld .= $bval; - * } - * $codetext = $strBld; - * $generator = new BarcodeGenerator(EncodeTypes::MAXI_CODE, $codetext); - * $generator->getParameters()->getBarcode()->getMaxiCode()->setMaxiCodeEncodeMode(MaxiCodeEncodeMode.BYTES); - * $generator->save(ApiTests::folder."test2.bmp", BarCodeImageFormat::BMP); - * @endcode - */ -class MaxiCodeEncodeMode -{ - /** - *- * In Auto mode, the CodeText is encoded with maximum data compactness. - * Unicode characters are re-encoded in the ECIEncoding specified encoding with the insertion of an ECI identifier. - * If a character is found that is not supported by the selected ECI encoding, an exception is thrown. - *
- */ - const AUTO = 0; - - /** - * Encode codetext as plain bytes. If it detects any Unicode character, the character will be encoded as two bytes, lower byte first. - * @deprecated - */ - const BYTES = 1; - - /** - *- *
Extended mode which supports multi ECI modes.
- *It is better to use MaxiCodeExtCodetextBuilder for extended codetext generation.
- *Use Display2DText property to set visible text to removing managing characters.
- *ECI identifiers are set as single slash and six digits identifier "\000026" - UTF8 ECI identifier
- *All unicode characters after ECI identifier are automatically encoded into correct character codeset.
- * - * @deprecated - */ - const EXTENDED_CODETEXT = 2; - - /** - * Extended mode which supports multi ECI modes. - * It is better to use MaxiCodeExtCodetextBuilder for extended codetext generation. - * Use Display2DText property to set visible text to removing managing characters. - * ECI identifiers are set as single slash and six digits identifier "\000026" - UTF8 ECI identifier - * All unicode characters after ECI identifier are automatically encoded into correct character codeset. - */ - const EXTENDED = 3; - - /** - *- * In Binary mode, the CodeText is encoded with maximum data compactness. - * If a Unicode character is found, an exception is thrown. - *
- */ - const BINARY = 4; - - /** - *- * In ECI mode, the entire message is re-encoded in the ECIEncoding specified encoding with the insertion of an ECI identifier. - * If a character is found that is not supported by the selected ECI encoding, an exception is thrown. - * Please note that some old (pre 2006) scanners may not support this mode. - *
- */ - const ECI = 5; -} - -/** - *- * Encoding mode for DotCode barcodes. - *
- */ -class DotCodeEncodeMode -{ - /** - *- *- * //Auto mode with macros - * $codetext = ""[)>\u001E05\u001DCodetextWithMacros05\u001E\u0004""; - * $generator = new BarcodeGenerator(EncodeTypes::DOT_CODE, $codetext); - * $generator->save("test.bmp", BarCodeImageFormat::BMP); - * - * //Auto mode - * $codetext = "犬Right狗"; - * $generator = new BarcodeGenerator(EncodeTypes::DOT_CODE, $codetext); - * $generator->getParameters()->getBarcode()->getDotCode()->setECIEncoding(ECIEncodings::UTF8); - * $generator->save("test.bmp", BarCodeImageFormat::BMP); - * - * //Bytes mode - * $encodedArr = array(0xFF, 0xFE, 0xFD, 0xFC, 0xFB, 0xFA, 0xF9); - * $generator = new BarcodeGenerator(EncodeTypes::DOT_CODE, null); - * $generator->setCodetext($encodedArr, null); - * $generator->getParameters()->getBarcode()->getDotCode()->setDotCodeEncodeMode(DotCodeEncodeMode::BINARY); - * $generator->save("test.bmp", BarcodeImageFormat:PNG); - * - * //Extended codetext mode - * //create codetext - * $textBuilder = new DotCodeExtCodetextBuilder(); - * $textBuilder->addFNC1FormatIdentifier(); - * $textBuilder->addECICodetext(ECIEncodings::Win1251, "Will"); - * $textBuilder->addFNC1FormatIdentifier(); - * $textBuilder->addECICodetext(ECIEncodings::UTF8, "犬Right狗"); - * $textBuilder->addFNC3SymbolSeparator(); - * $textBuilder->addFNC1FormatIdentifier(); - * $textBuilder->addECICodetext(ECIEncodings::UTF16BE, "犬Power狗"); - * $textBuilder->addPlainCodetext("Plain text"); - * //generate codetext - * $codetext = $textBuilder->getExtended(); - * //generate - * $generator = new BarcodeGenerator(EncodeTypes::DOT_CODE, $codetext); - * $generator->getParameters()->getBarcode()->getDotCode()->setDotCodeEncodeMode(DotCodeEncodeMode::EXTENDED_CODETEXT); - * $generator->save("test.bmp", BarCodeImageFormat::BMP); - *- *- * In Auto mode, the CodeText is encoded with maximum data compactness. - * Unicode characters are re-encoded in the ECIEncoding specified encoding with the insertion of an ECI identifier. - * If a character is found that is not supported by the selected ECI encoding, an exception is thrown. - *
- */ - const AUTO = 0; - - /** - *- * Encode codetext as plain bytes. If it detects any Unicode character, the character will be encoded as two bytes, lower byte first. - *
- * @deprecated - */ - const BYTES = 1; - - /** - *- *
Extended mode which supports multi ECI modes.
- *It is better to use DotCodeExtCodetextBuilder for extended codetext generation.
- *Use Display2DText property to set visible text to removing managing characters.
- *ECI identifiers are set as single slash and six digits identifier "\000026" - UTF8 ECI identifier
- *All unicode characters after ECI identifier are automatically encoded into correct character codeset.
- * - * @deprecated - */ - const EXTENDED_CODETEXT = 2; - - /** - *- * In Binary mode, the CodeText is encoded with maximum data compactness. - * If a Unicode character is found, an exception is thrown. - *
- */ - const BINARY = 3; - - /** - *- * In ECI mode, the entire message is re-encoded in the ECIEncoding specified encoding with the insertion of an ECI identifier. - * If a character is found that is not supported by the selected ECI encoding, an exception is thrown. - * Please note that some old (pre 2006) scanners may not support this mode. - *
- */ - const ECI = 4; - - /** - *- *
Extended mode which supports multi ECI modes.
- *It is better to use DotCodeExtCodetextBuilder for extended codetext generation.
- *Use Display2DText property to set visible text to removing managing characters.
- *ECI identifiers are set as single slash and six digits identifier "\000026" - UTF8 ECI identifier
- *All unicode characters after ECI identifier are automatically encoded into correct character codeset.
- * - */ - const EXTENDED = 5; -} - - -/** - *- * Pdf417 barcode encode mode - *
- */ -class Pdf417EncodeMode -{ - /** - *- * In Auto mode, the CodeText is encoded with maximum data compactness. - * Unicode characters are re-encoded in the ECIEncoding specified encoding with the insertion of an ECI identifier. - * If a character is found that is not supported by the selected ECI encoding, an exception is thrown. - *
- */ - const AUTO = 0; - - /** - *- * In Binary mode, the CodeText is encoded with maximum data compactness. - * If a Unicode character is found, an exception is thrown. - *
- */ - const BINARY = 1; - - /** - *- * In ECI mode, the entire message is re-encoded in the ECIEncoding specified encoding with the insertion of an ECI identifier. - * If a character is found that is not supported by the selected ECI encoding, an exception is thrown. - * Please note that some old (pre 2006) scanners may not support this mode. - *
- */ - const ECI = 2; - - /** - *- *
Extended mode which supports multi ECI modes.
- *It is better to use Pdf417ExtCodetextBuilder for extended codetext generation.
- *Use Display2DText property to set visible text to removing managing characters.
- *ECI identifiers are set as single slash and six digits identifier "\000026" - UTF8 ECI identifier
- *All unicode characters after ECI identifier are automatically encoded into correct character codeset.
- * - */ - const EXTENDED = 3; -} - - -/** - *- * Encoding mode for Code128 barcodes. - * {@code Code 128} specification. - *
- */ -class Code128EncodeMode -{ - /** - *- * Thos code demonstrates how to generate code 128 with different encodings - *- * - * //Generate code 128 with ISO 15417 encoding - * $generator = new BarcodeGenerator(EncodeTypes::Code128, "ABCD1234567890"); - * $generator->Parameters->Barcode->Code128->setCode128EncodeMode(Code128EncodeMode::AUTO); - * $generator->Save("d:/code128Auto.png", BarCodeImageFormat::Png); - * //Generate code 128 only with Codeset A encoding - * $generator = new BarcodeGenerator(EncodeTypes::Code128, "ABCD1234567890"); - * $generator->Parameters->Barcode->Code128->setCode128EncodeMode(Code128EncodeMode::CODE_A); - * $generator->Save("d:/code128CodeA.png", BarCodeImageFormat::Png); - *- *- * Encode codetext in classic ISO 15417 mode. The mode should be used in all ordinary cases. - *
- */ - const AUTO = 0; - - /** - *- * Encode codetext only in 128A codeset. - *
- */ - const CODE_A = 1; - - /** - *- * Encode codetext only in 128B codeset. - *
- */ - const CODE_B = 2; - - /** - *- * Encode codetext only in 128C codeset. - *
- */ - const CODE_C = 4; - - /** - *- * Encode codetext only in 128A and 128B codesets. - *
- */ - const CODE_AB = 3; - - /** - *- * Encode codetext only in 128A and 128C codesets. - *
- */ - const CODE_AC = 5; - - /** - *- * Encode codetext only in 128B and 128C codesets. - *
- */ - const CODE_BC = 6; -} - -/** - *- * Han Xin Code encoding mode. It is recommended to use Auto with ASCII / Chinese characters or Unicode for Unicode characters. - *
- */ -class HanXinEncodeMode -{ - /** - *- *- * // Auto mode - * $codetext = "1234567890ABCDEFGabcdefg,Han Xin Code"; - * $generator = new BarcodeGenerator(EncodeTypes::HAN_XIN, codetext); - * $generator->save("test.bmp", BarcodeImageFormat::BMP); - * - * // Bytes mode - * $encodedArr = array(0xFF, 0xFE, 0xFD, 0xFC, 0xFB, 0xFA, 0xF9); - * - * //encode array to string - * StringBuilder strBld = new StringBuilder(); - * for (byte bval : encodedArr) - * strBld.append((char) bval); - * $codetext = strBld.toString(); - * - * $generator = new BarcodeGenerator(EncodeTypes::HAN_XIN, codetext); - * $generator->getParameters()->getBarcode()->getHanXin()->setHanXinEncodeMode(HanXinEncodeMode::BYTES); - * $generator->save("test.bmp", BarcodeImageFormat::BMP); - * - * // ECI mode - * $codetext = "ΑΒΓΔΕ"; - * $generator = new BarcodeGenerator(EncodeTypes::HAN_XIN, codetext); - * $generator->getParameters()->getBarcode()->getHanXin()->setHanXinEncodeMode(HanXinEncodeMode::ECI); - * $generator->getParameters()->getBarcode()->getHanXin()->setHanXinECIEncoding(ECIEncodings::ISO_8859_7); - * $generator->save("test.bmp", BarcodeImageFormat::BMP); - * - * // URI mode - * $codetext = "https://www.test.com/%BC%DE%%%ab/search=test"; - * $generator = new BarcodeGenerator(EncodeTypes::HAN_XIN, codetext); - * $generator->getParameters()->getBarcode()->getHanXin()->setHanXinEncodeMode(HanXinEncodeMode::URI); - * $generator->save("test.bmp", BarcodeImageFormat::BMP); - * - * // Extended mode - TBD - *- *- * Sequence of Numeric, Text, ECI, Binary Bytes and 4 GB18030 modes changing automatically. - *
- */ - const AUTO = 0; - /** - *- * Binary byte mode encodes binary data in any form and encodes them in their binary byte. Every byte in - * Binary Byte mode is represented by 8 bits. - *
- */ - const BINARY = 1; - /** - *- * Extended Channel Interpretation (ECI) mode - *
- */ - const ECI = 2; - /** - *- * Unicode mode designs a way to represent any text data reference to UTF8 encoding/charset in Han Xin Code. - *
- */ - const UNICODE = 3; - /** - *- * URI mode indicates the data represented in Han Xin Code is Uniform Resource Identifier (URI) - * reference to RFC 3986. - *
- */ - const URI = 4; - /** - *- * Extended mode will allow more flexible combinations of other modes, this mode is currently not implemented. - *
- */ - const EXTENDED = 5; -} - -/** - *- * Level of Reed-Solomon error correction. From low to high: L1, L2, L3, L4. - *
- */ -class HanXinErrorLevel -{ - /** - *- * Allows recovery of 8% of the code text - *
- */ - const L1 = 0; - /** - *- * Allows recovery of 15% of the code text - *
- */ - const L2 = 1; - /** - *- * Allows recovery of 23% of the code text - *
- */ - const L3 = 2; - /** - *- * Allows recovery of 30% of the code text - *
- */ - const L4 = 3; -} - - -/** - *- * Version of Han Xin Code. - * From Version01 - 23 x 23 modules to Version84 - 189 x 189 modules, increasing in steps of 2 modules per side. - *
- */ -class HanXinVersion -{ - /** - *- * Specifies to automatically pick up the best version. - * This is default value. - *
- */ - const AUTO = 0; - /** - *- * Specifies version 1 with 23 x 23 modules. - *
- */ - const VERSION_01 = 1; - /** - *- * Specifies version 2 with 25 x 25 modules. - *
- */ - const VERSION_02 = 2; - /** - *- * Specifies version 3 with 27 x 27 modules. - *
- */ - const VERSION_03 = 3; - /** - *- * Specifies version 4 with 29 x 29 modules. - *
- */ - const VERSION_04 = 4; - /** - *- * Specifies version 5 with 31 x 31 modules. - *
- */ - const VERSION_05 = 5; - /** - *- * Specifies version 6 with 33 x 33 modules. - *
- */ - const VERSION_06 = 6; - /** - *- * Specifies version 7 with 35 x 35 modules. - *
- */ - const VERSION_07 = 7; - /** - *- * Specifies version 8 with 37 x 37 modules. - *
- */ - const VERSION_08 = 8; - /** - *- * Specifies version 9 with 39 x 39 modules. - *
- */ - const VERSION_09 = 9; - /** - *- * Specifies version 10 with 41 x 41 modules. - *
- */ - const VERSION_10 = 10; - /** - *- * Specifies version 11 with 43 x 43 modules. - *
- */ - const VERSION_11 = 11; - /** - *- * Specifies version 12 with 45 x 45 modules. - *
- */ - const VERSION_12 = 12; - /** - *- * Specifies version 13 with 47 x 47 modules. - *
- */ - const VERSION_13 = 13; - /** - *- * Specifies version 14 with 49 x 49 modules. - *
- */ - const VERSION_14 = 14; - /** - *- * Specifies version 15 with 51 x 51 modules. - *
- */ - const VERSION_15 = 15; - /** - *- * Specifies version 16 with 53 x 53 modules. - *
- */ - const VERSION_16 = 16; - /** - *- * Specifies version 17 with 55 x 55 modules. - *
- */ - const VERSION_17 = 17; - /** - *- * Specifies version 18 with 57 x 57 modules. - *
- */ - const VERSION_18 = 18; - /** - *- * Specifies version 19 with 59 x 59 modules. - *
- */ - const VERSION_19 = 19; - /** - *- * Specifies version 20 with 61 x 61 modules. - *
- */ - const VERSION_20 = 20; - /** - *- * Specifies version 21 with 63 x 63 modules. - *
- */ - const VERSION_21 = 21; - /** - *- * Specifies version 22 with 65 x 65 modules. - *
- */ - const VERSION_22 = 22; - /** - *- * Specifies version 23 with 67 x 67 modules. - *
- */ - const VERSION_23 = 23; - /** - *- * Specifies version 24 with 69 x 69 modules. - *
- */ - const VERSION_24 = 24; - /** - *- * Specifies version 25 with 71 x 71 modules. - *
- */ - const VERSION_25 = 25; - /** - *- * Specifies version 26 with 73 x 73 modules. - *
- */ - const VERSION_26 = 26; - /** - *- * Specifies version 27 with 75 x 75 modules. - *
- */ - const VERSION_27 = 27; - /** - *- * Specifies version 28 with 77 x 77 modules. - *
- */ - const VERSION_28 = 28; - /** - *- * Specifies version 29 with 79 x 79 modules. - *
- */ - const VERSION_29 = 29; - /** - *- * Specifies version 30 with 81 x 81 modules. - *
- */ - const VERSION_30 = 30; - /** - *- * Specifies version 31 with 83 x 83 modules. - *
- */ - const VERSION_31 = 31; - /** - *- * Specifies version 32 with 85 x 85 modules. - *
- */ - const VERSION_32 = 32; - /** - *- * Specifies version 33 with 87 x 87 modules. - *
- */ - const VERSION_33 = 33; - /** - *- * Specifies version 34 with 89 x 89 modules. - *
- */ - const VERSION_34 = 34; - /** - *- * Specifies version 35 with 91 x 91 modules. - *
- */ - const VERSION_35 = 35; - /** - *- * Specifies version 36 with 93 x 93 modules. - *
- */ - const VERSION_36 = 36; - /** - *- * Specifies version 37 with 95 x 95 modules. - *
- */ - const VERSION_37 = 37; - /** - *- * Specifies version 38 with 97 x 97 modules. - *
- */ - const VERSION_38 = 38; - /** - *- * Specifies version 39 with 99 x 99 modules. - *
- */ - const VERSION_39 = 39; - /** - *- * Specifies version 40 with 101 x 101 modules. - *
- */ - const VERSION_40 = 40; - /** - *- * Specifies version 41 with 103 x 103 modules. - *
- */ - const VERSION_41 = 41; - /** - *- * Specifies version 42 with 105 x 105 modules. - *
- */ - const VERSION_42 = 42; - /** - *- * Specifies version 43 with 107 x 107 modules. - *
- */ - const VERSION_43 = 43; - /** - *- * Specifies version 44 with 109 x 109 modules. - *
- */ - const VERSION_44 = 44; - /** - *- * Specifies version 45 with 111 x 111 modules. - *
- */ - const VERSION_45 = 45; - /** - *- * Specifies version 46 with 113 x 113 modules. - *
- */ - const VERSION_46 = 46; - /** - *- * Specifies version 47 with 115 x 115 modules. - *
- */ - const VERSION_47 = 47; - /** - *- * Specifies version 48 with 117 x 117 modules. - *
- */ - const VERSION_48 = 48; - /** - *- * Specifies version 49 with 119 x 119 modules. - *
- */ - const VERSION_49 = 49; - /** - *- * Specifies version 50 with 121 x 121 modules. - *
- */ - const VERSION_50 = 50; - /** - *- * Specifies version 51 with 123 x 123 modules. - *
- */ - const VERSION_51 = 51; - /** - *- * Specifies version 52 with 125 x 125 modules. - *
- */ - const VERSION_52 = 52; - /** - *- * Specifies version 53 with 127 x 127 modules. - *
- */ - const VERSION_53 = 53; - /** - *- * Specifies version 54 with 129 x 129 modules. - *
- */ - const VERSION_54 = 54; - /** - *- * Specifies version 55 with 131 x 131 modules. - *
- */ - const VERSION_55 = 55; - /** - *- * Specifies version 56 with 133 x 133 modules. - *
- */ - const VERSION_56 = 56; - /** - *- * Specifies version 57 with 135 x 135 modules. - *
- */ - const VERSION_57 = 57; - /** - *- * Specifies version 58 with 137 x 137 modules. - *
- */ - const VERSION_58 = 58; - /** - *- * Specifies version 59 with 139 x 139 modules. - *
- */ - const VERSION_59 = 59; - /** - *- * Specifies version 60 with 141 x 141 modules. - *
- */ - const VERSION_60 = 60; - /** - *- * Specifies version 61 with 143 x 143 modules. - *
- */ - const VERSION_61 = 61; - /** - *- * Specifies version 62 with 145 x 145 modules. - *
- */ - const VERSION_62 = 62; - /** - *- * Specifies version 63 with 147 x 147 modules. - *
- */ - const VERSION_63 = 63; - /** - *- * Specifies version 64 with 149 x 149 modules. - *
- */ - const VERSION_64 = 64; - /** - *- * Specifies version 65 with 151 x 151 modules. - *
- */ - const VERSION_65 = 65; - /** - *- * Specifies version 66 with 153 x 153 modules. - *
- */ - const VERSION_66 = 66; - /** - *- * Specifies version 67 with 155 x 155 modules. - *
- */ - const VERSION_67 = 67; - /** - *- * Specifies version 68 with 157 x 157 modules. - *
- */ - const VERSION_68 = 68; - /** - *- * Specifies version 69 with 159 x 159 modules. - *
- */ - const VERSION_69 = 69; - /** - *- * Specifies version 70 with 161 x 161 modules. - *
- */ - const VERSION_70 = 70; - /** - *- * Specifies version 71 with 163 x 163 modules. - *
- */ - const VERSION_71 = 71; - /** - *- * Specifies version 72 with 165 x 165 modules. - *
- */ - const VERSION_72 = 72; - /** - *- * Specifies version 73 with 167 x 167 modules. - *
- */ - const VERSION_73 = 73; - /** - *- * Specifies version 74 with 169 x 169 modules. - *
- */ - const VERSION_74 = 74; - /** - *- * Specifies version 75 with 171 x 171 modules. - *
- */ - const VERSION_75 = 75; - /** - *- * Specifies version 76 with 173 x 173 modules. - *
- */ - const VERSION_76 = 76; - /** - *- * Specifies version 77 with 175 x 175 modules. - *
- */ - const VERSION_77 = 77; - /** - *- * Specifies version 78 with 177 x 177 modules. - *
- */ - const VERSION_78 = 78; - /** - *- * Specifies version 79 with 179 x 179 modules. - *
- */ - const VERSION_79 = 79; - /** - *- * Specifies version 80 with 181 x 181 modules. - *
- */ - const VERSION_80 = 80; - /** - *- * Specifies version 81 with 183 x 183 modules. - *
- */ - const VERSION_81 = 81; - /** - *- * Specifies version 82 with 185 x 185 modules. - *
- */ - const VERSION_82 = 82; - /** - *- * Specifies version 83 with 187 x 187 modules. - *
- */ - const VERSION_83 = 83; - /** - *- * Specifies version 84 with 189 x 189 modules. - *
- */ - const VERSION_84 = 84; -} - -/** - *- * Possible modes for filling color in svg file, RGB is default and supported by SVG 1.1. - * RGBA, HSL, HSLA is allowed in SVG 2.0 standard. - * Even in RGB opacity will be set through "fill-opacity" parameter - *
- */ -class SvgColorMode -{ - /** - *- * RGB mode, example: fill="#ff5511" fill-opacity="0.73". Default mode. - *
- */ - const RGB = 0; - /** - *- * RGBA mode, example: fill="rgba(255, 85, 17, 0.73)" - *
- */ - const RGBA =1; - /** - *- * HSL mode, example: fill="hsl(17, 100%, 53%)" fill-opacity="0.73" - *
- */ - const HSL = 2; - /** - *- * HSLA mode, example: fill="hsla(30, 50%, 70%, 0.8)" - *
- */ - const HSLA = 3; -} diff --git a/lib/Generation/AustralianPostParameters.php b/lib/Generation/AustralianPostParameters.php new file mode 100644 index 00000000..beac4261 --- /dev/null +++ b/lib/Generation/AustralianPostParameters.php @@ -0,0 +1,129 @@ +australianPostParametersDto; + } + + private function setAustralianPostParametersDto(AustralianPostParametersDTO $australianPostParametersDto): void + { + $this->australianPostParametersDto = $australianPostParametersDto; + } + + private $australianPostShortBarHeight; + + function __construct(AustralianPostParametersDTO $australianPostParametersDto) + { + $this->australianPostParametersDto = $australianPostParametersDto; + $this->obtainDto(); + $this->initFieldsFromDto(); + } + + public function obtainDto(...$args) + { + } + + public function initFieldsFromDto(): void + { + try + { + $this->australianPostShortBarHeight = new Unit($this->getAustralianPostParametersDto()->australianPostShortBarHeight); + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Short bar's height of AustralianPost barcode. + */ + public function getAustralianPostShortBarHeight(): Unit + { + try + { + return $this->australianPostShortBarHeight; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Short bar's height of AustralianPost barcode. + */ + public function setAustralianPostShortBarHeight(Unit $value): void + { + try + { + $this->getAustralianPostParametersDto()->australianPostShortBarHeight = $value->getUnitDto(); + $this->australianPostShortBarHeight = $value; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Interpreting type for the Customer Information of AustralianPost, default to CustomerInformationInterpretingType.Other" + */ + public function getAustralianPostEncodingTable(): int + { + try + { + return $this->getAustralianPostParametersDto()->australianPostEncodingTable; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Interpreting type for the Customer Information of AustralianPost, default to CustomerInformationInterpretingType.Other" + */ + public function setAustralianPostEncodingTable(int $value): void + { + try + { + $this->getAustralianPostParametersDto()->australianPostEncodingTable = $value; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Returns a human-readable string representation of this AustralianPostParameters. + * + * @return string A string that represents this AustralianPostParameters. + */ + public function toString(): string + { + $thriftConnection = new ThriftConnection(); + $client = $thriftConnection->openConnection(); + $str = $client->AustralianPostParameters_toString($this->getAustralianPostParametersDto()); + $thriftConnection->closeConnection(); + + return $str; + } +} \ No newline at end of file diff --git a/lib/Generation/AutoSizeMode.php b/lib/Generation/AutoSizeMode.php new file mode 100644 index 00000000..4dab10d3 --- /dev/null +++ b/lib/Generation/AutoSizeMode.php @@ -0,0 +1,48 @@ +setAutoSizeMode(AutoSizeMode.NEAREST); + * $generator->getBarCodeWidth()->setMillimeters(50); + * $generator->getBarCodeHeight()->setInches(1.3f); + * $generator->save("test.png"); + * @endcode + */ +class AutoSizeMode +{ + /** + * Automatic resizing is disabled. Default value. + */ + const NONE = '0'; //or CUSTOM, or DEFAULT + + /** + * Barcode resizes to nearest lowest possible size + * which are specified by BarCodeWidth and BarCodeHeight properties. + */ + const NEAREST = '1'; + + /** + * Resizes barcode to specified size with little scaling + * but it can be little damaged in some cases + * because using interpolation for scaling. + * Size can be specified by BarcodeGenerator.BarCodeWidth + * and BarcodeGenerator.BarCodeHeight properties. + * + * This sample shows how to create and save a BarCode image in Scale mode. + * @code + * $generator = new BarcodeGenerator(EncodeTypes::DATA_MATRIX, ""); + * $generator->getParameters()->getBarcode()->setAutoSizeMode(AutoSizeMode::INTERPOLATION); + * $generator->getParameters()->getBarcode()->getBarCodeWidth()->setMillimeters(50); + * $generator->getParameters()->getBarcode()->getBarCodeHeight()->setInches(1.3); + * $generator->save("test.png", "PNG); + * @endcode + */ + const INTERPOLATION = '2'; +} \ No newline at end of file diff --git a/lib/Generation/AztecEncodeMode.php b/lib/Generation/AztecEncodeMode.php new file mode 100644 index 00000000..04b7d148 --- /dev/null +++ b/lib/Generation/AztecEncodeMode.php @@ -0,0 +1,106 @@ + + * Encoding mode for Aztec barcodes. + *+ */ +class AztecEncodeMode +{ + /** + *+ *+ * + * @code + * //Auto mode + * $codetext = "犬Right狗"; + * $generator = new BarcodeGenerator(EncodeTypes::AZTEC, $codetext); + * $generator->getParameters()->getBarcode()->getAztec()->setECIEncoding(ECIEncodings::UTF_8); + * $generator->save("test.bmp", BarcodeImageFormat::BMP); + * + * @code + * //Bytes mode + * $encodedArr = [0xFF, 0xFE, 0xFD, 0xFC, 0xFB, 0xFA, 0xF9]; + * //encode array to string + * $strBld = ""; + * foreach($encodedArr as bval) + * $strBld->append(chr(bval)); + * $codetext = $strBld->toString(); + * $generator = new BarcodeGenerator(EncodeTypes::AZTEC, $codetext); + * $generator->getParameters()->getBarcode()->getAztec()->setAztecEncodeMode(AztecEncodeMode::BYTES); + * $generator->save("test.bmp", BarcodeImageFormat::BMP); + * + * @code + * //Extended codetext mode + * //create codetext + * $textBuilder = new AztecExtCodetextBuilder(); + * $textBuilder->addECICodetext(ECIEncodings::Win1251, "Will"); + * $textBuilder->addECICodetext(ECIEncodings::UTF8, "犬Right狗"); + * $textBuilder->addECICodetext(ECIEncodings::UTF16BE, "犬Power狗"); + * $textBuilder->addPlainCodetext("Plain text"); + * //generate codetext + * $codetext = $textBuilder->getExtendedCodetext(); + * //generate + * $generator = new BarcodeGenerator(EncodeTypes::AZTEC, codetext); + * $generator->getParameters()->getBarcode()->getAztec()->setAztecEncodeMode(AztecEncodeMode::EXTENDED_CODETEXT); + * $generator->getParameters()->getBarcode()->getCodeTextParameters()->setTwoDDisplayText("My Text"); + * $generator->save("test.bmp", BarcodeImageFormat::BMP); + * + *+ *+ * In Auto mode, the CodeText is encoded with maximum data compactness. + * Unicode characters are re-encoded in the ECIEncoding specified encoding with the insertion of an ECI identifier. + * If a character is found that is not supported by the selected ECI encoding, an exception is thrown. + *
+ */ + const AUTO = 0; + + /** + *+ * Encode codetext as plain bytes. If it detects any Unicode character, the character will be encoded as two bytes, lower byte first. + *
+ * @deprecated + */ + const BYTES = 1; + + /** + *+ *
Extended mode which supports multi ECI modes.
+ *It is better to use AztecExtCodetextBuilder for extended codetext generation.
+ *Use Display2DText property to set visible text to removing managing characters.
+ *ECI identifiers are set as single slash and six digits identifier "\000026" - UTF8 ECI identifier
+ *All unicode characters after ECI identifier are automatically encoded into correct character codeset.
+ * + * @deprecated + */ + const EXTENDED_CODETEXT = 2; + /** + *+ *
Extended mode which supports multi ECI modes.
+ *It is better to use AztecExtCodetextBuilder for extended codetext generation.
+ *Use Display2DText property to set visible text to removing managing characters.
+ *ECI identifiers are set as single slash and six digits identifier "\000026" - UTF8 ECI identifier
+ *All unicode characters after ECI identifier are automatically encoded into correct character codeset.
+ * + */ + const EXTENDED = 3; + + /** + *+ * In Binary mode, the CodeText is encoded with maximum data compactness. + * If a Unicode character is found, an exception is thrown. + *
+ */ + const BINARY = 4; + + /** + *+ * In ECI mode, the entire message is re-encoded in the ECIEncoding specified encoding with the insertion of an ECI identifier. + * If a character is found that is not supported by the selected ECI encoding, an exception is thrown. + * Please note that some old (pre 2006) scanners may not support this mode. + *
+ */ + const ECI = 5; +} \ No newline at end of file diff --git a/lib/Generation/AztecExtCodetextBuilder.php b/lib/Generation/AztecExtCodetextBuilder.php new file mode 100644 index 00000000..a3c4641a --- /dev/null +++ b/lib/Generation/AztecExtCodetextBuilder.php @@ -0,0 +1,53 @@ + + *Extended codetext generator for Aztec barcodes for ExtendedCodetext Mode of AztecEncodeMode
+ *Use TwoDDisplayText property of BarcodeGenerator to set visible text to removing managing characters.
+ *+ * This sample shows how to use AztecExtCodetextBuilder in Extended Mode. + *+ * @code + * //create codetext + * $textBuilder = new AztecExtCodetextBuilder(); + * $textBuilder->addECICodetext(ECIEncodings::Win1251, "Will"); + * $textBuilder->addECICodetext(ECIEncodings::UTF8, "犬Right狗"); + * $textBuilder->addECICodetext(ECIEncodings::UTF16BE, "犬Power狗"); + * $textBuilder->addPlainCodetext("Plain text"); + * //generate codetext + * $codetext = $textBuilder->getExtendedCodetext(); + * //generate + * $generator = new BarcodeGenerator(EncodeTypes::AZTEC, $codetext); + * $generator->getParameters()->getBarcode()->getCodeTextParameters()->setwoDDisplayText("My Text"); + * $generator->save("test.bmp", BarcodeImageFormat::BMP); + */ +class AztecExtCodetextBuilder extends ExtCodetextBuilder +{ + function __construct() + { + try + { + parent::__construct(); + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + public function init(): void + { + } + + protected function getExtCodetextBuilderType(): int + { + return ExtCodetextBuilderType::AZTEC_EXT_CODETEXT_BUILDER; + } +} \ No newline at end of file diff --git a/lib/Generation/AztecParameters.php b/lib/Generation/AztecParameters.php new file mode 100644 index 00000000..ded2492b --- /dev/null +++ b/lib/Generation/AztecParameters.php @@ -0,0 +1,276 @@ +aztecParametersDto; + } + + private function setAztecParametersDto(AztecParametersDTO $aztecParametersDto): void + { + $this->aztecParametersDto = $aztecParametersDto; + } + + function __construct(AztecParametersDTO $aztecParametersDto) + { + $this->aztecParametersDto = $aztecParametersDto; + $this->obtainDto(); + $this->initFieldsFromDto(); + } + + public function obtainDto(...$args) + { + } + + public function initFieldsFromDto(): void + { + } + + /** + *+ * Gets a Aztec encode mode. + * Default value: Auto. + *
+ */ + public function getAztecEncodeMode(): int + { + return $this->getAztecParametersDto()->aztecEncodeMode; + } + + /** + *+ * Sets a Aztec encode mode. + * Default value: Auto. + *
+ */ + public function setAztecEncodeMode(int $value): void + { + $this->getAztecParametersDto()->aztecEncodeMode = $value; + } + + /** + *+ * Gets ECI encoding. Used when AztecEncodeMode is Auto. + * Default value: ISO-8859-1 + *
+ */ + public function getECIEncoding(): int + { + return $this->getAztecParametersDto()->ECIEncoding; + } + + /** + *+ * Gets ECI encoding. Used when AztecEncodeMode is Auto. + * Default value: ISO-8859-1 + *
+ */ + public function setECIEncoding(int $value): void + { + $this->getAztecParametersDto()->ECIEncoding = $value; + } + + /** + *+ * Barcode ID for Structured Append mode of Aztec barcode. Barcode ID should be in range from 1 to barcodes count. + * Default value: 0 + *
+ */ + public function getStructuredAppendBarcodeId(): int + { + return $this->getAztecParametersDto()->structuredAppendBarcodeId; + } + + /** + *+ * Barcode ID for Structured Append mode of Aztec barcode. Barcode ID should be in range from 1 to barcodes count. + * Default value: 0 + *
+ */ + public function setStructuredAppendBarcodeId(int $value): void + { + $this->getAztecParametersDto()->structuredAppendBarcodeId = $value; + } + + /** + *+ * Barcodes count for Structured Append mode of Aztec barcode. Barcodes count should be in range from 1 to 26. + * Default value: 0 + *
+ */ + public function getStructuredAppendBarcodesCount(): int + { + return $this->getAztecParametersDto()->structuredAppendBarcodesCount; + } + + /** + *+ * Barcodes count for Structured Append mode of Aztec barcode. Barcodes count should be in range from 1 to 26. + * Default value: 0 + *
+ */ + public function setStructuredAppendBarcodesCount(int $value): void + { + $this->getAztecParametersDto()->structuredAppendBarcodesCount = $value; + } + + /** + *+ * File ID for Structured Append mode of Aztec barcode (optional field). File ID should not contain spaces. + * Default value: empty string + *
+ */ + public function getStructuredAppendFileId(): string + { + return $this->getAztecParametersDto()->structuredAppendFileId; + } + + /** + *+ * File ID for Structured Append mode of Aztec barcode (optional field). File ID should not contain spaces. + * Default value: empty string + *
+ */ + public function setStructuredAppendFileId(string $value): void + { + $this->getAztecParametersDto()->structuredAppendFileId = $value; + } + + /** + *+ * Level of error correction of Aztec types of barcode. + * Value should between 5 to 95. + *
+ */ + public function getAztecErrorLevel(): int + { + return $this->getAztecParametersDto()->aztecErrorLevel; + } + + /** + *+ * Level of error correction of Aztec types of barcode. + * Value should between 5 to 95. + *
+ */ + public function setAztecErrorLevel(int $value): void + { + $this->getAztecParametersDto()->aztecErrorLevel = $value; + } + + /** + *+ * Gets a Aztec Symbol mode. + * Default value: AztecSymbolMode.Auto. + *
+ */ + public function getAztecSymbolMode(): int + { + return $this->getAztecParametersDto()->aztecSymbolMode; + } + + /** + *+ * Sets a Aztec Symbol mode. + * Default value: AztecSymbolMode.Auto. + *
+ */ + public function setAztecSymbolMode(int $value): void + { + $this->getAztecParametersDto()->aztecSymbolMode = $value; + } + + /** + *+ * Gets layers count of Aztec symbol. Layers count should be in range from 1 to 3 for Compact mode and + * in range from 1 to 32 for Full Range mode. + * Default value: 0 (auto). + *
+ */ + public function getLayersCount(): int + { + return $this->getAztecParametersDto()->layersCount; + } + + /** + *+ * Sets layers count of Aztec symbol. Layers count should be in range from 1 to 3 for Compact mode and + * in range from 1 to 32 for Full Range mode. + * Default value: 0 (auto). + *
+ */ + public function setLayersCount(int $value): void + { + $this->getAztecParametersDto()->layersCount = $value; + } + + /** + *+ * Used to instruct the reader to interpret the data contained within the symbol + * as programming for reader initialization. + *
+ */ + public function isReaderInitialization(): bool + { + return $this->getAztecParametersDto()->isReaderInitialization; + } + + /** + *+ * Used to instruct the reader to interpret the data contained within the symbol + * as programming for reader initialization. + *
+ */ + public function setReaderInitialization(bool $value): void + { + $this->getAztecParametersDto()->isReaderInitialization = $value; + } + + /** + *+ * Height/Width ratio of 2D BarCode module. + *
+ */ + public function getAspectRatio(): float + { + return $this->getAztecParametersDto()->aspectRatio; + } + + /** + *+ * Height/Width ratio of 2D BarCode module. + *
+ */ + public function setAspectRatio(float $value): void + { + $this->getAztecParametersDto()->aspectRatio = $value; + } + + /** + *+ * Returns a human-readable string representation of this {@code AztecParameters}. + *
+ * @return string that represents this {@code AztecParameters}. + */ + public function toString(): string + { + $thriftConnection = new ThriftConnection(); + $client = $thriftConnection->openConnection(); + $str = $client->AztecParameters_toString($this->getAztecParametersDto()); + $thriftConnection->closeConnection(); + + return $str; + } +} \ No newline at end of file diff --git a/lib/Generation/AztecSymbolMode.php b/lib/Generation/AztecSymbolMode.php new file mode 100644 index 00000000..bd3d6b40 --- /dev/null +++ b/lib/Generation/AztecSymbolMode.php @@ -0,0 +1,38 @@ +setCodeText("125"); + * $generator->getParameters()->getBarcode()->getAztec()->setAztecSymbolMode(AztecSymbolMode::RUNE); + * $generator->save("test.png", "PNG"); + * @endcode + */ +class AztecSymbolMode +{ + /** + * Specifies to automatically pick up the best symbol (COMPACT or FULL-range) for Aztec. + * This is default value. + */ + const AUTO = "0"; + /** + * Specifies the COMPACT symbol for Aztec. + * Aztec COMPACT symbol permits only 1, 2, 3 or 4 layers. + */ + const COMPACT = "1"; + /** + * Specifies the FULL-range symbol for Aztec. + * Aztec FULL-range symbol permits from 1 to 32 layers. + */ + const FULL_RANGE = "2"; + /** + * Specifies the RUNE symbol for Aztec. + * Aztec Runes are a series of small but distinct machine-readable marks. It permits only number value from 0 to 255. + */ + const RUNE = "3"; +} \ No newline at end of file diff --git a/lib/Generation/BarCodeImageFormat.php b/lib/Generation/BarCodeImageFormat.php new file mode 100644 index 00000000..e8363bbd --- /dev/null +++ b/lib/Generation/BarCodeImageFormat.php @@ -0,0 +1,55 @@ +setCodeText("123ABC"); + * @endcode + */ +class BarcodeGenerator implements Communicator +{ + private $barcodeGeneratorDto; + + private function getBarcodeGeneratorDto(): BarcodeGeneratorDTO + { + return $this->barcodeGeneratorDto; + } + + private function setBarcodeGeneratorDto(BarcodeGeneratorDTO $barcodeGeneratorDto): void + { + $this->barcodeGeneratorDto = $barcodeGeneratorDto; + } + + private $parameters; + + /** + * BarcodeGenerator constructor. + * @param int|null $encodeType Barcode symbology type. Use EncodeTypes class to setup a symbology + * @param string|null $codeText Text to be encoded. Should be encoded in UTF-8 encoding + * @code + * $barcodeGenerator = new BarcodeGenerator(EncodeTypes::EAN_14, "332211"); + * @endcode + * @throws BarcodeException + */ + public function __construct(?int $encodeType, ?string $codeText = null) + { + try + { + $this->barcodeGeneratorDto = $this->obtainDto($encodeType); + $this->getBarcodeGeneratorDto()->barcodeType = $encodeType; + $this->getBarcodeGeneratorDto()->base64CodeText = $codeText; + $this->initFieldsFromDto(); + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + public function obtainDto(...$args): BarcodeGeneratorDTO + { + $thriftConnection = new ThriftConnection(); + $client = $thriftConnection->openConnection(); + $dtoRef = $client->BarcodeGenerator_ctor($args[0]); + $thriftConnection->closeConnection(); + + return $dtoRef; + } + + public function initFieldsFromDto(): void + { + $this->parameters = new BaseGenerationParameters($this->getBarcodeGeneratorDto()->parameters); + } + + /** + * Generation parameters. + * @return BaseGenerationParameters + */ + public function getParameters(): BaseGenerationParameters + { + return $this->parameters; + } + + /** + * Barcode symbology type. + */ + public function getBarcodeType(): int + { + try + { + return $this->getBarcodeGeneratorDto()->barcodeType; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Barcode symbology type. + */ + public function setBarcodeType(int $value): void + { + try + { + $this->getBarcodeGeneratorDto()->barcodeType = $value; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Generate the barcode image under current settings. + * This sample shows how to create and save a barcode image. + * + * @return resource|false GD image resource or false on failure. + * + * @code + * $generator = new BarCodeGenerator(EncodeTypes::CODE_128); + * $image = $generator->generateBarCodeGDImage(); + * @endcode + * + * @throws BarcodeException + */ + public function generateBarCodeGDImage() + { + try + { + if (!extension_loaded('gd')) + throw new BarcodeException("GD extension is not available!", __FILE__, __LINE__); + $base64Image = $this->generateBarCodeImage(BarCodeImageFormat::PNG); + return imagecreatefromstring(base64_decode($base64Image)); + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Generate the barcode image under current settings. + * This sample shows how to create and save a barcode image. + * + * @param int $format value of BarCodeImageFormat (PNG, BMP, JPEG, GIF, EMF) + * @return string base64 representation of image. + * + * @code + * $generator = new BarCodeGenerator(EncodeTypes::CODE_128); + * $image = $generator->generateBarCodeImage(BarCodeImageFormat::PNG); + * @endcode + * + * @throws BarcodeException + */ + public function generateBarCodeImage(int $format, bool $passLicense = false): string + { + try + { + $thriftConnection = new ThriftConnection(); + $client = $thriftConnection->openConnection(); + // Deciding if the license should be used + $licenseContent = $passLicense ? License::getLicenseContent() : null; + // Passing the license or null + $base64Image = $client->BarcodeGenerator_generateBarCodeImage($this->getBarcodeGeneratorDto(), $format, $licenseContent); + $thriftConnection->closeConnection(); + return $base64Image; + } + catch (BarcodeExceptionDTO $be) + { + $msg = $be->message ?? '(no message)'; + $pos = $be->position ?? ''; + $kind = $be->kind ?? ''; + // pass a clear message up so it gets into your report + throw new \Exception("Java error" . + ($kind !== null ? " [$kind]" : "") . + ": $msg\n$pos"); + } + catch (Exception $exc) + { + throw new BarcodeException($exc->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Save barcode image to specific file in specific format. + * @param string $filePath Path to save to. + * @param int $format value of BarCodeImageFormat (PNG, BMP, JPEG, GIF, EMF) + * + * @code + * $generator = new BarCodeGenerator(EncodeTypes::CODE_128); + * $generator->save(file_path, BarCodeImageFormat::PNG); + * @endcode + * @throws BarcodeException + */ + public function save(string $filePath, int $format): void + { + try + { + $image = $this->generateBarCodeImage($format); + file_put_contents($filePath, base64_decode($image)); + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Text to be encoded. + */ + public function getCodeText(): string + { + try + { + return $this->getBarcodeGeneratorDto()->base64CodeText; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + *+ *
+ * Encodes the Unicode {@code codeText} into a byte sequence using the specified {@code encoding}. + * UTF-8 is the most commonly used encoding. + * If the encoding supports it and {@code insertBOM} is set to {@code true}, the function includes a + * {@code byte order mark (BOM)}. + *
+ *+ * This function is intended for use with 2D barcodes only (e.g., Aztec, QR, DataMatrix, PDF417, MaxiCode, DotCode, HanXin, RectMicroQR, etc.). + * It enables manual encoding of Unicode text using national or special encodings; however, this method is considered obsolete in modern applications. + * For modern use cases, {@code ECI} encoding is recommended for Unicode data. + *
+ *+ * Using this function with 1D barcodes, GS1-compliant barcodes (including 2D), or HIBC barcodes (including 2D) is not supported by the corresponding barcode standards and may lead to unpredictable results. + *
+ *+ * @param codeText CodeText string + * @param encoding Applied encoding + * @param insertBOM + * Indicates whether to insert a byte order mark (BOM) when the specified encoding supports it (e.g., UTF-8, UTF-16, UTF-32). + * If set to {@code true}, the BOM is added; if {@code false}, the BOM is omitted even if the encoding normally uses one. + * + */ + public function setCodeText($codeText, ?string $encoding = null, ?bool $insertBOM = false): void + { + try + { + if (is_array($codeText)) + { + $this->getBarcodeGeneratorDto()->base64CodeText = (base64_encode(pack("C*", ...$codeText))); + $this->getBarcodeGeneratorDto()->codeTextType = Base64CodeTextType::BYTE; + } else + { + $this->getBarcodeGeneratorDto()->base64CodeText = $codeText; + $this->getBarcodeGeneratorDto()->codeTextType = Base64CodeTextType::STRING; + if (!is_null($encoding) && strlen($encoding) > 0) + $this->getBarcodeGeneratorDto()->encoding = $encoding; + $this->getBarcodeGeneratorDto()->insertBOM = $insertBOM; + } + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Exports BarCode properties to the xml-file specified + * @param string $xmlFile The path to xml file + * @return bool Whether or not export completed successfully. + * Returns True in case of success; False Otherwise + */ + public function exportToXml(string $xmlFile): bool + { + try + { + $thriftConnection = new ThriftConnection(); + $client = $thriftConnection->openConnection(); + //TODO BARCODEPHP-677 Implement the passing of license file content from PHP to Java + $xmlData = $client->BarcodeGenerator_exportToXml($this->barcodeGeneratorDto); + $thriftConnection->closeConnection(); + $isContentExported = $xmlData != null; + if ($isContentExported) + { + file_put_contents($xmlFile, $xmlData); + } + return $isContentExported; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Import BarCode properties from xml file + * @param string $resource The name of the xml file or path to http resource + * @return \Aspose\Barcode\Recognition\BarCodeReader + * @throws BarcodeException + */ + public static function importFromXml($resource): BarcodeGenerator + { + try + { + if (CommonUtility::isPath($resource)) + { + $resource = fopen($resource, "r"); + } + $xmlData = (stream_get_contents($resource)); + $thriftConnection = new ThriftConnection(); + $client = $thriftConnection->openConnection(); + + $barCodeGeneratorDto = $client->BarcodeGenerator_importFromXml($xmlData); + $thriftConnection->closeConnection(); + + return BarcodeGenerator::construct($barCodeGeneratorDto); + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + private static function construct(BarcodeGeneratorDTO $barCodeGeneratorDto): BarcodeGenerator + { + $barCodeGenerator = new BarcodeGenerator(0, null); + $barCodeGenerator->setBarcodeGeneratorDto($barCodeGeneratorDto); + $barCodeGenerator->initFieldsFromDto(); + return $barCodeGenerator; + } +} \ No newline at end of file diff --git a/lib/Generation/BarcodeParameters.php b/lib/Generation/BarcodeParameters.php new file mode 100644 index 00000000..0b302f75 --- /dev/null +++ b/lib/Generation/BarcodeParameters.php @@ -0,0 +1,807 @@ +barcodeParametersDto; + } + + private function setBarcodeParametersDto(BarcodeParametersDTO $barcodeParametersDto): void + { + $this->barcodeParametersDto = $barcodeParametersDto; + } + + private $xDimension; + private $barHeight; + private $codeTextParameters; + private $postal; + private $australianPost; + private $codablock; + private $dataBar; + private $gs1CompositeBar; + private $dataMatrix; + private $code16K; + private $itf; + private $qr; + private $pdf417; + private $maxiCode; + private $aztec; + private $code128; + private $codabar; + private $coupon; + private $hanXin; + private $supplement; + private $dotCode; + private $padding; + private $patchCode; + private $barWidthReduction; + + function __construct(BarcodeParametersDTO $barcodeParametersDto) + { + $this->barcodeParametersDto = $barcodeParametersDto; + $this->obtainDto(); + $this->initFieldsFromDto(); + } + + public function obtainDto(...$args) + { + } + + public function initFieldsFromDto(): void + { + try + { + $this->xDimension = new Unit($this->getBarcodeParametersDto()->xDimension); + $this->barHeight = new Unit($this->getBarcodeParametersDto()->barHeight); + $this->codeTextParameters = new CodetextParameters($this->getBarcodeParametersDto()->codeTextParameters); + $this->postal = new PostalParameters($this->getBarcodeParametersDto()->postal); + $this->australianPost = new AustralianPostParameters($this->getBarcodeParametersDto()->australianPost); + $this->codablock = new CodablockParameters($this->getBarcodeParametersDto()->codablock); + $this->dataBar = new DataBarParameters($this->getBarcodeParametersDto()->dataBar); + $this->gs1CompositeBar = new GS1CompositeBarParameters($this->getBarcodeParametersDto()->gs1CompositeBar); + $this->dataMatrix = new DataMatrixParameters($this->getBarcodeParametersDto()->dataMatrix); + $this->code16K = new Code16KParameters($this->getBarcodeParametersDto()->code16K); + $this->itf = new ITFParameters($this->getBarcodeParametersDto()->itf); + $this->qr = new QrParameters($this->getBarcodeParametersDto()->qr); + $this->pdf417 = new Pdf417Parameters($this->getBarcodeParametersDto()->pdf417); + $this->maxiCode = new MaxiCodeParameters($this->getBarcodeParametersDto()->maxiCode); + $this->aztec = new AztecParameters($this->getBarcodeParametersDto()->aztec); + $this->code128 = new Code128Parameters($this->getBarcodeParametersDto()->code128); + $this->codabar = new CodabarParameters($this->getBarcodeParametersDto()->codabar); + $this->coupon = new CouponParameters($this->getBarcodeParametersDto()->coupon); + $this->hanXin = new HanXinParameters($this->getBarcodeParametersDto()->hanXin); + $this->supplement = new SupplementParameters($this->getBarcodeParametersDto()->supplement); + $this->dotCode = new DotCodeParameters($this->getBarcodeParametersDto()->dotCode); + $this->padding = new Padding($this->getBarcodeParametersDto()->padding); + $this->patchCode = new PatchCodeParameters($this->getBarcodeParametersDto()->patchCode); + $this->barWidthReduction = new Unit($this->getBarcodeParametersDto()->barWidthReduction); + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * PatchCode parameters. + */ + public function getPatchCode(): PatchCodeParameters + { + return $this->patchCode; + } + + /** + * PatchCode parameters. + */ + private function setPatchCode(PatchCodeParameters $value) + { + try + { + $this->patchCode = $value; + $this->getBarcodeParametersDto()->patchCode = $value->getPatchCodeParametersDto(); + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * x-dimension is the smallest width of the unit of BarCode bars or spaces. + * Increase this will increase the whole barcode image width. + * Ignored if AutoSizeMode property is set to AutoSizeMode::NEAREST or AutoSizeMode::INTERPOLATION. + */ + public function getXDimension(): Unit + { + try + { + return $this->xDimension; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * x-dimension is the smallest width of the unit of BarCode bars or spaces. + * Increase this will increase the whole barcode image width. + * Ignored if AutoSizeMode property is set to AutoSizeMode::NEAREST or AutoSizeMode::INTERPOLATION. + * + * @throws BarcodeException + */ + public function setXDimension(Unit $value): void + { + try + { + $this->getBarcodeParametersDto()->xDimension = $value->getUnitDto(); + $this->xDimension = $value; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Get bars reduction value that is used to compensate ink spread while printing. + * @return Unit value of BarWidthReduction + */ + public function getBarWidthReduction(): Unit + { + try + { + return $this->barWidthReduction; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Sets bars reduction value that is used to compensate ink spread while printing. + */ + public function setBarWidthReduction(Unit $value): void + { + try + { + $this->getBarcodeParametersDto()->barWidthReduction = $value->getUnitDto(); + $this->barWidthReduction = $value; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Height of 1D barcodes' bars in Unit value. + * Ignored if AutoSizeMode property is set to AutoSizeMode::NEAREST or AutoSizeMode::INTERPOLATION. + */ + public function getBarHeight(): Unit + { + return $this->barHeight; + } + + /** + * Height of 1D barcodes' bars in Unit value. + * Ignored if AutoSizeMode property is set to utoSizeMode::NEAREST or AutoSizeMode::INTERPOLATION. + * + * @throws BarcodeException + */ + public function setBarHeight(Unit $value): void + { + try + { + $this->getBarcodeParametersDto()->barHeight = $value->getUnitDto(); + $this->barHeight = $value; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Bars color. + * Default value: #000000 + */ + public function getBarColor(): string + { + try + { + $hexColor = strtoupper(dechex($this->getBarcodeParametersDto()->barColor)); + while (strlen($hexColor) < 6) + { + $hexColor = "0" . $hexColor; + } + $hexColor = "#" . $hexColor; + return $hexColor; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Bars color. + * Default value: #000000. + */ + public function setBarColor(string $value): void + { + try + { + if (substr($value, 0, 1) == '#') + $value = substr($value, 1, strlen($value) - 1); + $this->getBarcodeParametersDto()->barColor = (hexdec($value)); + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Barcode paddings. + * Default value: 5pt 5pt 5pt 5pt. + */ + public function getPadding(): Padding + { + try + { + return $this->padding; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Barcode paddings. + * Default value: 5pt 5pt 5pt 5pt. + */ + function setPadding(Padding $value): void + { + try + { + $this->getBarcodeParametersDto()->padding = $value->getPaddingDto(); + $this->padding = $value; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Always display checksum digit in the human readable text for Code128 and GS1Code128 barcodes. + */ + public function getChecksumAlwaysShow(): bool + { + try + { + return $this->getBarcodeParametersDto()->checksumAlwaysShow; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Always display checksum digit in the human readable text for Code128 and GS1Code128 barcodes. + */ + public function setChecksumAlwaysShow(bool $checksumAlwaysShow): void + { + try + { + $this->getBarcodeParametersDto()->checksumAlwaysShow = $checksumAlwaysShow; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Enable checksum during generation 1D barcodes. + * Default is treated as Yes for symbology which must contain checksum, as No where checksum only possible. + * Checksum is possible: Code39 Standard/Extended, Standard2of5, Interleaved2of5, Matrix2of5, ItalianPost25, DeutschePostIdentcode, DeutschePostLeitcode, VIN, Codabar + * Checksum always used: Rest symbology + */ + + public function isChecksumEnabled(): int + { + try + { + return $this->getBarcodeParametersDto()->isChecksumEnabled; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Enable checksum during generation 1D barcodes. + * Default is treated as Yes for symbology which must contain checksum, as No where checksum only possible. + * Checksum is possible: Code39 Standard/Extended, Standard2of5, Interleaved2of5, Matrix2of5, ItalianPost25, DeutschePostIdentcode, DeutschePostLeitcode, VIN, Codabar + * Checksum always used: Rest symbology + */ + public function setChecksumEnabled(int $value): void + { + try + { + $this->getBarcodeParametersDto()->isChecksumEnabled = $value; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Indicates whether explains the character "\" as an escape character in CodeText property. Used for Pdf417, DataMatrix, Code128 only + * If the EnableEscape is true, "\" will be explained as a special escape character. Otherwise, "\" acts as normal characters. + * Aspose.BarCode supports inputing decimal ascii code and mnemonic for ASCII control-code characters. For example, \013 and \\CR stands for CR. + */ + public function getEnableEscape(): bool + { + try + { + return $this->getBarcodeParametersDto()->enableEscape; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Indicates whether explains the character "\" as an escape character in CodeText property. Used for Pdf417, DataMatrix, Code128 only + * If the EnableEscape is true, "\" will be explained as a special escape character. Otherwise, "\" acts as normal characters. + *+ *This example shows how to use {@code SetCodeText} with or without a BOM for 2D barcodes.
+ *+ * //Encode codetext using UTF-8 with BOM + * $gen = new BarcodeGenerator(EncodeTypes::QR, null); + * $gen->setCodeText("車種名", "UTF-8", true); + * $gen->save("barcode.png", BarCodeImageFormat::PNG); + * + * $reader = new BarCodeReader("barcode.png", null, DecodeType::QR); + * $results = $reader->readBarCodes(); + * for($i = 0; $i < sizeof($results); $i++) + * { + * $result = $results[$i]; + * echo ("BarCode CodeText: " . $result->getCodeText()); + * } + * //Encode codetext using UTF-8 without BOM + * $gen = new BarcodeGenerator(EncodeTypes::QR, null); + * $gen->setCodeText("車種名", "UTF-8", false); + * $gen->save("barcode.png", BarCodeImageFormat::PNG); + * $reader = new BarCodeReader("barcode.png", null, DecodeType.QR); + * $results = $reader->readBarCodes(); + * for($i = 0; $i < sizeof($results); $i++) + * { + * $result = $results[$i]; + * echo ("BarCode CodeText: " . $result->getCodeText()); + * } + *+ *
Aspose.BarCode supports inputing decimal ascii code and mnemonic for ASCII control-code characters. For example, \013 and \\CR stands for CR. + */ + public function setEnableEscape(bool $value): void + { + try + { + $this->getBarcodeParametersDto()->enableEscape = $value; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Wide bars to Narrow bars ratio. + * Default value: 3, that is, wide bars are 3 times as wide as narrow bars. + * Used for ITF, PZN, PharmaCode, Standard2of5, Interleaved2of5, Matrix2of5, ItalianPost25, IATA2of5, VIN, DeutschePost, OPC, Code32, DataLogic2of5, PatchCode, Code39Extended, Code39Standard + * + * @exception IllegalArgumentException + * The WideNarrowRatio parameter value is less than or equal to 0. + */ + public function getWideNarrowRatio(): float + { + try + { + return $this->getBarcodeParametersDto()->wideNarrowRatio; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Wide bars to Narrow bars ratio. + * Default value: 3, that is, wide bars are 3 times as wide as narrow bars. + * Used for ITF, PZN, PharmaCode, Standard2of5, Interleaved2of5, Matrix2of5, ItalianPost25, IATA2of5, VIN, DeutschePost, OPC, Code32, DataLogic2of5, PatchCode, Code39Extended, Code39Standard + * + * @exception IllegalArgumentException + * @param float $value The WideNarrowRatio parameter value is less than or equal to 0. + */ + public function setWideNarrowRatio(float $value): void + { + try + { + $this->getBarcodeParametersDto()->wideNarrowRatio = $value; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Codetext parameters. + */ + public function getCodeTextParameters(): CodetextParameters + { + try + { + return $this->codeTextParameters; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * + * Only for 1D barcodes. + * @return bool Gets a value indicating whether bars filled. + * @throws BarcodeException + */ + public function getFilledBars(): bool + { + try + { + return $this->getBarcodeParametersDto()->filledBars; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Sets a value indicating whether bars filled. + * Only for 1D barcodes. + * @param bool $value Sets a value indicating whether bars filled. + * @throws BarcodeException + */ + public function setFilledBars(bool $value): void + { + try + { + $this->getBarcodeParametersDto()->filledBars = $value; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Postal parameters. Used for Postnet, Planet. + */ + public function getPostal(): PostalParameters + { + try + { + return $this->postal; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * AustralianPost barcode parameters. + */ + public function getAustralianPost(): AustralianPostParameters + { + try + { + return $this->australianPost; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Databar parameters. + */ + public function getDataBar(): DataBarParameters + { + try + { + return $this->dataBar; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * GS1 Composite Bar parameters. + * + * This sample shows how to create and save a GS1 Composite Bar image. + * Note that 1D codetext and 2D codetext are separated by symbol '/' + * + * $codetext = "(01)03212345678906/(21)A1B2C3D4E5F6G7H8"; + * $generator = new BarcodeGenerator(EncodeTypes::GS_1_COMPOSITE_BAR, $codetext); + * + * $generator->getParameters()->getBarcode()->getGS1CompositeBar()->setLinearComponentType(EncodeTypes::GS_1_CODE_128); + * $generator->getParameters()->getBarcode()->getGS1CompositeBar()->setTwoDComponentType(TwoDComponentType::CC_A); + * + * // Aspect ratio of 2D component + * $generator->getParameters()->getBarcode()->getPdf417()->setAspectRatio(3); + * + * // X-Dimension of 1D and 2D components + * $generator->getParameters()->getBarcode()->getXDimension()->setPixels(3); + * /// + * // Height of 1D component + * $generator->getParameters()->getBarcode()->getBarHeight()->setPixels(100); + * /// + * $generator->save("test.png", BarcodeImageFormat::PNG); + * + * @return GS1CompositeBarParameters GS1 Composite Bar parameters. + */ + public function getGS1CompositeBar(): GS1CompositeBarParameters + { + return $this->gs1CompositeBar; + } + + /** + * GS1 Composite Bar parameters. + * + * This sample shows how to create and save a GS1 Composite Bar image. + * Note that 1D codetext and 2D codetext are separated by symbol '/' + * + * $codetext = "(01)03212345678906/(21)A1B2C3D4E5F6G7H8"; + * $generator = new BarcodeGenerator(EncodeTypes::GS_1_COMPOSITE_BAR, $codetext); + * + * $generator->getParameters()->getBarcode()->getGS1CompositeBar()->setLinearComponentType(EncodeTypes::GS_1_CODE_128); + * $generator->getParameters()->getBarcode()->getGS1CompositeBar()->setTwoDComponentType(TwoDComponentType::CC_A); + * + * // Aspect ratio of 2D component + * $generator->getParameters()->getBarcode()->getPdf417()->setAspectRatio(3); + * + * // X-Dimension of 1D and 2D components + * $generator->getParameters()->getBarcode()->getXDimension()->setPixels(3); + * /// + * // Height of 1D component + * $generator->getParameters()->getBarcode()->getBarHeight()->setPixels(100); + * /// + * $generator->save("test.png", BarcodeImageFormat::PNG); + */ + public function setGS1CompositeBar(GS1CompositeBarParameters $value): void + { + $this->gs1CompositeBar = $value; + $this->getBarcodeParametersDto()->gs1CompositeBar = $value->getGS1CompositeBarParametersDto(); + } + + /** + * Codablock parameters. + */ + public function getCodablock(): CodablockParameters + { + try + { + return $this->codablock; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * DataMatrix parameters. + */ + public function getDataMatrix(): DataMatrixParameters + { + try + { + return $this->dataMatrix; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Code16K parameters. + */ + public function getCode16K(): Code16KParameters + { + try + { + return $this->code16K; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * DotCode parameters. + */ + public function getDotCode(): DotCodeParameters + { + try + { + return $this->dotCode; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * ITF parameters. + */ + public function getITF(): ITFParameters + { + try + { + return $this->itf; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * PDF417 parameters. + */ + public function getPdf417(): Pdf417Parameters + { + try + { + return $this->pdf417; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * QR parameters. + */ + public function getQR(): QrParameters + { + try + { + return $this->qr; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Supplement parameters. Used for Interleaved2of5, Standard2of5, EAN13, EAN8, UPCA, UPCE, ISBN, ISSN, ISMN. + */ + public function getSupplement(): SupplementParameters + { + try + { + return $this->supplement; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * MaxiCode parameters. + */ + public function getMaxiCode(): MaxiCodeParameters + { + try + { + return $this->maxiCode; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Aztec parameters. + */ + public function getAztec(): AztecParameters + { + try + { + return $this->aztec; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + *+ * Code128 parameters. + *
+ */ + public function getCode128(): Code128Parameters + { + return $this->code128; + } + + /** + * Codabar parameters. + */ + public function getCodabar(): CodabarParameters + { + try + { + return $this->codabar; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Coupon parameters. Used for UpcaGs1DatabarCoupon, UpcaGs1Code128Coupon. + */ + public function getCoupon(): CouponParameters + { + try + { + return $this->coupon; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * HanXin parameters. + */ + public function getHanXin(): HanXinParameters + { + return $this->hanXin; + } +} \ No newline at end of file diff --git a/lib/Generation/Base64CodeTextType.php b/lib/Generation/Base64CodeTextType.php new file mode 100644 index 00000000..c85cd419 --- /dev/null +++ b/lib/Generation/Base64CodeTextType.php @@ -0,0 +1,9 @@ +baseGenerationParametersDto; + } + + private function setBaseGenerationParametersDto(BaseGenerationParametersDTO $baseGenerationParametersDto): void + { + $this->baseGenerationParametersDto = $baseGenerationParametersDto; + } + + private $captionAbove; + private $captionBelow; + private $barcodeParameters; + private $borderParameters; + private $image; + + private $imageWidth; + private $imageHeight; + + function __construct(BaseGenerationParametersDTO $baseGenerationParametersDto) + { + $this->baseGenerationParametersDto = $baseGenerationParametersDto; + $this->obtainDto(); + $this->initFieldsFromDto(); + } + + public function obtainDto(...$args) + { + } + + public function initFieldsFromDto(): void + { + try + { + $this->captionAbove = new CaptionParameters($this->getBaseGenerationParametersDto()->captionAbove); + $this->captionBelow = new CaptionParameters($this->getBaseGenerationParametersDto()->captionBelow); + $this->barcodeParameters = new BarcodeParameters($this->getBaseGenerationParametersDto()->barcode); + $this->borderParameters = new BorderParameters($this->getBaseGenerationParametersDto()->border); + $this->imageWidth = new Unit($this->getBaseGenerationParametersDto()->imageWidth); + $this->imageHeight = new Unit($this->getBaseGenerationParametersDto()->imageHeight); + $this->image = new ImageParameters($this->getBaseGenerationParametersDto()->image); + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + *+ * Gets a value indicating whether is used anti-aliasing mode to render image + *
+ */ + public function getUseAntiAlias(): bool + { + return $this->getBaseGenerationParametersDto()->useAntiAlias; + } + + /** + *+ * Sets a value indicating whether is used anti-aliasing mode to render image + *
+ */ + public function setUseAntiAlias(bool $value): void + { + $this->getBaseGenerationParametersDto()->useAntiAlias = $value; + } + + /** + * Background color of the barcode image. + * Default value: #FFFFFF + * @return string value of background color. + */ + public function getBackColor(): string + { + try + { + $hexColor = strtoupper(dechex($this->getBaseGenerationParametersDto()->backColor)); + while (strlen($hexColor) < 6) + { + $hexColor = "0" . $hexColor; + } + $hexColor = "#" . $hexColor; + return $hexColor; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Background color of the barcode image. + * Default value: #FFFFFF + * @param string $hexValue value of background color. + * @throws BarcodeException + */ + public function setBackColor(string $hexValue): void + { + try + { + if ($hexValue[0] == '#') + $hexValue = substr($hexValue, 1, strlen($hexValue) - 1); + $this->getBaseGenerationParametersDto()->backColor = hexdec($hexValue); + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Gets the resolution of the BarCode image. + * One value for both dimensions. + * Default value: 96 dpi. + * @return float The Resolution parameter value is less than or equal to 0. + * @throws BarcodeException + */ + public function getResolution(): float + { + try + { + return $this->getBaseGenerationParametersDto()->resolution; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Sets the resolution of the BarCode image. + * One value for both dimensions. + * Default value: 96 dpi. + * @param float $value The Resolution parameter value is less than or equal to 0. + * @throws BarcodeException + */ + public function setResolution(float $value): void + { + try + { + $this->updateResolution($value); + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + private function updateResolution(float $newResolution) + { + $this->getBaseGenerationParametersDto()->resolution = $newResolution; + + $thriftConnection = new ThriftConnection(); + $client = $thriftConnection->openConnection(); + $resolutionUpdatedParametersDto = $client->BaseGenerationParameters_updateResolution($this->getBaseGenerationParametersDto(), $newResolution); + $thriftConnection->closeConnection(); + + + $this->getBaseGenerationParametersDto()->captionAbove = $resolutionUpdatedParametersDto->captionAbove; + $this->getBaseGenerationParametersDto()->captionBelow = $resolutionUpdatedParametersDto->captionBelow; + $this->getBaseGenerationParametersDto()->barcode = $resolutionUpdatedParametersDto->barcode; + $this->getBaseGenerationParametersDto()->border = $resolutionUpdatedParametersDto->border; + $this->getBaseGenerationParametersDto()->imageWidth = $resolutionUpdatedParametersDto->imageWidth; + $this->getBaseGenerationParametersDto()->imageHeight = $resolutionUpdatedParametersDto->imageHeight; + $this->getBaseGenerationParametersDto()->image = $resolutionUpdatedParametersDto->image; + + $this->initFieldsFromDto(); + } + + /** + * Image parameters. See. + * @return + */ + public function getImage(): ImageParameters + { + return $this->image; + } + + /** + * BarCode image rotation angle, measured in degree, e.g. RotationAngle = 0 or RotationAngle = 360 means no rotation. + * If RotationAngle NOT equal to 90, 180, 270 or 0, it may increase the difficulty for the scanner to read the image. + * Default value: 0. + * + * This sample shows how to create and save a BarCode image. + * @code + * $generator = new BarcodeGenerator( EncodeTypes::DATA_MATRIX); + * $generator->getParameters()->setRotationAngle(7); + * $generator->save("test.png", BarcodeImageFormat::PNG); + * @endcode + */ + public function getRotationAngle(): float + { + try + { + return $this->getBaseGenerationParametersDto()->rotationAngle; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * BarCode image rotation angle, measured in degree, e.g. RotationAngle = 0 or RotationAngle = 360 means no rotation. + * If RotationAngle NOT equal to 90, 180, 270 or 0, it may increase the difficulty for the scanner to read the image. + * Default value: 0. + * + * This sample shows how to create and save a BarCode image. + * @code + * $generator = new BarcodeGenerator( EncodeTypes::DATA_MATRIX); + * $generator->getParameters()->setRotationAngle(7); + * $generator->save("test.png", BarcodeImageFormat::PNG); + * @endcode + */ + public function setRotationAngle(float $value): void + { + try + { + $this->getBaseGenerationParametersDto()->rotationAngle = $value; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Caption Above the BarCode image. + * @see CaptionParameters. + */ + public function getCaptionAbove(): CaptionParameters + { + try + { + return $this->captionAbove; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Caption Above the BarCode image. + * @see CaptionParameters. + */ + public function setCaptionAbove(CaptionParameters $value): void + { + try + { + $this->getBaseGenerationParametersDto()->captionAbove = $value->getCaptionParametersDto(); + $this->captionAbove->updateCaption($value); + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Caption Below the BarCode image. + * @see CaptionParameters. + */ + public function getCaptionBelow(): CaptionParameters + { + try + { + return $this->captionBelow; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Caption Below the BarCode image. + * @see CaptionParameters. + */ + function setCaptionBelow(CaptionParameters $value): void + { + try + { + $this->getBaseGenerationParametersDto()->captionBelow = $value->getCaptionParametersDto(); + $this->captionBelow->updateCaption($value); + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Specifies the different types of automatic sizing modes. + * Default value: AutoSizeMode::NONE. + */ + public function getAutoSizeMode(): int + { + try + { + return $this->getBaseGenerationParametersDto()->autoSizeMode; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Specifies the different types of automatic sizing modes. + * Default value: AutoSizeMode::NONE. + */ + public function setAutoSizeMode(int $value) + { + try + { + $this->getBaseGenerationParametersDto()->autoSizeMode = $value; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * BarCode image height when AutoSizeMode property is set to AutoSizeMode::NEAREST or AutoSizeMode::INTERPOLATION. + */ + public function getImageHeight(): Unit + { + return $this->imageHeight; + } + + /** + * BarCode image height when AutoSizeMode property is set to AutoSizeMode.NEAREST or AutoSizeMode::INTERPOLATION. + */ + public function setImageHeight(Unit $value): void + { + try + { + $this->getBaseGenerationParametersDto()->imageHeight = $value->getUnitDto(); + $this->imageHeight = $value; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * BarCode image width when AutoSizeMode property is set to AutoSizeMode.NEAREST or AutoSizeMode::INTERPOLATION. + */ + public function getImageWidth(): Unit + { + return $this->imageWidth; + } + + /** + * BarCode image width when AutoSizeMode property is set to AutoSizeMode.NEAREST or AutoSizeMode::INTERPOLATION. + */ + public function setImageWidth(Unit $value) + { + $this->getBaseGenerationParametersDto()->imageWidth = $value->getUnitDto(); + $this->imageWidth = $value; + } + + /** + * Gets the BarcodeParameters that contains all barcode properties. + */ + public function getBarcode(): BarcodeParameters + { + try + { + return $this->barcodeParameters; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Gets the BarcodeParameters that contains all barcode properties. + */ + function setBarcode(BarcodeParameters $value): void + { + try + { + $this->getBaseGenerationParametersDto()->barcode = $value->getBarcodeParametersDto(); + $this->barcodeParameters = $value; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Gets the BorderParameters that contains all configuration properties for barcode border. + */ + public function getBorder(): BorderParameters + { + try + { + return $this->borderParameters; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } +} \ No newline at end of file diff --git a/lib/Generation/BorderDashStyle.php b/lib/Generation/BorderDashStyle.php new file mode 100644 index 00000000..97cc079f --- /dev/null +++ b/lib/Generation/BorderDashStyle.php @@ -0,0 +1,31 @@ +borderParametersDto; + } + + private function setBorderParametersDto(BorderParametersDTO $borderParametersDto): void + { + $this->borderParametersDto = $borderParametersDto; + } + + private $width; + + function __construct(BorderParametersDTO $borderParametersDto) + { + $this->borderParametersDto = $borderParametersDto; + $this->obtainDto(); + $this->initFieldsFromDto(); + } + + public function obtainDto(...$args) + { + } + + public function initFieldsFromDto(): void + { + try + { + $this->width = new Unit($this->getBorderParametersDto()->width); + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Border visibility. If false than parameter Width is always ignored (0). + * Default value: false. + */ + public function getVisible(): bool + { + try + { + return $this->getBorderParametersDto()->visible; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Border visibility. If false than parameter Width is always ignored (0). + * Default value: false. + */ + public function setVisible(bool $value): void + { + try + { + $this->getBorderParametersDto()->visible = $value; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Border width. + * Default value: 0. + * Ignored if Visible is set to false. + */ + public function getWidth(): Unit + { + return $this->width; + } + + /** + * Border width. + * Default value: 0. + * Ignored if Visible is set to false. + *public + */ + public function setWidth(Unit $value): void + { + try + { + $this->getBorderParametersDto()->width = $value->getUnitDto(); + $this->width = $value; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Returns a human-readable string representation of this BorderParameters. + * + * @return string A string that represents this BorderParameters. + */ + public function toString(): string + { + $thriftConnection = new ThriftConnection(); + $client = $thriftConnection->openConnection(); + $str = $client->BorderParameters_toString($this->getBorderParametersDto()); + $thriftConnection->closeConnection(); + + return $str; + } + + /** + * Border dash style. + * Default value: BorderDashStyle::SOLID. + */ + public function getDashStyle(): int + { + try + { + return $this->getBorderParametersDto()->dashStyle; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Border dash style. + * Default value: BorderDashStyle::SOLID. + */ + public function setDashStyle(int $value): void + { + try + { + $this->getBorderParametersDto()->dashStyle = $value; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Border color. + * Default value: #000000 + */ + public function getColor(): string + { + try + { + $hexColor = strtoupper(dechex($this->getBorderParametersDto()->color)); + while (strlen($hexColor) < 6) + { + $hexColor = "0" . $hexColor; + } + $hexColor = "#" . $hexColor; + return $hexColor; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Border color. + * Default value: #000000 + */ + public function setColor(string $hexValue): void + { + try + { + if (substr($hexValue, 0, 1) == '#') + $hexValue = substr($hexValue, 1, strlen($hexValue) - 1); + $this->getBorderParametersDto()->color = hexdec($hexValue); + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } +} \ No newline at end of file diff --git a/lib/Generation/CMYKColor.php b/lib/Generation/CMYKColor.php new file mode 100644 index 00000000..cbe0533f --- /dev/null +++ b/lib/Generation/CMYKColor.php @@ -0,0 +1,100 @@ +C = min(100, max(0, $c)) / 100.0; + $this->M = min(100, max(0, $m)) / 100.0; + $this->Y = min(100, max(0, $y)) / 100.0; + $this->K = min(100, max(0, $k)) / 100.0; + } + + /** + * Parse a CMYK string of the form "C_M_Y_K" into a CMYKColor instance. + * + * @param string $str a string like "30_100_0_30" + * @return CMYKColor + * @throws InvalidArgumentException if the format is invalid or values are not numeric + */ + public static function parseCMYK(string $str): CMYKColor + { + $parts = explode('_', $str); + if (count($parts) !== 4) + { + throw new InvalidArgumentException("Invalid CMYK string: expected 4 parts but got " . count($parts)); + } + + $nums = []; + foreach ($parts as $i => $s) + { + if (!is_numeric($s)) + { + throw new InvalidArgumentException("Invalid number in CMYK string at index $i: \"$s\""); + } + // PHP does not auto-convert to float in this context + $nums[] = floatval($s); + } + + return new CMYKColor($nums[0], $nums[1], $nums[2], $nums[3]); + } + + /** + * Format this CMYKColor into a string "C_M_Y_K", + * multiplying each internal component (0–1) by 100 and rounding. + * + * @return string e.g. "30_100_0_30" + */ + public function formatCMYK(): string + { + $c = round($this->C * 100); + $m = round($this->M * 100); + $y = round($this->Y * 100); + $k = round($this->K * 100); + return "{$c}_{$m}_{$y}_{$k}"; + } + + /** + * Optional: a human-readable representation. + * + * @return string + */ + public function __toString(): string + { + $c = round($this->C * 100); + $m = round($this->M * 100); + $y = round($this->Y * 100); + $k = round($this->K * 100); + return "CMYKColor(C={$c}%, M={$m}%, Y={$y}%, K={$k}%)"; + } +} \ No newline at end of file diff --git a/lib/Generation/CaptionParameters.php b/lib/Generation/CaptionParameters.php new file mode 100644 index 00000000..384e5657 --- /dev/null +++ b/lib/Generation/CaptionParameters.php @@ -0,0 +1,266 @@ +captionParametersDto; + } + + private function setCaptionParametersDto(CaptionParametersDTO $captionParametersDto): void + { + $this->captionParametersDto = $captionParametersDto; + } + + private $font; + private $padding; + + function __construct(CaptionParametersDTO $captionParametersDto) + { + $this->captionParametersDto = $captionParametersDto; + $this->obtainDto(); + $this->initFieldsFromDto(); + } + + public function obtainDto(...$args) + { + } + + public function initFieldsFromDto(): void + { + try + { + $this->padding = new Padding($this->getCaptionParametersDto()->padding); + $this->font = new FontUnit($this->getCaptionParametersDto()->font); + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Caption text. + * Default value: empty string. + */ + public function getText(): string + { + try + { + return $this->getCaptionParametersDto()->text; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Caption text. + * Default value: empty string. + */ + public function setText(string $value): void + { + try + { + $this->getCaptionParametersDto()->text = $value; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Caption font. + * Default value: Arial 8pt regular. + */ + public function getFont(): FontUnit + { + try + { + return $this->font; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Caption text visibility. + * Default value: false. + */ + public function getVisible(): bool + { + try + { + return $this->getCaptionParametersDto()->visible; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Caption text visibility. + * Default value: false. + */ + public function setVisible(bool $value): void + { + try + { + $this->getCaptionParametersDto()->visible = $value; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Caption text color. + * Default value BLACK. + */ + public function getTextColor(): string + { + try + { + $hexColor = strtoupper(dechex($this->getCaptionParametersDto()->textColor)); + while (strlen($hexColor) < 6) + { + $hexColor = "0" . $hexColor; + } + $hexColor = "#" . $hexColor; + return $hexColor; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Caption text color. + * Default value BLACK. + */ + public function setTextColor(string $value): void + { + try + { + if (substr($value, 0, 1) == '#') + $value = substr($value, 1, strlen($value) - 1); + $this->getCaptionParametersDto()->textColor = hexdec($value); + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Captions paddings. + * Default value for CaptionAbove: 5pt 5pt 0 5pt. + * Default value for CaptionBelow: 0 5pt 5pt 5pt. + */ + public function getPadding(): Padding + { + return $this->padding; + } + + /** + * Captions paddings. + * Default value for CaptionAbove: 5pt 5pt 0 5pt. + * Default value for CaptionBelow: 0 5pt 5pt 5pt. + */ + public function setPadding(Padding $value): void + { + try + { + $this->getCaptionParametersDto()->padding = $value->getPaddingDto(); + $this->padding = $value; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Caption test horizontal alignment. + * Default value: StringAlignment.Center. + */ + public function getAlignment(): int + { + try + { + return $this->getCaptionParametersDto()->alignment; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Caption test horizontal alignment. + * Default value: StringAlignment.CENTER. + */ + public function setAlignment(int $value): void + { + try + { + $this->getCaptionParametersDto()->alignment = $value; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /* + * Specify word wraps (line breaks) within text. + * @return bool + */ + public function getNoWrap(): bool + { + try + { + return $this->getCaptionParametersDto()->noWrap; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /* + * Specify word wraps (line breaks) within text. + */ + public function setNoWrap(bool $value): void + { + try + { + $this->getCaptionParametersDto()->noWrap = $value; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } +} \ No newline at end of file diff --git a/lib/Generation/CodabarChecksumMode.php b/lib/Generation/CodabarChecksumMode.php new file mode 100644 index 00000000..db097348 --- /dev/null +++ b/lib/Generation/CodabarChecksumMode.php @@ -0,0 +1,20 @@ +codabarParametersDto; + } + + private function setCodabarParametersDto(CodabarParametersDTO $codabarParametersDto): void + { + $this->codabarParametersDto = $codabarParametersDto; + } + + function __construct(CodabarParametersDTO $codabarParametersDto) + { + $this->codabarParametersDto = $codabarParametersDto; + $this->obtainDto(); + $this->initFieldsFromDto(); + } + + public function obtainDto(...$args) + { + } + + public function initFieldsFromDto(): void + { + } + + /** + * Get the checksum algorithm for Codabar barcodes. + * Default value: CodabarChecksumMode::MOD_16. + * To enable checksum calculation set value EnableChecksum::YES to property EnableChecksum. + * @see CodabarChecksumMode. + */ + public function getCodabarChecksumMode(): int + { + try + { + return $this->getCodabarParametersDto()->codabarChecksumMode; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Set the checksum algorithm for Codabar barcodes. + * Default value: CodabarChecksumMode::MOD_16. + * To enable checksum calculation set value EnableChecksum::YES to property EnableChecksum. + * @see CodabarChecksumMode. + */ + public function setCodabarChecksumMode(int $value): void + { + try + { + $this->getCodabarParametersDto()->codabarChecksumMode = $value; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Start symbol (character) of Codabar symbology. + * Default value: CodabarSymbol::A + */ + public function getCodabarStartSymbol(): int + { + try + { + return $this->getCodabarParametersDto()->codabarStartSymbol; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Start symbol (character) of Codabar symbology. + * Default value: CodabarSymbol::A + */ + public function setCodabarStartSymbol(int $value): void + { + try + { + $this->getCodabarParametersDto()->codabarStartSymbol = $value; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Stop symbol (character) of Codabar symbology. + * Default value: CodabarSymbol::A + */ + public function getCodabarStopSymbol(): int + { + try + { + return $this->getCodabarParametersDto()->codabarStopSymbol; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Stop symbol (character) of Codabar symbology. + * Default value: CodabarSymbol::A + */ + public function setCodabarStopSymbol(int $value): void + { + try + { + $this->getCodabarParametersDto()->codabarStopSymbol = $value; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Returns a human-readable string representation of this CodabarParameters. + * + * @return string that represents this CodabarParameters. + */ + public function toString(): string + { + $thriftConnection = new ThriftConnection(); + $client = $thriftConnection->openConnection(); + $str = $client->CodabarParameters_toString($this->getCodabarParametersDto()); + $thriftConnection->closeConnection(); + + return $str; + } +} \ No newline at end of file diff --git a/lib/Generation/CodabarSymbol.php b/lib/Generation/CodabarSymbol.php new file mode 100644 index 00000000..049522cc --- /dev/null +++ b/lib/Generation/CodabarSymbol.php @@ -0,0 +1,31 @@ +codablockParametersDto; + } + + private function setCodablockParametersDto(CodablockParametersDTO $codablockParametersDto): void + { + $this->codablockParametersDto = $codablockParametersDto; + } + + function __construct(CodablockParametersDTO $codablockParametersDto) + { + $this->codablockParametersDto = $codablockParametersDto; + $this->obtainDto(); + $this->initFieldsFromDto(); + } + + public function obtainDto(...$args) + { + } + + public function initFieldsFromDto(): void + { + } + + /** + * Columns count. + */ + public function getColumns(): int + { + try + { + return $this->getCodablockParametersDto()->columns; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Columns count. + */ + public function setColumns(int $value): void + { + try + { + $this->getCodablockParametersDto()->columns = $value; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Rows count. + */ + public function getRows(): int + { + try + { + return $this->getCodablockParametersDto()->rows; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Rows count. + */ + public function setRows(int $value): void + { + try + { + $this->getCodablockParametersDto()->rows = $value; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Height/Width ratio of 2D BarCode module. + */ + public function getAspectRatio(): float + { + try + { + return $this->getCodablockParametersDto()->aspectRatio; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Height/Width ratio of 2D BarCode module. + */ + public function setAspectRatio(float $value): void + { + try + { + $this->getCodablockParametersDto()->aspectRatio = $value; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Returns a human-readable string representation of this CodablockParameters. + * + * @return string that represents this CodablockParameters. + */ + public function toString(): string + { + $thriftConnection = new ThriftConnection(); + $client = $thriftConnection->openConnection(); + $str = $client->CodablockParameters_toString($this->getCodablockParametersDto()); + $thriftConnection->closeConnection(); + + return $str; + } +} \ No newline at end of file diff --git a/lib/Generation/Code128EncodeMode.php b/lib/Generation/Code128EncodeMode.php new file mode 100644 index 00000000..b9a70c14 --- /dev/null +++ b/lib/Generation/Code128EncodeMode.php @@ -0,0 +1,74 @@ + + * Encoding mode for Code128 barcodes. + * {@code Code 128} specification. + * + */ +class Code128EncodeMode +{ + /** + *+ * Thos code demonstrates how to generate code 128 with different encodings + *+ * + * //Generate code 128 with ISO 15417 encoding + * $generator = new BarcodeGenerator(EncodeTypes::Code128, "ABCD1234567890"); + * $generator->Parameters->Barcode->Code128->setCode128EncodeMode(Code128EncodeMode::AUTO); + * $generator->Save("d:/code128Auto.png", BarCodeImageFormat::Png); + * //Generate code 128 only with Codeset A encoding + * $generator = new BarcodeGenerator(EncodeTypes::Code128, "ABCD1234567890"); + * $generator->Parameters->Barcode->Code128->setCode128EncodeMode(Code128EncodeMode::CODE_A); + * $generator->Save("d:/code128CodeA.png", BarCodeImageFormat::Png); + *+ *+ * Encode codetext in classic ISO 15417 mode. The mode should be used in all ordinary cases. + *
+ */ + const AUTO = 0; + + /** + *+ * Encode codetext only in 128A codeset. + *
+ */ + const CODE_A = 1; + + /** + *+ * Encode codetext only in 128B codeset. + *
+ */ + const CODE_B = 2; + + /** + *+ * Encode codetext only in 128C codeset. + *
+ */ + const CODE_C = 4; + + /** + *+ * Encode codetext only in 128A and 128B codesets. + *
+ */ + const CODE_AB = 3; + + /** + *+ * Encode codetext only in 128A and 128C codesets. + *
+ */ + const CODE_AC = 5; + + /** + *+ * Encode codetext only in 128B and 128C codesets. + *
+ */ + const CODE_BC = 6; +} \ No newline at end of file diff --git a/lib/Generation/Code128Parameters.php b/lib/Generation/Code128Parameters.php new file mode 100644 index 00000000..189032b2 --- /dev/null +++ b/lib/Generation/Code128Parameters.php @@ -0,0 +1,92 @@ +code128ParametersDto; + } + + private function setCode128ParametersDto(Code128ParametersDTO $code128ParametersDto): void + { + $this->code128ParametersDto = $code128ParametersDto; + } + + function __construct(Code128ParametersDTO $code128ParametersDto) + { + $this->code128ParametersDto = $code128ParametersDto; + $this->obtainDto(); + $this->initFieldsFromDto(); + } + + public function obtainDto(...$args) + { + } + + public function initFieldsFromDto(): void + { + } + + /** + *+ * Gets a Code128 encode mode. + * Default value: Code128EncodeMode.Auto + *
+ */ + public function getCode128EncodeMode(): int + { + try + { + return $this->getCode128ParametersDto()->code128EncodeMode; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + *+ * Sets a Code128 encode mode. + * Default value: Code128EncodeMode.Auto + *
+ */ + public function setCode128EncodeMode(int $value) + { + try + { + $this->getCode128ParametersDto()->code128EncodeMode = $value; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Returns a human-readable string representation of this PatchCodeParameters. + * @return string A string that represents this PatchCodeParameters. + */ + public function toString(): string + { + $thriftConnection = new ThriftConnection(); + $client = $thriftConnection->openConnection(); + $str = $client->Code128Parameters_toString($this->getCode128ParametersDto()); + $thriftConnection->closeConnection(); + + return $str; + } +} \ No newline at end of file diff --git a/lib/Generation/Code16KParameters.php b/lib/Generation/Code16KParameters.php new file mode 100644 index 00000000..88aea78a --- /dev/null +++ b/lib/Generation/Code16KParameters.php @@ -0,0 +1,151 @@ +code16KParametersDto; + } + + private function setCode16KParametersDto(Code16KParametersDTO $code16KParametersDto): void + { + $this->code16KParametersDto = $code16KParametersDto; + } + + function __construct(Code16KParametersDTO $code16KParametersDto) + { + $this->code16KParametersDto = $code16KParametersDto; + $this->obtainDto(); + $this->initFieldsFromDto(); + } + + public function obtainDto(...$args) + { + } + + public function initFieldsFromDto(): void + { + } + + /** + * Height/Width ratio of 2D BarCode module. + */ + public function getAspectRatio(): float + { + try + { + return $this->getCode16KParametersDto()->aspectRatio; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Height/Width ratio of 2D BarCode module. + */ + public function setAspectRatio($value): void + { + try + { + $this->getCode16KParametersDto()->aspectRatio = $value; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Size of the left quiet zone in xDimension. + * Default value: 10, meaning if xDimension = 2px than left quiet zone will be 20px. + */ + public function getQuietZoneLeftCoef(): int + { + try + { + return $this->getCode16KParametersDto()->quietZoneLeftCoef; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Size of the left quiet zone in xDimension. + * Default value: 10, meaning if xDimension = 2px than left quiet zone will be 20px. + */ + public function setQuietZoneLeftCoef(int $value): void + { + try + { + $this->getCode16KParametersDto()->quietZoneLeftCoef = $value; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Size of the right quiet zone in xDimension. + * Default value: 1, meaning if xDimension = 2px than right quiet zone will be 2px. + */ + public function getQuietZoneRightCoef(): int + { + try + { + return $this->getCode16KParametersDto()->quietZoneRightCoef; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Size of the right quiet zone in xDimension. + * Default value: 1, meaning if xDimension = 2px than right quiet zone will be 2px. + */ + public function setQuietZoneRightCoef(int $value): void + { + try + { + $this->getCode16KParametersDto()->quietZoneRightCoef = $value; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Returns a human-readable string representation of this Code16KParameters. + * + * @return string A string that represents this Code16KParameters. + */ + public function toString(): string + { + $thriftConnection = new ThriftConnection(); + $client = $thriftConnection->openConnection(); + $str = $client->Code16KParameters_toString($this->getCode16KParametersDto()); + $thriftConnection->closeConnection(); + + return $str; + } +} \ No newline at end of file diff --git a/lib/Generation/CodeLocation.php b/lib/Generation/CodeLocation.php new file mode 100644 index 00000000..0aac7349 --- /dev/null +++ b/lib/Generation/CodeLocation.php @@ -0,0 +1,24 @@ +codetextParametersDto; + } + + private function setCodetextParametersDto(CodetextParametersDTO $codetextParametersDto): void + { + $this->codetextParametersDto = $codetextParametersDto; + } + + private $font; + private $space; + + function __construct(CodetextParametersDTO $codetextParametersDto) + { + $this->codetextParametersDto = $codetextParametersDto; + $this->obtainDto(); + $this->initFieldsFromDto(); + } + + public function obtainDto(...$args) + { + } + + public function initFieldsFromDto(): void + { + try + { + $this->font = new FontUnit($this->getCodetextParametersDto()->font); + $this->space = new Unit($this->getCodetextParametersDto()->space); + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Text that will be displayed instead of codetext in 2D barcodes. + * Used for: Aztec, Pdf417, DataMatrix, QR, MaxiCode, DotCode + */ + public function getTwoDDisplayText(): string + { + try + { + return $this->getCodetextParametersDto()->twoDDisplayText; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Text that will be displayed instead of codetext in 2D barcodes. + * Used for: Aztec, Pdf417, DataMatrix, QR, MaxiCode, DotCode + */ + public function setTwoDDisplayText(string $value): void + { + try + { + $this->getCodetextParametersDto()->twoDDisplayText = $value; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Specify FontMode. If FontMode is set to Auto, font size will be calculated automatically based on xDimension value. + * It is recommended to use FontMode::AUTO especially in AutoSizeMode.NEAREST or AutoSizeMode::INTERPOLATION. + * Default value: FontMode::AUTO. + */ + public function getFontMode(): int + { + try + { + return $this->getCodetextParametersDto()->fontMode; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Specify FontMode. If FontMode is set to Auto, font size will be calculated automatically based on xDimension value. + * It is recommended to use FontMode::AUTO especially in AutoSizeMode.NEAREST or AutoSizeMode::INTERPOLATION. + * Default value: FontMode::AUTO. + */ + public function setFontMode(int $value): void + { + try + { + $this->getCodetextParametersDto()->fontMode = $value; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Specify the displaying CodeText's font. + * Default value: Arial 5pt regular. + * Ignored if FontMode is set to FontMode::AUTO. + */ + public function getFont(): FontUnit + { + return $this->font; + } + + /** + * Specify the displaying CodeText's font. + * Default value: Arial 5pt regular. + * Ignored if FontMode is set to FontMode::AUTO. + */ + public function setFont(FontUnit $value): void + { + try + { + $this->getCodetextParametersDto()->font = $value->getFontUnitDto(); + $this->font = $value; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Space between the CodeText and the BarCode in Unit value. + * Default value: 2pt. + * Ignored for EAN8, EAN13, UPCE, UPCA, ISBN, ISMN, ISSN, UpcaGs1DatabarCoupon. + */ + public function getSpace(): Unit + { + try + { + return $this->space; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Space between the CodeText and the BarCode in Unit value. + * Default value: 2pt. + * Ignored for EAN8, EAN13, UPCE, UPCA, ISBN, ISMN, ISSN, UpcaGs1DatabarCoupon. + */ + public function setSpace(Unit $value): void + { + try + { + $this->getCodetextParametersDto()->space = $value->getUnitDto(); + $this->space = $value; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Gets the alignment of the code text. + * Default value: TextAlignment::CENTER. + */ + public function getAlignment(): int + { + try + { + return $this->getCodetextParametersDto()->alignment; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Sets the alignment of the code text. + * Default value: TextAlignment::CENTER. + */ + public function setAlignment(int $value): void + { + try + { + $this->getCodetextParametersDto()->alignment = $value; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Specify the displaying CodeText's Color. + * Default value BLACK. + */ + public function getColor(): string + { + try + { + $hexColor = strtoupper(dechex($this->getCodetextParametersDto()->color)); + while (strlen($hexColor) < 6) + { + $hexColor = "0" . $hexColor; + } + $hexColor = "#" . $hexColor; + return $hexColor; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Specify the displaying CodeText's Color. + * Default value BLACK. + */ + public function setColor(string $value): void + { + try + { + if (substr($value, 0, 1) == '#') + $value = substr($value, 1, strlen($value) - 1); + $this->getCodetextParametersDto()->color = hexdec($value); + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Specify the displaying CodeText Location, set to CodeLocation::NONE to hide CodeText. + * Default value: CodeLocation::BELOW. + */ + public function getLocation(): int + { + try + { + return $this->getCodetextParametersDto()->location; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Specify the displaying CodeText Location, set to CodeLocation::NONE to hide CodeText. + * Default value: CodeLocation::BELOW. + */ + public function setLocation(int $value): void + { + try + { + $this->getCodetextParametersDto()->location = $value; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Specify word wraps (line breaks) within text. + * @return bool + */ + public function getNoWrap(): bool + { + try + { + return $this->getCodetextParametersDto()->noWrap; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Specify word wraps (line breaks) within text. + */ + public function setNoWrap(bool $value): void + { + try + { + $this->getCodetextParametersDto()->noWrap = $value; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Returns a human-readable string representation of this CodetextParameters. + * + * @return string A string that represents this CodetextParameters. + */ + public function toString(): string + { + $thriftConnection = new ThriftConnection(); + $client = $thriftConnection->openConnection(); + $str = $client->CodetextParameters_toString($this->getCodetextParametersDto()); + $thriftConnection->closeConnection(); + + return $str; + } +} \ No newline at end of file diff --git a/lib/Generation/CouponParameters.php b/lib/Generation/CouponParameters.php new file mode 100644 index 00000000..9c154b59 --- /dev/null +++ b/lib/Generation/CouponParameters.php @@ -0,0 +1,98 @@ +couponParametersDto; + } + + private function setCouponParametersDto(CouponParametersDTO $couponParametersDto): void + { + $this->couponParametersDto = $couponParametersDto; + } + + private $_space; + + function __construct(CouponParametersDTO $couponParametersDto) + { + $this->couponParametersDto = $couponParametersDto; + $this->obtainDto(); + $this->initFieldsFromDto(); + } + + public function obtainDto(...$args) + { + } + + public function initFieldsFromDto(): void + { + try + { + $this->_space = new Unit($this->getCouponParametersDto()->supplementSpace); + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Space between main the BarCode and supplement BarCode in Unit value. + * + * @exception IllegalArgumentException + * The Space parameter value is less than 0. + */ + public function getSupplementSpace(): Unit + { + return $this->_space; + } + + /** + * Space between main the BarCode and supplement BarCode in Unit value. + * + * @exception IllegalArgumentException + * The Space parameter value is less than 0. + */ + public function setSupplementSpace(Unit $value): void + { + try + { + $this->getCouponParametersDto()->supplementSpace = $value->getUnitDto(); + $this->_space = $value; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Returns a human-readable string representation of this CouponParameters. + * + * @return string that represents this CouponParameters. + */ + public function toString(): string + { + $thriftConnection = new ThriftConnection(); + $client = $thriftConnection->openConnection(); + $str = $client->CouponParameters_toString($this->getCouponParametersDto()); + $thriftConnection->closeConnection(); + + return $str; + } +} \ No newline at end of file diff --git a/lib/Generation/DataBarParameters.php b/lib/Generation/DataBarParameters.php new file mode 100644 index 00000000..e61e834c --- /dev/null +++ b/lib/Generation/DataBarParameters.php @@ -0,0 +1,209 @@ +dataBarParametersDto; + } + + private function setDataBarParametersDto(DataBarParametersDTO $dataBarParametersDto): void + { + $this->dataBarParametersDto = $dataBarParametersDto; + } + + function __construct(DataBarParametersDTO $dataBarParametersDto) + { + $this->dataBarParametersDto = $dataBarParametersDto; + $this->obtainDto(); + $this->initFieldsFromDto(); + } + + public function obtainDto(...$args) + { + } + + public function initFieldsFromDto(): void + { + } + + /** + * Enables flag of 2D composite component with DataBar barcode + */ + public function is2DCompositeComponent(): bool + { + try + { + return $this->getDataBarParametersDto()->is2DCompositeComponent; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Enables flag of 2D composite component with DataBar barcode + */ + public function set2DCompositeComponent(bool $value): void + { + try + { + $this->getDataBarParametersDto()->is2DCompositeComponent = $value; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * If this flag is set, it allows only GS1 encoding standard for Databar barcode types + */ + public function isAllowOnlyGS1Encoding(): bool + { + try + { + return $this->getDataBarParametersDto()->isAllowOnlyGS1Encoding; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * If this flag is set, it allows only GS1 encoding standard for Databar barcode types + */ + public function setAllowOnlyGS1Encoding(bool $value): void + { + try + { + $this->getDataBarParametersDto()->isAllowOnlyGS1Encoding = $value; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Columns count. + */ + public function getColumns(): int + { + try + { + return $this->getDataBarParametersDto()->columns; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Columns count. + */ + public function setColumns(int $value): void + { + try + { + $this->getDataBarParametersDto()->columns = $value; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Rows count. + */ + public function getRows(): int + { + try + { + return $this->getDataBarParametersDto()->rows; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Rows count. + */ + public function setRows(int $value): void + { + try + { + $this->getDataBarParametersDto()->rows = $value; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Height/Width ratio of 2D BarCode module. + * Used for DataBar stacked. + */ + public function getAspectRatio(): float + { + try + { + return $this->getDataBarParametersDto()->aspectRatio; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Height/Width ratio of 2D BarCode module. + * Used for DataBar stacked. + */ + public function setAspectRatio(float $value): void + { + try + { + $this->getDataBarParametersDto()->aspectRatio = $value; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Returns a human-readable string representation of this DataBarParameters. + * + * @return string that represents this DataBarParameters. + */ + public function toString(): string + { + $thriftConnection = new ThriftConnection(); + $client = $thriftConnection->openConnection(); + $str = $client->DataBarParameters_toString($this->getDataBarParametersDto()); + $thriftConnection->closeConnection(); + + return $str; + } +} \ No newline at end of file diff --git a/lib/Generation/DataMatrixEccType.php b/lib/Generation/DataMatrixEccType.php new file mode 100644 index 00000000..578773f0 --- /dev/null +++ b/lib/Generation/DataMatrixEccType.php @@ -0,0 +1,38 @@ + + * DataMatrix encoder's encoding mode, default to Auto + *+ */ +class DataMatrixEncodeMode +{ + /** + * In Auto mode, the CodeText is encoded with maximum data compactness. + * Unicode characters are re-encoded in the ECIEncoding specified encoding with the insertion of an ECI identifier. + * If a character is found that is not supported by the selected ECI encoding, an exception is thrown. + */ + const AUTO = 0; + + /** + *+ * This sample shows how to do codetext in Extended Mode. + *+ * //Auto mode + * $codetext = "犬Right狗"; + * $generator = new BarcodeGenerator(EncodeTypes::DATA_MATRIX, $codetext); + * $generator->getParameters()->getBarcode()->getDataMatrix()->setECIEncoding(ECIEncodings::UTF8); + * $generator->save("test.bmp", BarcodeImageFormat::PNG); + * //Bytes mode + * $encodedArr = array( 0xFF, 0xFE, 0xFD, 0xFC, 0xFB, 0xFA, 0xF9 ); + * $generator = new BarcodeGenerator(EncodeTypes::DATA_MATRIX, $encodedArr); + * $generator->getParameters()->getBarcode()->getDataMatrix()->setDataMatrixEncodeMode(DataMatrixEncodeMode::BINARY); + * $generator->save("test.bmp", BarcodeImageFormat::PNG); + * //Extended codetext mode + * //create codetext + * $codetextBuilder=new DataMatrixExtCodetextBuilder(); + * $codetextBuilder->addECICodetextWithEncodeMode(ECIEncodings::Win1251,DataMatrixEncodeMode::BYTES,"World"); + * $codetextBuilder->addPlainCodetext("Will"); + * $codetextBuilder->addECICodetext(ECIEncodings::UTF8,"犬Right狗"); + * $codetextBuilder->addCodetextWithEncodeMode(DataMatrixEncodeMode::C40,"ABCDE"); + * //generate codetext + * $codetext=$codetextBuilder->getExtended(); + * //generate + * $generator=new BarcodeGenerator(EncodeTypes::DATA_MATRIX,codetext); + * $generator->getParameters()->getBarcode()->getDataMatrix()->setDataMatrixEncodeMode(DataMatrixEncodeMode::EXTENDED_CODETEXT); + * $generator->save("test.bmp", BarcodeImageFormat::PNG); + *+ *+ * Encodes one alphanumeric or two numeric characters per byte + *
+ */ + const ASCII = 1; + + /** + * Encode 8 bit values + * @deprecated This property is obsolete and will be removed in future releases. Instead, use Base256 option. + */ + const BYTES = 6; + + /** + *+ * Uses C40 encoding. Encodes Upper-case alphanumeric, Lower case and special characters + *
+ */ + const C40 = 8; + + /** + *+ * Uses Text encoding. Encodes Lower-case alphanumeric, Upper case and special characters + *
+ */ + const TEXT = 9; + + /** + *+ * Uses EDIFACT encoding. Uses six bits per character, encodes digits, upper-case letters, and many punctuation marks, but has no support for lower-case letters. + *
+ */ + const EDIFACT = 10; + + /** + *+ * Uses ANSI X12 encoding. + *
+ */ + const ANSIX12 = 11; + + /** + *+ *
ExtendedCodetext mode allows to manually switch encodation schemes and ECI encodings in codetext.
+ *It is better to use DataMatrixExtCodetextBuilder for extended codetext generation.
+ *Use Display2DText property to set visible text to removing managing characters.
+ *ECI identifiers are set as single slash and six digits identifier "\000026" - UTF8 ECI identifier
+ *All unicode characters after ECI identifier are automatically encoded into correct character codeset.
+ * + *Encodation schemes are set in the next format : "\Encodation_scheme_name:text\Encodation_scheme_name:text".
+ *Allowed encodation schemes are: EDIFACT, ANSIX12, ASCII, C40, Text, Auto.
+ * + *All backslashes (\) must be doubled in text.
+ * + * @deprecated This property is obsolete and will be removed in future releases. Instead, use the 'Extended' encode mode + */ + const EXTENDED_CODETEXT = 12; + + /** + * ExtendedCodetext mode allows to manually switch encodation schemes and ECI encodings in codetext. + * It is better to use DataMatrixExtCodetextBuilder for extended codetext generation. + * Use Display2DText property to set visible text to removing managing characters. + * ECI identifiers are set as single slash and six digits identifier "\000026" - UTF8 ECI identifier + * All unicode characters after ECI identifier are automatically encoded into correct character codeset. + * + * Encodation schemes are set in the next format : "\Encodation_scheme_name:text\Encodation_scheme_name:text". + * Allowed encodation schemes are: EDIFACT, ANSIX12, ASCII, C40, Text, Auto. + * + * All backslashes (\) must be doubled in text. + */ + const EXTENDED = 13; + + /** + * Encode 8 bit values + */ + const BASE_256 = 14; + + /** + * In Binary mode, the CodeText is encoded with maximum data compactness. + * If a Unicode character is found, an exception is thrown. + */ + const BINARY = 15; + + /** + * In ECI mode, the entire message is re-encoded in the ECIEncoding specified encoding with the insertion of an ECI identifier. + * If a character is found that is not supported by the selected ECI encoding, an exception is thrown. + * Please note that some old (pre 2006) scanners may not support this mode. + */ + const ECI = 16; +} \ No newline at end of file diff --git a/lib/Generation/DataMatrixExtCodetextBuilder.php b/lib/Generation/DataMatrixExtCodetextBuilder.php new file mode 100644 index 00000000..d798b974 --- /dev/null +++ b/lib/Generation/DataMatrixExtCodetextBuilder.php @@ -0,0 +1,84 @@ + + *Extended codetext generator for 2D DataMatrix barcodes for ExtendedCodetext Mode of DataMatrixEncodeMode
+ *+ */ +class DataMatrixExtCodetextBuilder extends ExtCodetextBuilder +{ + function __construct() + { + try + { + parent::__construct(); + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + function init(): void + { + } + + /** + *+ *+ * //Extended codetext mode + * //create codetext + * $textBuilder = new DataMatrixExtCodetextBuilder(); + * $codetextBuilder->addECICodetextWithEncodeMode(ECIEncodings::Win1251, DataMatrixEncodeMode::BYTES, "World"); + * $codetextBuilder->addPlainCodetext("Will"); + * $codetextBuilder->addECICodetext(ECIEncodings::UTF_8, "犬Right狗"); + * $codetextBuilder->addCodetextWithEncodeMode(DataMatrixEncodeMode::C_40, "ABCDE"); + * //generate codetext + * $codetext = $textBuilder->getExtendedCodetext(); + * //generate + * $generator = new BarcodeGenerator(EncodeTypes::DATA_MATRIX, null, $codetext); + * $generator->getParameters()->getBarcode()->getDataMatrix()->setDataMatrixEncodeMode(DataMatrixEncodeMode::EXTENDED_CODETEXT); + * $generator->save("test.bmp", BarcodeImageFormat::BMP); + *+ *+ * Adds codetext with Extended Channel Identifier with defined encode mode + *
+ * @param ECIEncoding Extended Channel Identifier + * @param encodeMode Encode mode value + * @param codetext Codetext in unicode to add as extended codetext item with Extended Channel Identifier with defined encode mode + */ + public function addECICodetextWithEncodeMode(int $ECIEncoding, int $encodeMode, string $codetext): void + { + $extCodeItemDTO = new \Aspose\Barcode\Bridge\ExtCodeItemDTO(); + $extCodeItemDTO->extCodeItemType = ExtCodeItemType::ECI_CODETEXT_WITH_ENCODE_MODE; + $extCodeItemDTO->arguments = array($ECIEncoding, $encodeMode, $codetext); + array_push($this->_list, $extCodeItemDTO); + } + + /** + *+ * Adds codetext with defined encode mode to the extended codetext items + *
+ * @param encodeMode Encode mode value + * @param codetext Codetext in unicode to add as extended codetext item + */ + public function addCodetextWithEncodeMode(int $encodeMode, string $codetext): void + { + $extCodeItemDTO = new \Aspose\Barcode\Bridge\ExtCodeItemDTO(); + $extCodeItemDTO->extCodeItemType = ExtCodeItemType::CODETEXT_WITH_ENCODE_MODE; + $extCodeItemDTO->arguments = array($encodeMode, $codetext); + array_push($this->_list, $extCodeItemDTO); + } + + protected function getExtCodetextBuilderType(): int + { + return ExtCodetextBuilderType::DATA_MATRIX_EXT_CODETEXT_BUILDER; + } +} \ No newline at end of file diff --git a/lib/Generation/DataMatrixParameters.php b/lib/Generation/DataMatrixParameters.php new file mode 100644 index 00000000..99185258 --- /dev/null +++ b/lib/Generation/DataMatrixParameters.php @@ -0,0 +1,388 @@ +dataMatrixParametersDto; + } + + private function setDataMatrixParametersDto(DataMatrixParametersDTO $dataMatrixParametersDto): void + { + $this->dataMatrixParametersDto = $dataMatrixParametersDto; + } + + function __construct(DataMatrixParametersDTO $dataMatrixParametersDto) + { + $this->dataMatrixParametersDto = $dataMatrixParametersDto; + $this->obtainDto(); + $this->initFieldsFromDto(); + } + + public function obtainDto(...$args) + { + } + + public function initFieldsFromDto(): void + { + } + + /** + *+ * Gets a Datamatrix symbol size. + * Default value: DataMatrixVersion.Auto. + *
+ */ + public function getDataMatrixVersion(): int + { + return $this->getDataMatrixParametersDto()->dataMatrixVersion; + } + + /** + *+ * Sets a Datamatrix symbol size. + * Default value: DataMatrixVersion.Auto. + *
+ */ + public function setDataMatrixVersion(int $value) + { + $this->getDataMatrixParametersDto()->dataMatrixVersion = $value; + } + + /** + * Gets a Datamatrix ECC type. + * Default value: DataMatrixEccType::ECC_200. + */ + public function getDataMatrixEcc(): int + { + try + { + return $this->getDataMatrixParametersDto()->dataMatrixEcc; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Sets a Datamatrix ECC type. + * Default value: DataMatrixEccType::ECC_200. + */ + public function setDataMatrixEcc(int $value): void + { + try + { + $this->getDataMatrixParametersDto()->dataMatrixEcc = $value; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Encode mode of Datamatrix barcode. + * Default value: DataMatrixEncodeMode::AUTO. + */ + public function getDataMatrixEncodeMode(): int + { + try + { + return $this->getDataMatrixParametersDto()->dataMatrixEncodeMode; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Encode mode of Datamatrix barcode. + * Default value: DataMatrixEncodeMode::AUTO. + */ + public function setDataMatrixEncodeMode(int $value): void + { + try + { + $this->getDataMatrixParametersDto()->dataMatrixEncodeMode = $value; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + *+ * Barcode ID for Structured Append mode of Datamatrix barcode. + * Default value: 0 + *
+ */ + public function getStructuredAppendBarcodeId(): int + { + return $this->getDataMatrixParametersDto()->structuredAppendBarcodeId; + } + + /** + *+ * Barcode ID for Structured Append mode of Datamatrix barcode. + * Default value: 0 + *
+ */ + public function setStructuredAppendBarcodeId(int $value): void + { + $this->getDataMatrixParametersDto()->structuredAppendBarcodeId = $value; + } + + /** + *+ * Barcodes count for Structured Append mode of Datamatrix barcode. + * Default value: 0 + *
+ */ + public function getStructuredAppendBarcodesCount(): int + { + return $this->getDataMatrixParametersDto()->structuredAppendBarcodesCount; + } + + /** + *+ * Barcodes count for Structured Append mode of Datamatrix barcode. + * Default value: 0 + *
+ */ + public function setStructuredAppendBarcodesCount(int $value): void + { + $this->getDataMatrixParametersDto()->structuredAppendBarcodesCount = $value; + } + + /** + *+ * File ID for Structured Append mode of Datamatrix barcode. + * Default value: 0 + *
+ */ + public function getStructuredAppendFileId(): int + { + return $this->getDataMatrixParametersDto()->structuredAppendFileId; + } + + /** + *+ * File ID for Structured Append mode of Datamatrix barcode. + * Default value: 0 + *
+ */ + public function setStructuredAppendFileId(int $value): void + { + $this->getDataMatrixParametersDto()->structuredAppendFileId = $value; + } + + /** + *+ * Used to instruct the reader to interpret the data contained within the symbol + * as programming for reader initialization. + * Default value: false + *
+ */ + public function isReaderProgramming(): bool + { + return $this->getDataMatrixParametersDto()->isReaderProgramming; + } + + /** + *+ * Used to instruct the reader to interpret the data contained within the symbol + * as programming for reader initialization. + * Default value: false + *
+ */ + public function setReaderProgramming(bool $value): void + { + $this->getDataMatrixParametersDto()->isReaderProgramming = $value; + } + + /** + * ISO/IEC 16022 + * 5.2.4.7 Macro characters + * 11.3 Protocol for Macro characters in the first position (ECC 200 only) + * Macro Characters 05 and 06 values are used to obtain more compact encoding in special modes. + * Can be used only with DataMatrixEccType.Ecc200 or DataMatrixEccType.EccAuto. + * Cannot be used with EncodeTypes::GS_1_DATA_MATRIX + * Default value: MacroCharacter::NONE. + */ + public function getMacroCharacters(): int + { + try + { + return $this->getDataMatrixParametersDto()->macroCharacters; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * ISO/IEC 16022 + * 5.2.4.7 Macro characters + * 11.3 Protocol for Macro characters in the first position (ECC 200 only) + * Macro Characters 05 and 06 values are used to obtain more compact encoding in special modes. + * Can be used only with DataMatrixEccType.Ecc200 or DataMatrixEccType.EccAuto. + * Cannot be used with EncodeTypes::GS_1_DATA_MATRIX + * Default value: MacroCharacter::NONE. + */ + public function setMacroCharacters(int $value): void + { + try + { + $this->getDataMatrixParametersDto()->macroCharacters = $value; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Columns count. + */ + public function getColumns(): int + { + try + { + return $this->getDataMatrixParametersDto()->columns; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Columns count. + */ + public function setColumns(int $value): void + { + try + { + $this->getDataMatrixParametersDto()->columns = $value; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Rows count. + */ + public function getRows(): int + { + try + { + return $this->getDataMatrixParametersDto()->rows; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Rows count. + */ + public function setRows(int $value): void + { + try + { + $this->getDataMatrixParametersDto()->rows = $value; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Height/Width ratio of 2D BarCode module. + */ + public function getAspectRatio(): float + { + try + { + return $this->getDataMatrixParametersDto()->aspectRatio; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Height/Width ratio of 2D BarCode module. + */ + public function setAspectRatio(float $value): void + { + try + { + $this->getDataMatrixParametersDto()->aspectRatio = $value; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + *+ * Gets ECI encoding. Used when DataMatrixEncodeMode is Auto. + * Default value: ISO-8859-1 + *
+ */ + public function getECIEncoding(): int + { + return $this->getDataMatrixParametersDto()->eCIEncoding; + } + + /** + *+ * Sets ECI encoding. Used when DataMatrixEncodeMode is Auto. + * Default value: ISO-8859-1 + *
+ */ + public function setECIEncoding(int $value): void + { + $this->getDataMatrixParametersDto()->eCIEncoding = $value; + } + + /** + * Returns a human-readable string representation of this DataMatrixParameters. + * + * @return string presentation of this DataMatrixParameters. + */ + public function toString(): string + { + $thriftConnection = new ThriftConnection(); + $client = $thriftConnection->openConnection(); + $str = $client->DataMatrixParameters_toString($this->getDataMatrixParametersDto()); + $thriftConnection->closeConnection(); + + return $str; + } + +} \ No newline at end of file diff --git a/lib/Generation/DataMatrixVersion.php b/lib/Generation/DataMatrixVersion.php new file mode 100644 index 00000000..d2fb8418 --- /dev/null +++ b/lib/Generation/DataMatrixVersion.php @@ -0,0 +1,440 @@ + + * Specify the type of the ECC to encode. + * + */ +class DataMatrixVersion +{ + /** + *+ * Specifies to automatically pick up the smallest size for DataMatrix. + * This is default value. + *
+ */ + const AUTO = 0; + /** + *+ * Instructs to get symbol sizes from Rows And Columns parameters. Note that DataMatrix does not support + * custom rows and columns numbers. This option is not recommended to use. + *
+ */ + const ROWS_COLUMNS = 1; + /** + *+ * Specifies size of 9 x 9 modules for ECC000 type. + *
+ */ + const ECC000_9x9 = 2; + /** + *+ * Specifies size of 11 x 11 modules for ECC000-ECC050 types. + *
+ */ + const ECC000_050_11x11 = 3; + /** + *+ * Specifies size of 13 x 13 modules for ECC000-ECC100 types. + *
+ */ + const ECC000_100_13x13 = 4; + /** + *+ * Specifies size of 15 x 15 modules for ECC000-ECC100 types. + *
+ */ + const ECC000_100_15x15 = 5; + /** + *+ * Specifies size of 17 x 17 modules for ECC000-ECC140 types. + *
+ */ + const ECC000_140_17x17 = 6; + /** + *+ * Specifies size of 19 x 19 modules for ECC000-ECC140 types. + *
+ */ + const ECC000_140_19x19 = 7; + /** + *+ * Specifies size of 21 x 21 modules for ECC000-ECC140 types. + *
+ */ + const ECC000_140_21x21 = 8; + /** + *+ * Specifies size of 23 x 23 modules for ECC000-ECC140 types. + *
+ */ + const ECC000_140_23x23 = 9; + /** + *+ * Specifies size of 25 x 25 modules for ECC000-ECC140 types. + *
+ */ + const ECC000_140_25x25 = 10; + /** + *+ * Specifies size of 27 x 27 modules for ECC000-ECC140 types. + *
+ */ + const ECC000_140_27x27 = 11; + /** + *+ * Specifies size of 29 x 29 modules for ECC000-ECC140 types. + *
+ */ + const ECC000_140_29x29 = 12; + /** + *+ * Specifies size of 31 x 31 modules for ECC000-ECC140 types. + *
+ */ + const ECC000_140_31x31 = 13; + /** + *+ * Specifies size of 33 x 33 modules for ECC000-ECC140 types. + *
+ */ + const ECC000_140_33x33 = 14; + /** + *+ * Specifies size of 35 x 35 modules for ECC000-ECC140 types. + *
+ */ + const ECC000_140_35x35 = 15; + /** + *+ * Specifies size of 37 x 37 modules for ECC000-ECC140 types. + *
+ */ + const ECC000_140_37x37 = 16; + /** + *+ * Specifies size of 39 x 39 modules for ECC000-ECC140 types. + *
+ */ + const ECC000_140_39x39 = 17; + /** + *+ * Specifies size of 41 x 41 modules for ECC000-ECC140 types. + *
+ */ + const ECC000_140_41x41 = 18; + /** + *+ * Specifies size of 43 x 43 modules for ECC000-ECC140 types. + *
+ */ + const ECC000_140_43x43 = 19; + /** + *+ * Specifies size of 45 x 45 modules for ECC000-ECC140 types. + *
+ */ + const ECC000_140_45x45 = 20; + /** + *+ * Specifies size of 47 x 47 modules for ECC000-ECC140 types. + *
+ */ + const ECC000_140_47x47 = 21; + /** + *+ * Specifies size of 49 x 49 modules for ECC000-ECC140 types. + *
+ */ + const ECC000_140_49x49 = 22; + /** + *+ * Specifies size of 10 x 10 modules for ECC200 type. + *
+ */ + const ECC200_10x10 = 23; + /** + *+ * Specifies size of 12 x 12 modules for ECC200 type. + *
+ */ + const ECC200_12x12 = 24; + /** + *+ * Specifies size of 14 x 14 modules for ECC200 type. + *
+ */ + const ECC200_14x14 = 25; + /** + *+ * Specifies size of 16 x 16 modules for ECC200 type. + *
+ */ + const ECC200_16x16 = 26; + /** + *+ * Specifies size of 18 x 18 modules for ECC200 type. + *
+ */ + const ECC200_18x18 = 27; + /** + *+ * Specifies size of 20 x 20 modules for ECC200 type. + *
+ */ + const ECC200_20x20 = 28; + /** + *+ * Specifies size of 22 x 22 modules for ECC200 type. + *
+ */ + const ECC200_22x22 = 29; + /** + *+ * Specifies size of 24 x 24 modules for ECC200 type. + *
+ */ + const ECC200_24x24 = 30; + /** + *+ * Specifies size of 26 x 26 modules for ECC200 type. + *
+ */ + const ECC200_26x26 = 31; + /** + *+ * Specifies size of 32 x 32 modules for ECC200 type. + *
+ */ + const ECC200_32x32 = 32; + /** + *+ * Specifies size of 36 x 36 modules for ECC200 type. + *
+ */ + const ECC200_36x36 = 33; + /** + *+ * Specifies size of 40 x 40 modules for ECC200 type. + *
+ */ + const ECC200_40x40 = 34; + /** + *+ * Specifies size of 44 x 44 modules for ECC200 type. + *
+ */ + const ECC200_44x44 = 35; + /** + *+ * Specifies size of 48 x 48 modules for ECC200 type. + *
+ */ + const ECC200_48x48 = 36; + /** + *+ * Specifies size of 52 x 52 modules for ECC200 type. + *
+ */ + const ECC200_52x52 = 37; + /** + *+ * Specifies size of 64 x 64 modules for ECC200 type. + *
+ */ + const ECC200_64x64 = 38; + /** + *+ * Specifies size of 72 x 72 modules for ECC200 type. + *
+ */ + const ECC200_72x72 = 39; + /** + *+ * Specifies size of 80 x 80 modules for ECC200 type. + *
+ */ + const ECC200_80x80 = 40; + /** + *+ * Specifies size of 88 x 88 modules for ECC200 type. + *
+ */ + const ECC200_88x88 = 41; + /** + *+ * Specifies size of 96 x 96 modules for ECC200 type. + *
+ */ + const ECC200_96x96 = 42; + /** + *+ * Specifies size of 104 x 104 modules for ECC200 type. + *
+ */ + const ECC200_104x104 = 43; + /** + *+ * Specifies size of 120 x 120 modules for ECC200 type. + *
+ */ + const ECC200_120x120 = 44; + /** + *+ * Specifies size of 132 x 132 modules for ECC200 type. + *
+ */ + const ECC200_132x132 = 45; + /** + *+ * Specifies size of 144 x 144 modules for ECC200 type. + *
+ */ + const ECC200_144x144 = 46; + /** + *+ * Specifies size of 8 x 18 modules for ECC200 type. + *
+ */ + const ECC200_8x18 = 47; + /** + *+ * Specifies size of 8 x 32 modules for ECC200 type. + *
+ */ + const ECC200_8x32 = 48; + /** + *+ * Specifies size of 12 x 26 modules for ECC200 type. + *
+ */ + const ECC200_12x26 = 49; + /** + *+ * Specifies size of 12 x 36 modules for ECC200 type. + *
+ */ + const ECC200_12x36 = 50; + /** + *+ * Specifies size of 16 x 36 modules for ECC200 type. + *
+ */ + const ECC200_16x36 = 51; + /** + *+ * Specifies size of 16 x 48 modules for ECC200 type. + *
+ */ + const ECC200_16x48 = 52; + /** + *+ * Specifies size of 8 x 48 modules for DMRE barcodes. + *
+ */ + const DMRE_8x48 = 53; + /** + *+ * Specifies size of 8 x 64 modules for DMRE barcodes. + *
+ */ + const DMRE_8x64 = 54; + /** + *+ * Specifies size of 8 x 80 modules for DMRE barcodes. + *
+ */ + const DMRE_8x80 = 55; + /** + *+ * Specifies size of 8 x 96 modules for DMRE barcodes. + *
+ */ + const DMRE_8x96 = 56; + /** + *+ * Specifies size of 8 x 120 modules for DMRE barcodes. + *
+ */ + const DMRE_8x120 = 57; + /** + *+ * Specifies size of 8 x 144 modules for DMRE barcodes. + *
+ */ + const DMRE_8x144 = 58; + /** + *+ * Specifies size of 12 x 64 modules for DMRE barcodes. + *
+ */ + const DMRE_12x64 = 59; + /** + *+ * Specifies size of 12 x 88 modules for DMRE barcodes. + *
+ */ + const DMRE_12x88 = 60; + /** + *+ * Specifies size of 16 x 64 modules for DMRE barcodes. + *
+ */ + const DMRE_16x64 = 61; + /** + *+ * Specifies size of 20 x 36 modules for DMRE barcodes. + *
+ */ + const DMRE_20x36 = 62; + /** + *+ * Specifies size of 20 x 44 modules for DMRE barcodes. + *
+ */ + const DMRE_20x44 = 63; + /** + *+ * Specifies size of 20 x 64 modules for DMRE barcodes. + *
+ */ + const DMRE_20x64 = 64; + /** + *+ * Specifies size of 22 x 48 modules for DMRE barcodes. + *
+ */ + const DMRE_22x48 = 65; + /** + *+ * Specifies size of 24 x 48 modules for DMRE barcodes. + *
+ */ + const DMRE_24x48 = 66; + /** + *+ * Specifies size of 24 x 64 modules for DMRE barcodes. + *
+ */ + const DMRE_24x64 = 67; + /** + *+ * Specifies size of 26 x 40 modules for DMRE barcodes. + *
+ */ + const DMRE_26x40 = 68; + /** + *+ * Specifies size of 26 x 48 modules for DMRE barcodes. + *
+ */ + const DMRE_26x48 = 69; + /** + *+ * Specifies size of 26 x 64 modules for DMRE barcodes. + *
+ */ + const DMRE_26x64 = 70; +} \ No newline at end of file diff --git a/lib/Generation/DotCodeEncodeMode.php b/lib/Generation/DotCodeEncodeMode.php new file mode 100644 index 00000000..0f9d96a7 --- /dev/null +++ b/lib/Generation/DotCodeEncodeMode.php @@ -0,0 +1,106 @@ + + * Encoding mode for DotCode barcodes. + *+ */ +class DotCodeEncodeMode +{ + /** + *+ *+ * //Auto mode with macros + * $codetext = ""[)>\u001E05\u001DCodetextWithMacros05\u001E\u0004""; + * $generator = new BarcodeGenerator(EncodeTypes::DOT_CODE, $codetext); + * $generator->save("test.bmp", BarCodeImageFormat::BMP); + * + * //Auto mode + * $codetext = "犬Right狗"; + * $generator = new BarcodeGenerator(EncodeTypes::DOT_CODE, $codetext); + * $generator->getParameters()->getBarcode()->getDotCode()->setECIEncoding(ECIEncodings::UTF8); + * $generator->save("test.bmp", BarCodeImageFormat::BMP); + * + * //Bytes mode + * $encodedArr = array(0xFF, 0xFE, 0xFD, 0xFC, 0xFB, 0xFA, 0xF9); + * $generator = new BarcodeGenerator(EncodeTypes::DOT_CODE, null); + * $generator->setCodetext($encodedArr, null); + * $generator->getParameters()->getBarcode()->getDotCode()->setDotCodeEncodeMode(DotCodeEncodeMode::BINARY); + * $generator->save("test.bmp", BarcodeImageFormat:PNG); + * + * //Extended codetext mode + * //create codetext + * $textBuilder = new DotCodeExtCodetextBuilder(); + * $textBuilder->addFNC1FormatIdentifier(); + * $textBuilder->addECICodetext(ECIEncodings::Win1251, "Will"); + * $textBuilder->addFNC1FormatIdentifier(); + * $textBuilder->addECICodetext(ECIEncodings::UTF8, "犬Right狗"); + * $textBuilder->addFNC3SymbolSeparator(); + * $textBuilder->addFNC1FormatIdentifier(); + * $textBuilder->addECICodetext(ECIEncodings::UTF16BE, "犬Power狗"); + * $textBuilder->addPlainCodetext("Plain text"); + * //generate codetext + * $codetext = $textBuilder->getExtended(); + * //generate + * $generator = new BarcodeGenerator(EncodeTypes::DOT_CODE, $codetext); + * $generator->getParameters()->getBarcode()->getDotCode()->setDotCodeEncodeMode(DotCodeEncodeMode::EXTENDED_CODETEXT); + * $generator->save("test.bmp", BarCodeImageFormat::BMP); + *+ *+ * In Auto mode, the CodeText is encoded with maximum data compactness. + * Unicode characters are re-encoded in the ECIEncoding specified encoding with the insertion of an ECI identifier. + * If a character is found that is not supported by the selected ECI encoding, an exception is thrown. + *
+ */ + const AUTO = 0; + + /** + *+ * Encode codetext as plain bytes. If it detects any Unicode character, the character will be encoded as two bytes, lower byte first. + *
+ * @deprecated + */ + const BYTES = 1; + + /** + *+ *
Extended mode which supports multi ECI modes.
+ *It is better to use DotCodeExtCodetextBuilder for extended codetext generation.
+ *Use Display2DText property to set visible text to removing managing characters.
+ *ECI identifiers are set as single slash and six digits identifier "\000026" - UTF8 ECI identifier
+ *All unicode characters after ECI identifier are automatically encoded into correct character codeset.
+ * + * @deprecated + */ + const EXTENDED_CODETEXT = 2; + + /** + *+ * In Binary mode, the CodeText is encoded with maximum data compactness. + * If a Unicode character is found, an exception is thrown. + *
+ */ + const BINARY = 3; + + /** + *+ * In ECI mode, the entire message is re-encoded in the ECIEncoding specified encoding with the insertion of an ECI identifier. + * If a character is found that is not supported by the selected ECI encoding, an exception is thrown. + * Please note that some old (pre 2006) scanners may not support this mode. + *
+ */ + const ECI = 4; + + /** + *+ *
Extended mode which supports multi ECI modes.
+ *It is better to use DotCodeExtCodetextBuilder for extended codetext generation.
+ *Use Display2DText property to set visible text to removing managing characters.
+ *ECI identifiers are set as single slash and six digits identifier "\000026" - UTF8 ECI identifier
+ *All unicode characters after ECI identifier are automatically encoded into correct character codeset.
+ * + */ + const EXTENDED = 5; +} \ No newline at end of file diff --git a/lib/Generation/DotCodeExtCodetextBuilder.php b/lib/Generation/DotCodeExtCodetextBuilder.php new file mode 100644 index 00000000..40584bc4 --- /dev/null +++ b/lib/Generation/DotCodeExtCodetextBuilder.php @@ -0,0 +1,117 @@ + + *Extended codetext generator for 2D DotCode barcodes for ExtendedCodetext Mode of DotCodeEncodeMode
+ *+ */ +class DotCodeExtCodetextBuilder extends ExtCodetextBuilder +{ + function __construct() + { + try + { + parent::__construct(); + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + *+ *+ * + * //Extended codetext mode + * //create codetext + * $textBuilder = new DotCodeExtCodetextBuilder(); + * $textBuilder->addFNC1FormatIdentifier(); + * $textBuilder->addECICodetext(ECIEncodings::Win1251, "Will"); + * $textBuilder->addFNC1FormatIdentifier(); + * $textBuilder->addECICodetext(ECIEncodings::UTF8, "犬Right狗"); + * $textBuilder->addFNC1FormatIdentifier(); + * $textBuilder->addECICodetext(ECIEncodings::UTF16BE, "犬Power狗"); + * $textBuilder->addPlainCodetext("Plain text"); + * $textBuilder->addFNC3SymbolSeparator(); + * $textBuilder->addFNC3ReaderInitialization(); + * $textBuilder->addPlainCodetext("Reader initialization info"); + * //generate codetext + * $codetext = $textBuilder->getExtendedCodetext(); + * //generate + * $generator = new BarcodeGenerator(EncodeTypes::DOT_CODE, $codetext); + * { + * $generator->getParameters()->getBarcode()->getDotCode()->setDotCodeEncodeMode(DotCodeEncodeMode::EXTENDED_CODETEXT); + * $generator->save("test.bmp", BarCodeImageFormat::BMP); + * } + *+ *+ * Adds FNC1 format identifier to the extended codetext items + *
+ */ + public function addFNC1FormatIdentifier(): void + { + $extCodeItemDTO = new \Aspose\Barcode\Bridge\ExtCodeItemDTO(); + $extCodeItemDTO->extCodeItemType = ExtCodeItemType::FNC_1_FORMAT_IDENTIFIER; + $extCodeItemDTO->arguments = array(); + array_push($this->_list, $extCodeItemDTO); + } + + /** + *+ * Adds FNC3 symbol separator to the extended codetext items + *
+ */ + public function addFNC3SymbolSeparator(): void + { + $extCodeItemDTO = new \Aspose\Barcode\Bridge\ExtCodeItemDTO(); + $extCodeItemDTO->extCodeItemType = ExtCodeItemType::FNC_3_SYMBOL_SEPARATOR; + $extCodeItemDTO->arguments = array(); + array_push($this->_list, $extCodeItemDTO); + } + + /** + *+ * Adds FNC3 reader initialization to the extended codetext items + *
+ */ + public function addFNC3ReaderInitialization(): void + { + $extCodeItemDTO = new \Aspose\Barcode\Bridge\ExtCodeItemDTO(); + $extCodeItemDTO->extCodeItemType = ExtCodeItemType::FNC_3_RRADER_INITILIZATION; + $extCodeItemDTO->arguments = array(); + array_push($this->_list, $extCodeItemDTO); + } + + /** + *+ * Adds structured append mode to the extended codetext items + *
+ * @param int barcodeId ID of barcode + * @param int barcodesCount Barcodes count + */ + public function addStructuredAppendMode(int $barcodeId, int $barcodesCount): void + { + $extCodeItemDTO = new \Aspose\Barcode\Bridge\ExtCodeItemDTO(); + $extCodeItemDTO->extCodeItemType = ExtCodeItemType::STRUCTURE_APPEND_MODE; + $extCodeItemDTO->arguments = array($barcodeId, $barcodesCount); + array_push($this->_list, $extCodeItemDTO); + } + + protected function getExtCodetextBuilderType(): int + { + return ExtCodetextBuilderType::DOT_CODE_EXT_CODETEXT_BUILDER; + } + + public function init(): void + { + } +} \ No newline at end of file diff --git a/lib/Generation/DotCodeParameters.php b/lib/Generation/DotCodeParameters.php new file mode 100644 index 00000000..56a966f7 --- /dev/null +++ b/lib/Generation/DotCodeParameters.php @@ -0,0 +1,237 @@ +dotCodeParametersDto; + } + + private function setDotCodeParametersDto(DotCodeParametersDTO $dotCodeParametersDto): void + { + $this->dotCodeParametersDto = $dotCodeParametersDto; + } + + function __construct(DotCodeParametersDTO $dotCodeParametersDto) + { + $this->dotCodeParametersDto = $dotCodeParametersDto; + $this->obtainDto(); + $this->initFieldsFromDto(); + } + + public function obtainDto(...$args) + { + } + + public function initFieldsFromDto(): void + { + } + + /** + *+ * Identifies DotCode encode mode. + * Default value: Auto. + *
+ */ + public function getDotCodeEncodeMode(): int + { + return $this->getDotCodeParametersDto()->dotCodeEncodeMode; + } + + /** + *+ * Identifies DotCode encode mode. + * Default value: Auto. + *
+ */ + public function setDotCodeEncodeMode(int $value): void + { + $this->getDotCodeParametersDto()->dotCodeEncodeMode = $value; + } + + /** + *+ * Indicates whether code is used for instruct reader to interpret the following data as instructions for initialization or reprogramming of the bar code reader. + * Default value is false. + *
+ */ + public function isReaderInitialization(): bool + { + return $this->getDotCodeParametersDto()->isReaderInitialization; + } + + /** + *+ * Indicates whether code is used for instruct reader to interpret the following data as instructions for initialization or reprogramming of the bar code reader. + * Default value is false. + *
+ */ + public function setReaderInitialization(bool $value): void + { + $this->getDotCodeParametersDto()->isReaderInitialization = $value; + } + + /** + *+ * Identifies the ID of the DotCode structured append mode barcode. ID starts from 1 and must be less or equal to barcodes count. Default value is -1. + *
+ */ + public function getDotCodeStructuredAppendModeBarcodeId(): int + { + return $this->getDotCodeParametersDto()->dotCodeStructuredAppendModeBarcodeId; + } + + /** + *+ * Identifies the ID of the DotCode structured append mode barcode. ID starts from 1 and must be less or equal to barcodes count. Default value is -1. + *
+ */ + public function setDotCodeStructuredAppendModeBarcodeId(int $value) + { + $this->getDotCodeParametersDto()->dotCodeStructuredAppendModeBarcodeId = $value; + } + + /** + *+ * Identifies DotCode structured append mode barcodes count. Default value is -1. Count must be a value from 1 to 35. + *
+ */ + public function getDotCodeStructuredAppendModeBarcodesCount(): int + { + return $this->getDotCodeParametersDto()->dotCodeStructuredAppendModeBarcodesCount; + } + + /** + *+ * Identifies DotCode structured append mode barcodes count. Default value is -1. Count must be a value from 1 to 35. + *
+ */ + public function setDotCodeStructuredAppendModeBarcodesCount(int $value): void + { + $this->getDotCodeParametersDto()->dotCodeStructuredAppendModeBarcodesCount = $value; + } + + /** + *+ * Identifies ECI encoding. Used when DotCodeEncodeMode is Auto. + * Default value: ISO-8859-1 + *
+ */ + public function getECIEncoding(): int + { + return $this->getDotCodeParametersDto()->eCIEncoding; + } + + /** + *+ * Identifies ECI encoding. Used when DotCodeEncodeMode is Auto. + * Default value: ISO-8859-1 + *
+ */ + public function setECIEncoding(int $value): void + { + $this->getDotCodeParametersDto()->eCIEncoding = $value; + } + + /** + *+ * Identifies rows count. Sum of the number of rows plus the number of columns of a DotCode symbol must be odd. Number of rows must be at least 5. + * Default value: -1 + *
+ */ + public function getRows(): int + { + return $this->getDotCodeParametersDto()->rows; + } + + /** + *+ * Identifies rows count. Sum of the number of rows plus the number of columns of a DotCode symbol must be odd. Number of rows must be at least 5. + * Default value: -1 + *
+ */ + public function setRows(int $value): void + { + $this->getDotCodeParametersDto()->rows = $value; + } + + /** + *+ * Identifies columns count. Sum of the number of rows plus the number of columns of a DotCode symbol must be odd. Number of columns must be at least 5. + * Default value: -1 + *
+ */ + public function getColumns(): int + { + return $this->getDotCodeParametersDto()->columns; + } + + /** + *+ * Identifies columns count. Sum of the number of rows plus the number of columns of a DotCode symbol must be odd. Number of columns must be at least 5. + * Default value: -1 + *
+ */ + public function setColumns(int $value): void + { + $this->getDotCodeParametersDto()->columns = $value; + } + + /** + * Height/Width ratio of 2D BarCode module. + */ + public function getAspectRatio(): float + { + try + { + return $this->getDotCodeParametersDto()->aspectRatio; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Height/Width ratio of 2D BarCode module. + */ + public function setAspectRatio(float $value): void + { + try + { + $this->getDotCodeParametersDto()->aspectRatio = $value; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Returns a human-readable string representation of this DotCodeParameters. + * + * @return string that represents this DotCodeParameters. + */ + public function toString(): string + { + $thriftConnection = new ThriftConnection(); + $client = $thriftConnection->openConnection(); + $str = $client->DotCodeParameters_toString($this->getDotCodeParametersDto()); + $thriftConnection->closeConnection(); + + return $str; + } +} \ No newline at end of file diff --git a/lib/Generation/ECIEncodings.php b/lib/Generation/ECIEncodings.php new file mode 100644 index 00000000..18f94389 --- /dev/null +++ b/lib/Generation/ECIEncodings.php @@ -0,0 +1,163 @@ +setCodeText("12345TEXT"); + * $generator->getParameters()->getBarcode()->getQR()->setQrEncodeMode(QREncodeMode::ECI_ENCODING); + * $generator->getParameters()->getBarcode()->getQR()->setQrECIEncoding(ECIEncodings::UTF_8); + * $generator->save("test.png", "PNG"); + * @endcode + */ +class ECIEncodings +{ + + /** + * ISO/IEC 8859-1 Latin alphabet No. 1 encoding. ECI Id:"\000003" + */ + const ISO_8859_1 = 3; + /** + * ISO/IEC 8859-2 Latin alphabet No. 2 encoding. ECI Id:"\000004" + */ + const ISO_8859_2 = 4; + /** + * ISO/IEC 8859-3 Latin alphabet No. 3 encoding. ECI Id:"\000005" + */ + const ISO_8859_3 = 5; + /** + * ISO/IEC 8859-4 Latin alphabet No. 4 encoding. ECI Id:"\000006" + */ + const ISO_8859_4 = 6; + /** + * ISO/IEC 8859-5 Latin/Cyrillic alphabet encoding. ECI Id:"\000007" + */ + const ISO_8859_5 = 7; + /** + * ISO/IEC 8859-6 Latin/Arabic alphabet encoding. ECI Id:"\000008" + */ + const ISO_8859_6 = 8; + /** + * ISO/IEC 8859-7 Latin/Greek alphabet encoding. ECI Id:"\000009" + */ + const ISO_8859_7 = 9; + /** + * ISO/IEC 8859-8 Latin/Hebrew alphabet encoding. ECI Id:"\000010" + */ + const ISO_8859_8 = 10; + /** + * ISO/IEC 8859-9 Latin alphabet No. 5 encoding. ECI Id:"\000011" + */ + const ISO_8859_9 = 11; + /** + * ISO/IEC 8859-10 Latin alphabet No. 6 encoding. ECI Id:"\000012" + */ + const ISO_8859_10 = 12; + /** + * ISO/IEC 8859-11 Latin/Thai alphabet encoding. ECI Id:"\000013" + */ + const ISO_8859_11 = 13; + //14 is reserved + /** + * ISO/IEC 8859-13 Latin alphabet No. 7 (Baltic Rim) encoding. ECI Id:"\000015" + */ + const ISO_8859_13 = 15; + /** + * ISO/IEC 8859-14 Latin alphabet No. 8 (Celtic) encoding. ECI Id:"\000016" + */ + const ISO_8859_14 = 16; + /** + * ISO/IEC 8859-15 Latin alphabet No. 9 encoding. ECI Id:"\000017" + */ + const ISO_8859_15 = 17; + /** + * ISO/IEC 8859-16 Latin alphabet No. 10 encoding. ECI Id:"\000018" + */ + const ISO_8859_16 = 18; + //19 is reserved + /** + * Shift JIS (JIS X 0208 Annex 1 + JIS X 0201) encoding. ECI Id:"\000020" + */ + const Shift_JIS = 20; + // + /** + * Windows 1250 Latin 2 (Central Europe) encoding. ECI Id:"\000021" + */ + const Win1250 = 21; + /** + * Windows 1251 Cyrillic encoding. ECI Id:"\000022" + */ + const Win1251 = 22; + /** + * Windows 1252 Latin 1 encoding. ECI Id:"\000023" + */ + const Win1252 = 23; + /** + * Windows 1256 Arabic encoding. ECI Id:"\000024" + */ + const Win1256 = 24; + // + /** + * ISO/IEC 10646 UCS-2 (High order byte first) encoding. ECI Id:"\000025" + */ + const UTF16BE = 25; + /** + * ISO/IEC 10646 UTF-8 encoding. ECI Id:"\000026" + */ + const UTF8 = 26; + // + /** + * ISO/IEC 646:1991 International Reference Version of ISO 7-bit coded character set encoding. ECI Id:"\000027" + */ + const US_ASCII = 27; + /** + * Big 5 (Taiwan) Chinese Character Set encoding. ECI Id:"\000028" + */ + const Big5 = 28; + /** + *GB2312 Chinese Character Set encoding. ECI Id:"\000029"
+ */ + const GB2312 = 29; + /** + * Korean Character Set encoding. ECI Id:"\000030" + */ + const EUC_KR = 30; + /** + *GBK (extension of GB2312 for Simplified Chinese) encoding. ECI Id:"\000031"
+ */ + const GBK = 31; + /** + *GGB18030 Chinese Character Set encoding. ECI Id:"\000032"
+ */ + const GB18030 = 32; + /** + *ISO/IEC 10646 UTF-16LE encoding. ECI Id:"\000033"
+ */ + const UTF16LE = 33; + /** + *ISO/IEC 10646 UTF-32BE encoding. ECI Id:"\000034"
+ */ + const UTF32BE = 34; + /** + *ISO/IEC 10646 UTF-32LE encoding. ECI Id:"\000035"
+ */ + const UTF32LE = 35; + /** + *ISO/IEC 646: ISO 7-bit coded character set - Invariant Characters set encoding. ECI Id:"\000170"
+ */ + const INVARIANT = 170; + /** + *8-bit binary data. ECI Id:"\000899"
+ */ + const BINARY = 899; + + /** + * No Extended Channel Interpretation/p> + */ + const NONE = 0; +} \ No newline at end of file diff --git a/lib/Generation/EnableChecksum.php b/lib/Generation/EnableChecksum.php new file mode 100644 index 00000000..e2620ee0 --- /dev/null +++ b/lib/Generation/EnableChecksum.php @@ -0,0 +1,28 @@ + + * Specifies that the data should be encoded with {@code Code 39} basic charset barcode specification: ISO/IEC 16388 + * + */ + const CODE_39 = 2; + + /** + *+ * Specifies that the data should be encoded with {@code Code 39} full ASCII charset barcode specification: ISO/IEC 16388 + *
+ */ + const CODE_39_FULL_ASCII = 3; + + /** + *+ * Specifies that the data should be encoded with {@code CODE 93} barcode specification + *
+ */ + const CODE_93 = 5; + + /** + * Specifies that the data should be encoded with CODE 128 barcode specification + */ + const CODE_128 = 6; + + /** + * Specifies that the data should be encoded with GS1 Code 128 barcode specification. The codetext must contains parentheses for AI. + */ + const GS_1_CODE_128 = 7; + + /** + * Specifies that the data should be encoded with EAN-8 barcode specification + */ + const EAN_8 = 8; + + /** + * Specifies that the data should be encoded with EAN-13 barcode specification + */ + const EAN_13 = 9; + + /** + * Specifies that the data should be encoded with EAN14 barcode specification + */ + const EAN_14 = 10; + + /** + * Specifies that the data should be encoded with SCC14 barcode specification + */ + const SCC_14 = 11; + + /** + * Specifies that the data should be encoded with SSCC18 barcode specification + */ + const SSCC_18 = 12; + + /** + * Specifies that the data should be encoded with UPC-A barcode specification + */ + const UPCA = 13; + + /** + * Specifies that the data should be encoded with UPC-E barcode specification + */ + const UPCE = 14; + + /** + * Specifies that the data should be encoded with isBN barcode specification + */ + const ISBN = 15; + + /** + * Specifies that the data should be encoded with ISSN barcode specification + */ + const ISSN = 16; + + /** + * Specifies that the data should be encoded with ISMN barcode specification + */ + const ISMN = 17; + + /** + * Specifies that the data should be encoded with Standard 2 of 5 barcode specification + */ + const STANDARD_2_OF_5 = 18; + + /** + * Specifies that the data should be encoded with INTERLEAVED 2 of 5 barcode specification + */ + const INTERLEAVED_2_OF_5 = 19; + + /** + * Represents Matrix 2 of 5 BarCode + */ + const MATRIX_2_OF_5 = 20; + + /** + * Represents Italian Post 25 barcode. + */ + const ITALIAN_POST_25 = 21; + + /** + * Represents IATA 2 of 5 barcode.IATA (International Air Transport Assosiation) uses this barcode for the management of air cargo. + */ + const IATA_2_OF_5 = 22; + + /** + * Specifies that the data should be encoded with ITF14 barcode specification + */ + const ITF_14 = 23; + + /** + * Represents ITF-6 Barcode. + */ + const ITF_6 = 24; + + /** + * Specifies that the data should be encoded with MSI Plessey barcode specification + */ + const MSI = 25; + + /** + * Represents VIN (Vehicle Identification Number) Barcode. + */ + const VIN = 26; + + /** + * Represents Deutsch Post barcode, This EncodeType is also known as Identcode,CodeIdentcode,German Postal 2 of 5 Identcode, + * Deutsch Post AG Identcode, Deutsch Frachtpost Identcode, Deutsch Post AG (DHL) + */ + const DEUTSCHE_POST_IDENTCODE = 27; + + /** + * Represents Deutsch Post Leitcode Barcode,also known as German Postal 2 of 5 Leitcode, CodeLeitcode, Leitcode, Deutsch Post AG (DHL). + */ + const DEUTSCHE_POST_LEITCODE = 28; + + /** + * Represents OPC(Optical Product Code) Barcode,also known as , VCA Barcode VCA OPC, Vision Council of America OPC Barcode. + */ + const OPC = 29; + + /** + * Represents PZN barcode.This EncodeType is also known as Pharmacy central number, Pharmazentralnummer + */ + const PZN = 30; + + /** + * Represents Code 16K barcode. + */ + const CODE_16_K = 31; + + /** + * Represents Pharmacode barcode. + */ + const PHARMACODE = 32; + + /** + * 2D barcode symbology DataMatrix + */ + const DATA_MATRIX = 33; + + /** + * Specifies that the data should be encoded with QR Code barcode specification + */ + const QR = 34; + + /** + * Specifies that the data should be encoded with Aztec barcode specification + */ + const AZTEC = 35; + + /** + *+ * Specifies that the data should be encoded with {@code GS1 Aztec} barcode specification. The codetext must contains parentheses for AI. + *
+ */ + const GS_1_AZTEC = 81; + + /** + * Specifies that the data should be encoded with Pdf417 barcode specification + */ + const PDF_417 = 36; + + /** + * Specifies that the data should be encoded with MacroPdf417 barcode specification + */ + const MACRO_PDF_417 = 37; + + /** + * 2D barcode symbology DataMatrix with GS1 string format + */ + const GS_1_DATA_MATRIX = 48; + + /** + * Specifies that the data should be encoded with MicroPdf417 barcode specification + */ + const MICRO_PDF_417 = 55; + + /** + * Specifies that the data should be encoded with GS1MicroPdf417 barcode specification + */ + const GS_1_MICRO_PDF_417 = 82; + + /** + * 2D barcode symbology QR with GS1 string format + */ + const GS_1_QR = 56; + + /** + * Specifies that the data should be encoded with MaxiCode barcode specification + */ + const MAXI_CODE = 57; + + /** + * Specifies that the data should be encoded with DotCode barcode specification + */ + const DOT_CODE = 60; + + /** + * Represents Australia Post Customer BarCode + */ + const AUSTRALIA_POST = 38; + + /** + * Specifies that the data should be encoded with Postnet barcode specification + */ + const POSTNET = 39; + + /** + * Specifies that the data should be encoded with Planet barcode specification + */ + const PLANET = 40; + + /** + * Specifies that the data should be encoded with USPS OneCode barcode specification + */ + const ONE_CODE = 41; + + /** + * Represents RM4SCC barcode. RM4SCC (Royal Mail 4-state Customer Code) is used for automated mail sort process in UK. + */ + const RM_4_SCC = 42; + + /** + * Represents Royal Mail Mailmark barcode. + */ + const MAILMARK = 66; + + /** + * Specifies that the data should be encoded with GS1 Databar omni-directional barcode specification. + */ + const DATABAR_OMNI_DIRECTIONAL = 43; + + /** + * Specifies that the data should be encoded with GS1 Databar truncated barcode specification. + */ + const DATABAR_TRUNCATED = 44; + + /** + * Represents GS1 DATABAR limited barcode. + */ + const DATABAR_LIMITED = 45; + + /** + * Represents GS1 Databar expanded barcode. + */ + const DATABAR_EXPANDED = 46; + + /** + * Represents GS1 Databar expanded stacked barcode. + */ + const DATABAR_EXPANDED_STACKED = 52; + + /** + * Represents GS1 Databar stacked barcode. + */ + const DATABAR_STACKED = 53; + + /** + * Represents GS1 Databar stacked omni-directional barcode. + */ + const DATABAR_STACKED_OMNI_DIRECTIONAL = 54; + + /** + * Specifies that the data should be encoded with Singapore Post Barcode barcode specification + */ + const SINGAPORE_POST = 47; + + /** + * Specifies that the data should be encoded with Australian Post Domestic eParcel Barcode barcode specification + */ + const AUSTRALIAN_POSTE_PARCEL = 49; + + /** + * Specifies that the data should be encoded with Swiss Post Parcel Barcode barcode specification. Supported types: Domestic Mail, International Mail, Additional Services (new) + */ + const SWISS_POST_PARCEL = 50; + + /** + * Represents Patch code barcode + */ + const PATCH_CODE = 51; + + /** + * Specifies that the data should be encoded with Code32 barcode specification + */ + const CODE_32 = 58; + + /** + * Specifies that the data should be encoded with DataLogic 2 of 5 barcode specification + */ + const DATA_LOGIC_2_OF_5 = 59; + + /** + * Specifies that the data should be encoded with Dutch KIX barcode specification + */ + const DUTCH_KIX = 61; + + /** + * Specifies that the data should be encoded with UPC coupon with GS1-128 Extended Code barcode specification. + * An example of the input string: + * BarCodeBuilder->setCodetext("514141100906(8102)03"), + * where UPCA part is "514141100906", GS1Code128 part is (8102)03. + */ + const UPCA_GS_1_CODE_128_COUPON = 62; + + /** + * Specifies that the data should be encoded with UPC coupon with GS1 DataBar addition barcode specification. + * + * An example of the input string: + * @code + * BarcodeGenerator->setCodetext("514141100906(8110)106141416543213500110000310123196000"), + * @endcode + * where UPCA part is "514141100906", DATABAR part is "(8110)106141416543213500110000310123196000". + * To change the caption, use barCodeBuilder->getCaptionAbove()->setText("company prefix + offer code"); + */ + const UPCA_GS_1_DATABAR_COUPON = 63; + + /** + * Specifies that the data should be encoded with Codablock-F barcode specification. + */ + const CODABLOCK_F = 64; + + /** + * Specifies that the data should be encoded with GS1 Codablock-F barcode specification. The codetext must contains parentheses for AI. + */ + const GS_1_CODABLOCK_F = 65; + + /** + * Specifies that the data should be encoded with GS1 Composite Bar barcode specification. The codetext must contains parentheses for AI. 1D codetext and 2D codetext must be separated with symbol '/' + */ + const GS_1_COMPOSITE_BAR = 67; + + /** + *+ * Specifies that the data should be encoded with {@code HIBC LIC Code39Standart} barcode specification. + *
+ */ + const HIBC_CODE_39_LIC = 68; + + /** + *+ * Specifies that the data should be encoded with {@code HIBC LIC Code128} barcode specification. + *
+ */ + const HIBC_CODE_128_LIC = 69; + + /** + *+ * Specifies that the data should be encoded with {@code HIBC LIC Aztec} barcode specification. + *
+ */ + const HIBC_AZTEC_LIC = 70; + + /** + *+ * Specifies that the data should be encoded with {@code HIBC LIC DataMatrix} barcode specification. + *
+ */ + const HIBC_DATA_MATRIX_LIC = 71; + + /** + *+ * Specifies that the data should be encoded with {@code HIBC LIC QR} barcode specification. + *
+ */ + const HIBCQRLIC = 72; + + /** + *+ * Specifies that the data should be encoded with {@code HIBC PAS Code39Standart} barcode specification. + *
+ */ + const HIBC_CODE_39_PAS = 73; + + /** + *+ * Specifies that the data should be encoded with {@code HIBC PAS Code128} barcode specification. + *
+ */ + const HIBC_CODE_128_PAS = 74; + + /** + *+ * Specifies that the data should be encoded with {@code HIBC PAS Aztec} barcode specification. + *
+ */ + const HIBC_AZTEC_PAS = 75; + + /** + *+ * Specifies that the data should be encoded with {@code HIBC PAS DataMatrix} barcode specification. + *
+ */ + const HIBC_DATA_MATRIX_PAS = 76; + + /** + *+ * Specifies that the data should be encoded with {@code HIBC PAS QR} barcode specification. + *
+ */ + const HIBCQRPAS = 77; + + /** + *+ * Specifies that the data should be encoded with {@code GS1 DotCode} barcode specification. The codetext must contains parentheses for AI. + *
+ */ + const GS_1_DOT_CODE = 78; + + /** + * Specifies that the data should be encoded with Han Xin barcode specification + */ + const HAN_XIN = 79; + + /** + * 2D barcode symbology QR with GS1 string format + */ + const GS_1_HAN_XIN = 80; + + /** + * Specifies that the data should be encoded with MicroQR Code barcode specification + */ + const MICRO_QR = 83; + + /** + * Specifies that the data should be encoded with RectMicroQR (rMQR) Code barcode specification + */ + const RECT_MICRO_QR = 84; + + public static function parse(string $encodeTypeName): int + { + if ($encodeTypeName == "CODABAR") return 0; + + else if ($encodeTypeName == "CODE_11") return 1; + + else if ($encodeTypeName == "CODE_39") return 2; + + else if ($encodeTypeName == "CODE_39_FULL_ASCII") return 3; + + else if ($encodeTypeName == "CODE_93") return 5; + + else if ($encodeTypeName == "CODE_128") return 6; + + else if ($encodeTypeName == "GS_1_CODE_128") return 7; + + else if ($encodeTypeName == "EAN_8") return 8; + + else if ($encodeTypeName == "EAN_13") return 9; + + else if ($encodeTypeName == "EAN_14") return 10; + + else if ($encodeTypeName == "SCC_14") return 11; + + else if ($encodeTypeName == "SSCC_18") return 12; + + else if ($encodeTypeName == "UPCA") return 13; + + else if ($encodeTypeName == "UPCE") return 14; + + else if ($encodeTypeName == "ISBN") return 15; + + else if ($encodeTypeName == "ISSN") return 16; + + else if ($encodeTypeName == "ISMN") return 17; + + else if ($encodeTypeName == "STANDARD_2_OF_5") return 18; + + else if ($encodeTypeName == "INTERLEAVED_2_OF_5") return 19; + + else if ($encodeTypeName == "MATRIX_2_OF_5") return 20; + + else if ($encodeTypeName == "ITALIAN_POST_25") return 21; + + else if ($encodeTypeName == "IATA_2_OF_5") return 22; + + else if ($encodeTypeName == "ITF_14") return 23; + + else if ($encodeTypeName == "ITF_6") return 24; + + else if ($encodeTypeName == "MSI") return 25; + + else if ($encodeTypeName == "VIN") return 26; + + else if ($encodeTypeName == "DEUTSCHE_POST_IDENTCODE") return 27; + + else if ($encodeTypeName == "DEUTSCHE_POST_LEITCODE") return 28; + + else if ($encodeTypeName == "OPC") return 29; + + else if ($encodeTypeName == "PZN") return 30; + + else if ($encodeTypeName == "CODE_16_K") return 31; + + else if ($encodeTypeName == "PHARMACODE") return 32; + + else if ($encodeTypeName == "DATA_MATRIX") return 33; + + else if ($encodeTypeName == "QR") return 34; + + else if ($encodeTypeName == "AZTEC") return 35; + + else if ($encodeTypeName == "GS_1_AZTEC") return 81; + + else if ($encodeTypeName == "PDF_417") return 36; + + else if ($encodeTypeName == "MACRO_PDF_417") return 37; + + else if ($encodeTypeName == "GS_1_DATA_MATRIX") return 48; + + else if ($encodeTypeName == "MICRO_PDF_417") return 55; + + else if ($encodeTypeName == "GS_1_QR") return 56; + + else if ($encodeTypeName == "MAXI_CODE") return 57; + + else if ($encodeTypeName == "DOT_CODE") return 60; + + else if ($encodeTypeName == "AUSTRALIA_POST") return 38; + + else if ($encodeTypeName == "POSTNET") return 39; + + else if ($encodeTypeName == "PLANET") return 40; + + else if ($encodeTypeName == "ONE_CODE") return 41; + + else if ($encodeTypeName == "RM_4_SCC") return 42; + + else if ($encodeTypeName == "MAILMARK") return 66; + + else if ($encodeTypeName == "DATABAR_OMNI_DIRECTIONAL") return 43; + + else if ($encodeTypeName == "DATABAR_TRUNCATED") return 44; + + else if ($encodeTypeName == "DATABAR_LIMITED") return 45; + + else if ($encodeTypeName == "DATABAR_EXPANDED") return 46; + + else if ($encodeTypeName == "DATABAR_EXPANDED_STACKED") return 52; + + else if ($encodeTypeName == "DATABAR_STACKED") return 53; + + else if ($encodeTypeName == "DATABAR_STACKED_OMNI_DIRECTIONAL") return 54; + + else if ($encodeTypeName == "SINGAPORE_POST") return 47; + + else if ($encodeTypeName == "AUSTRALIAN_POSTE_PARCEL") return 49; + + else if ($encodeTypeName == "SWISS_POST_PARCEL") return 50; + + else if ($encodeTypeName == "PATCH_CODE") return 51; + + else if ($encodeTypeName == "CODE_32") return 58; + + else if ($encodeTypeName == "DATA_LOGIC_2_OF_5") return 59; + + else if ($encodeTypeName == "DUTCH_KIX") return 61; + + else if ($encodeTypeName == "UPCA_GS_1_CODE_128_COUPON") return 62; + + else if ($encodeTypeName == "UPCA_GS_1_DATABAR_COUPON") return 63; + + else if ($encodeTypeName == "CODABLOCK_F") return 64; + + else if ($encodeTypeName == "GS_1_CODABLOCK_F") return 65; + + else if ($encodeTypeName == "GS_1_COMPOSITE_BAR") return 67; + + else if ($encodeTypeName == "HIBC_CODE_39_LIC") return 68; + + else if ($encodeTypeName == "HIBC_CODE_128_LIC") return 69; + + else if ($encodeTypeName == "HIBC_AZTEC_LIC") return 70; + + else if ($encodeTypeName == "HIBC_DATA_MATRIX_LIC") return 71; + + else if ($encodeTypeName == "HIBCQRLIC") return 72; + + else if ($encodeTypeName == "HIBC_CODE_39_PAS") return 73; + + else if ($encodeTypeName == "HIBC_CODE_128_PAS") return 74; + + else if ($encodeTypeName == "HIBC_AZTEC_PAS") return 75; + + else if ($encodeTypeName == "HIBC_DATA_MATRIX_PAS") return 76; + + else if ($encodeTypeName == "HIBCQRPAS") return 77; + + else if ($encodeTypeName == "GS_1_DOT_CODE") return 78; + + else if ($encodeTypeName == "HAN_XIN") return 79; + + else if ($encodeTypeName == "GS_1_HAN_XIN") return 80; + + else if ($encodeTypeName == "MICRO_QR") return 83; + + else if ($encodeTypeName == "RECT_MICRO_QR") return 84; + + else return -1; + } +} \ No newline at end of file diff --git a/lib/Generation/ExtCodeItemType.php b/lib/Generation/ExtCodeItemType.php new file mode 100644 index 00000000..aa99ad3a --- /dev/null +++ b/lib/Generation/ExtCodeItemType.php @@ -0,0 +1,18 @@ +_list = array(); + } + + function init(): void + { + } + + /** + * Clears extended codetext items + */ + public function clear(): void + { + try + { + array_splice($this->_list, 0); + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Adds plain codetext to the extended codetext items + * + * @param string $codetext Codetext in unicode to add as extended codetext item + */ + public function addPlainCodetext(string $codetext): void + { + try + { + $extCodeItemDTO = new \Aspose\Barcode\Bridge\ExtCodeItemDTO(); + $extCodeItemDTO->extCodeItemType = ExtCodeItemType::PLAIN_CODETEXT; + $extCodeItemDTO->arguments = array($codetext); + array_push($this->_list, $extCodeItemDTO); + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Adds codetext with Extended Channel Identifier + * + * @param int ECIEncoding Extended Channel Identifier + * @param string codetext Codetext in unicode to add as extended codetext item with Extended Channel Identifier + */ + public function addECICodetext(int $ECIEncoding, string $codetext): void + { + try + { + $extCodeItemDTO = new \Aspose\Barcode\Bridge\ExtCodeItemDTO(); + $extCodeItemDTO->extCodeItemType = ExtCodeItemType::ECI_CODETEXT; + $extCodeItemDTO->arguments = array($ECIEncoding, $codetext); + array_push($this->_list, $extCodeItemDTO); + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Generate extended codetext from generation items list + * + * @return string Return string of extended codetext + */ + public final function getExtendedCodetext(): string + { + try + { + $thriftConnection = new ThriftConnection(); + $client = $thriftConnection->openConnection(); + $extendedCodetext = $client->ExtCodetextBuilder_getExtendedCodetext($this->getExtCodetextBuilderType(), $this->_list); + $thriftConnection->closeConnection(); + return $extendedCodetext; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + protected abstract function getExtCodetextBuilderType(): int; +} \ No newline at end of file diff --git a/lib/Generation/ExtCodetextBuilderType.php b/lib/Generation/ExtCodetextBuilderType.php new file mode 100644 index 00000000..b050683c --- /dev/null +++ b/lib/Generation/ExtCodetextBuilderType.php @@ -0,0 +1,12 @@ +getParameters()->getCaptionAbove()->setText("CAPTION ABOOVE"); + * $generator->getParameters()->getCaptionAbove()->setVisible(true); + * $generator->getParameters()->getCaptionAbove()->getFont()->setStyle(FontStyle::ITALIC); + * $generator->getParameters()->getCaptionAbove()->getFont()->getSize()->setPoint(25); + * @endcode + */ +final class FontUnit implements Communicator +{ + private $fontUnitDto; + + function getFontUnitDto(): FontUnitDTO + { + return $this->fontUnitDto; + } + + private function setFontUnitDto(FontUnitDTO $fontUnitDto): void + { + $this->fontUnitDto = $fontUnitDto; + } + + private $_size; + + public function __construct($source) + { + $this->fontUnitDto = self::initFontUnit($source); + $this->obtainDto(); + $this->initFieldsFromDto(); + } + + private static function initFontUnit($source) + { + if ($source instanceof FontUnit) + { + return $source->getFontUnitDto(); + } elseif ($source instanceof FontUnitDTO) + return $source; + throw new InvalidArgumentException(); + } + + public function obtainDto(...$args) + { + } + + public function initFieldsFromDto(): void + { + try + { + $this->_size = new Unit($this->getFontUnitDto()->size); + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Gets the face name of this Font. + */ + public function getFamilyName(): string + { + try + { + return $this->getFontUnitDto()->familyName; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Sets the face name of this Font. + */ + public function setFamilyName(string $value): void + { + try + { + $this->getFontUnitDto()->familyName = $value; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Gets style information for this FontUnit. + */ + public function getStyle(): int + { + try + { + return $this->getFontUnitDto()->style; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Sets style information for this FontUnit. + */ + public function setStyle(int $value): void + { + try + { + $this->getFontUnitDto()->style = $value; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Gets size of this FontUnit in Unit value. + * + * @exception IllegalArgumentException + * The Size parameter value is less than or equal to 0. + */ + public function getSize(): Unit + { + return $this->_size; + } +} \ No newline at end of file diff --git a/lib/Generation/GS1CompositeBarParameters.php b/lib/Generation/GS1CompositeBarParameters.php new file mode 100644 index 00000000..1d1212ec --- /dev/null +++ b/lib/Generation/GS1CompositeBarParameters.php @@ -0,0 +1,106 @@ +gs1CompositeBarParametersDto; + } + + private function setGS1CompositeBarParametersDto(GS1CompositeBarParametersDTO $gs1CompositeBarParametersDto): void + { + $this->gs1CompositeBarParametersDto = $gs1CompositeBarParametersDto; + } + + function __construct(GS1CompositeBarParametersDTO $gs1CompositeBarParametersDto) + { + $this->gs1CompositeBarParametersDto = $gs1CompositeBarParametersDto; + $this->obtainDto(); + $this->initFieldsFromDto(); + } + + public function obtainDto(...$args) + { + } + + public function initFieldsFromDto(): void + { + } + + /** + * Linear component type: GS1Code128, UPCE, EAN8, UPCA, EAN13, DatabarStacked, DatabarStackedOmniDirectional, DatabarLimited, DatabarOmniDirectional, DatabarExpanded, DatabarExpandedStacked + */ + public function getLinearComponentType(): int + { + return $this->getGS1CompositeBarParametersDto()->linearComponentType; + } + + /** + * Linear component type: GS1Code128, UPCE, EAN8, UPCA, EAN13, DatabarStacked, DatabarStackedOmniDirectional, DatabarLimited, DatabarOmniDirectional, DatabarExpanded, DatabarExpandedStacked + */ + public function setLinearComponentType(int $value): void + { + $this->getGS1CompositeBarParametersDto()->linearComponentType = $value; + } + + /** + * 2D component type + */ + public function getTwoDComponentType(): int + { + return $this->getGS1CompositeBarParametersDto()->twoDComponentType; + } + + /** + * 2D component type + */ + public function setTwoDComponentType(int $value): void + { + $this->getGS1CompositeBarParametersDto()->twoDComponentType = $value; + } + + /** + *+ * If this flag is set, it allows only GS1 encoding standard for GS1CompositeBar 2D Component + *
+ */ + public function isAllowOnlyGS1Encoding(): bool + { + return $this->getGS1CompositeBarParametersDto()->isAllowOnlyGS1Encoding; + } + + /** + *+ * If this flag is set, it allows only GS1 encoding standard for GS1CompositeBar 2D Component + *
+ */ + public function setAllowOnlyGS1Encoding(bool $value): void + { + $this->getGS1CompositeBarParametersDto()->isAllowOnlyGS1Encoding = $value; + } + + /** + * Returns a human-readable string representation of this. + * @return string that represents this + */ + public function toString(): string + { + $thriftConnection = new ThriftConnection(); + $client = $thriftConnection->openConnection(); + $str = $client->GS1CompositeBarParameters_toString($this->getGS1CompositeBarParametersDto()); + $thriftConnection->closeConnection(); + + return $str; + } +} \ No newline at end of file diff --git a/lib/Generation/GraphicsUnit.php b/lib/Generation/GraphicsUnit.php new file mode 100644 index 00000000..f30a2f0c --- /dev/null +++ b/lib/Generation/GraphicsUnit.php @@ -0,0 +1,44 @@ + + * Han Xin Code encoding mode. It is recommended to use Auto with ASCII / Chinese characters or Unicode for Unicode characters. + * + */ +class HanXinEncodeMode +{ + /** + *+ *+ * // Auto mode + * $codetext = "1234567890ABCDEFGabcdefg,Han Xin Code"; + * $generator = new BarcodeGenerator(EncodeTypes::HAN_XIN, codetext); + * $generator->save("test.bmp", BarcodeImageFormat::BMP); + * + * // Bytes mode + * $encodedArr = array(0xFF, 0xFE, 0xFD, 0xFC, 0xFB, 0xFA, 0xF9); + * + * //encode array to string + * StringBuilder strBld = new StringBuilder(); + * for (byte bval : encodedArr) + * strBld.append((char) bval); + * $codetext = strBld.toString(); + * + * $generator = new BarcodeGenerator(EncodeTypes::HAN_XIN, codetext); + * $generator->getParameters()->getBarcode()->getHanXin()->setHanXinEncodeMode(HanXinEncodeMode::BYTES); + * $generator->save("test.bmp", BarcodeImageFormat::BMP); + * + * // ECI mode + * $codetext = "ΑΒΓΔΕ"; + * $generator = new BarcodeGenerator(EncodeTypes::HAN_XIN, codetext); + * $generator->getParameters()->getBarcode()->getHanXin()->setHanXinEncodeMode(HanXinEncodeMode::ECI); + * $generator->getParameters()->getBarcode()->getHanXin()->setHanXinECIEncoding(ECIEncodings::ISO_8859_7); + * $generator->save("test.bmp", BarcodeImageFormat::BMP); + * + * // URI mode + * $codetext = "https://www.test.com/%BC%DE%%%ab/search=test"; + * $generator = new BarcodeGenerator(EncodeTypes::HAN_XIN, codetext); + * $generator->getParameters()->getBarcode()->getHanXin()->setHanXinEncodeMode(HanXinEncodeMode::URI); + * $generator->save("test.bmp", BarcodeImageFormat::BMP); + * + * // Extended mode - TBD + *+ *+ * Sequence of Numeric, Text, ECI, Binary Bytes and 4 GB18030 modes changing automatically. + *
+ */ + const AUTO = 0; + /** + *+ * Binary byte mode encodes binary data in any form and encodes them in their binary byte. Every byte in + * Binary Byte mode is represented by 8 bits. + *
+ */ + const BINARY = 1; + /** + *+ * Extended Channel Interpretation (ECI) mode + *
+ */ + const ECI = 2; + /** + *+ * Unicode mode designs a way to represent any text data reference to UTF8 encoding/charset in Han Xin Code. + *
+ */ + const UNICODE = 3; + /** + *+ * URI mode indicates the data represented in Han Xin Code is Uniform Resource Identifier (URI) + * reference to RFC 3986. + *
+ */ + const URI = 4; + /** + *+ * Extended mode will allow more flexible combinations of other modes, this mode is currently not implemented. + *
+ */ + const EXTENDED = 5; +} \ No newline at end of file diff --git a/lib/Generation/HanXinErrorLevel.php b/lib/Generation/HanXinErrorLevel.php new file mode 100644 index 00000000..72467aee --- /dev/null +++ b/lib/Generation/HanXinErrorLevel.php @@ -0,0 +1,81 @@ + + * Level of Reed-Solomon error correction. From low to high: L1, L2, L3, L4. + * + */ +class HanXinErrorLevel +{ + /** + *+ * Allows recovery of 8% of the code text + *
+ */ + const L1 = 0; + /** + *+ * Allows recovery of 15% of the code text + *
+ */ + const L2 = 1; + /** + *+ * Allows recovery of 23% of the code text + *
+ */ + const L3 = 2; + /** + *+ * Allows recovery of 30% of the code text + *
+ */ + const L4 = 3; +} diff --git a/lib/Generation/HanXinExtCodetextBuilder.php b/lib/Generation/HanXinExtCodetextBuilder.php new file mode 100644 index 00000000..32f4464d --- /dev/null +++ b/lib/Generation/HanXinExtCodetextBuilder.php @@ -0,0 +1,251 @@ + + *Extended codetext generator for Han Xin Code for Extended Mode of HanXinEncodeMode
+ *+ */ +class HanXinExtCodetextBuilder +{ + + protected $_list; + + function __construct() + { + $this->_list = array(); + } + + function init(): void + { + } + + /** + *+ *+ * + * //Extended codetext mode + * //create codetext + * $codeTextBuilder = new HanXinExtCodetextBuilder(); + * $codeTextBuilder->addGB18030TwoByte("漄"); + * $codeTextBuilder->addGB18030FourByte("㐁"); + * $codeTextBuilder->addCommonChineseRegionOne("全"); + * $codeTextBuilder->addCommonChineseRegionTwo("螅"); + * $codeTextBuilder->addNumeric("123"); + * $codeTextBuilder->addText("qwe"); + * $codeTextBuilder->addUnicode("ıntəˈnæʃənəl"); + * $codeTextBuilder->addECI("ΑΒΓΔΕ", 9); + * $codeTextBuilder->addAuto("abc"); + * $codeTextBuilder->addBinary("abc"); + * $codeTextBuilder->addURI("backslashes_should_be_doubled\000555:test"); + * $codeTextBuilder->addGS1("(01)03453120000011(17)191125(10)ABCD1234(21)10"); + * $expectedStr = "漄㐁全螅123qweıntəˈnæʃənəlΑΒΓΔΕabcabcbackslashes_should_be_doubled\000555:test(01)03453120000011(17)191125(10)ABCD1234(21)10"; + * //generate codetext + * $str = $codeTextBuilder->getExtendedCodetext(); + * //generate + * $bg = new BarcodeGenerator(EncodeTypes::HAN_XIN, $str); + * $bg->getParameters()->getBarcode()->getHanXin()->setHanXinEncodeMode(HanXinEncodeMode::EXTENDED); + * $img = $bg->generateBarCodeImage(BarcodeImageFormat::PNG); + * $r = new BarCodeReader($img, null, DecodeType::HAN_XIN)) + * $found = $r->readBarCodes(); + * Assert::assertEquals(1, sizeof(found)); + * Assert::assertEquals($expectedStr, $found[0]->getCodeText()); + *+ *+ * Adds codetext fragment in ECI mode + *
+ * @param string text Codetext string + * @param int encoding ECI encoding in integer format + */ + public function addECI(string $text, int $encoding): void + { + $extCodeItemDTO = new ExtCodeItemDTO(); + $extCodeItemDTO->extCodeItemType = HanXinExtCodetextBuilderType::ECI; + $extCodeItemDTO->arguments = array($text, $encoding); + $this->_list[] = $extCodeItemDTO; + } + + /** + *+ * Adds codetext fragment in Auto mode + *
+ * @param string text Codetext string + */ + public function addAuto(string $text): void + { + $extCodeItemDTO = new \Aspose\Barcode\Bridge\ExtCodeItemDTO(); + $extCodeItemDTO->extCodeItemType = HanXinExtCodetextBuilderType::Auto; + $extCodeItemDTO->arguments = array($text); + array_push($this->_list, $extCodeItemDTO); + } + + /** + *+ * Adds codetext fragment in Binary mode + *
+ * @param text Codetext string + */ + public function addBinary(string $text): void + { + $extCodeItemDTO = new \Aspose\Barcode\Bridge\ExtCodeItemDTO(); + $extCodeItemDTO->extCodeItemType = HanXinExtCodetextBuilderType::Binary; + $extCodeItemDTO->arguments = array($text); + array_push($this->_list, $extCodeItemDTO); + } + + /** + *+ * Adds codetext fragment in URI mode + *
+ * @param text Codetext string + */ + public function addURI(string $text): void + { + $extCodeItemDTO = new \Aspose\Barcode\Bridge\ExtCodeItemDTO(); + $extCodeItemDTO->extCodeItemType = HanXinExtCodetextBuilderType::URI; + $extCodeItemDTO->arguments = array($text); + array_push($this->_list, $extCodeItemDTO); + } + + /** + *+ * Adds codetext fragment in Text mode + *
+ * @param text Codetext string + */ + public function addText(string $text): void + { + $extCodeItemDTO = new \Aspose\Barcode\Bridge\ExtCodeItemDTO(); + $extCodeItemDTO->extCodeItemType = HanXinExtCodetextBuilderType::Text; + $extCodeItemDTO->arguments = array($text); + array_push($this->_list, $extCodeItemDTO); + } + + /** + *+ * Adds codetext fragment in Numeric mode + *
+ * @param text Codetext string + */ + public function addNumeric(string $text): void + { + $extCodeItemDTO = new \Aspose\Barcode\Bridge\ExtCodeItemDTO(); + $extCodeItemDTO->extCodeItemType = HanXinExtCodetextBuilderType::Numeric; + $extCodeItemDTO->arguments = array($text); + array_push($this->_list, $extCodeItemDTO); + } + + /** + *+ * Adds codetext fragment in Unicode mode + *
+ * @param text Codetext string + */ + public function addUnicode(string $text): void + { + $extCodeItemDTO = new \Aspose\Barcode\Bridge\ExtCodeItemDTO(); + $extCodeItemDTO->extCodeItemType = HanXinExtCodetextBuilderType::Unicode; + $extCodeItemDTO->arguments = array($text); + array_push($this->_list, $extCodeItemDTO); + } + + /** + *+ * Adds codetext fragment in Common Chinese Region One mode + *
+ * @param text Codetext string + */ + public function addCommonChineseRegionOne(string $text): void + { + $extCodeItemDTO = new \Aspose\Barcode\Bridge\ExtCodeItemDTO(); + $extCodeItemDTO->extCodeItemType = HanXinExtCodetextBuilderType::CommonChineseRegionOne; + $extCodeItemDTO->arguments = array($text); + array_push($this->_list, $extCodeItemDTO); + } + + /** + *+ * Adds codetext fragment in Common Chinese Region Two mode + *
+ * @param text Codetext string + */ + public function addCommonChineseRegionTwo(string $text): void + { + $extCodeItemDTO = new \Aspose\Barcode\Bridge\ExtCodeItemDTO(); + $extCodeItemDTO->extCodeItemType = HanXinExtCodetextBuilderType::CommonChineseRegionTwo; + $extCodeItemDTO->arguments = array($text); + array_push($this->_list, $extCodeItemDTO); + } + + /** + *+ * Adds codetext fragment in GB18030 Two Byte mode + *
+ * @param text Codetext string + */ + public function addGB18030TwoByte(string $text): void + { + $extCodeItemDTO = new \Aspose\Barcode\Bridge\ExtCodeItemDTO(); + $extCodeItemDTO->extCodeItemType = HanXinExtCodetextBuilderType::GB18030TwoByte; + $extCodeItemDTO->arguments = array($text); + array_push($this->_list, $extCodeItemDTO); + } + + /** + *+ * Adds codetext fragment in GB18030 Four Byte mode + *
+ * @param text Codetext string + */ + public function addGB18030FourByte(string $text): void + { + $extCodeItemDTO = new \Aspose\Barcode\Bridge\ExtCodeItemDTO(); + $extCodeItemDTO->extCodeItemType = HanXinExtCodetextBuilderType::GB18030FourByte; + $extCodeItemDTO->arguments = array($text); + array_push($this->_list, $extCodeItemDTO); + } + + /** + *+ * Adds codetext fragment in GS1 mode + *
+ * @param text Codetext string + */ + public function addGS1(string $text): void + { + $extCodeItemDTO = new \Aspose\Barcode\Bridge\ExtCodeItemDTO(); + $extCodeItemDTO->extCodeItemType = HanXinExtCodetextBuilderType::GS1; + $extCodeItemDTO->arguments = array($text); + array_push($this->_list, $extCodeItemDTO); + } + + /** + *+ * Returns codetext from Extended mode codetext builder + *
+ * @return string Codetext in Extended mode + */ + public function getExtendedCodetext(): string + { + try + { + $thriftConnection = new ThriftConnection(); + $client = $thriftConnection->openConnection(); + $extendedCodetext = $client->HanXinExtCodetextBuilder_getExtendedCodetext($this->_list); + $thriftConnection->closeConnection(); + return $extendedCodetext; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } +} \ No newline at end of file diff --git a/lib/Generation/HanXinExtCodetextBuilderType.php b/lib/Generation/HanXinExtCodetextBuilderType.php new file mode 100644 index 00000000..bd46d46b --- /dev/null +++ b/lib/Generation/HanXinExtCodetextBuilderType.php @@ -0,0 +1,19 @@ + + * Han Xin parameters. + * + */ +class HanXinParameters implements Communicator +{ + private $hanXinParametersDto; + + private function getHanXinParametersDto(): HanXinParametersDTO + { + return $this->hanXinParametersDto; + } + + private function setHanXinParametersDto(HanXinParametersDTO $hanXinParametersDto): void + { + $this->hanXinParametersDto = $hanXinParametersDto; + } + + function __construct(HanXinParametersDTO $hanXinParametersDto) + { + $this->hanXinParametersDto = $hanXinParametersDto; + $this->obtainDto(); + $this->initFieldsFromDto(); + } + + public function obtainDto(...$args) + { + } + + public function initFieldsFromDto(): void + { + } + + /** + *+ * Version of HanXin Code. + * From Version01 to Version84 for Han Xin code. + * Default value is HanXinVersion.Auto. + *
+ */ + public function getHanXinVersion(): int + { + return $this->getHanXinParametersDto()->hanXinVersion; + } + + /** + *+ * Version of HanXin Code. + * From Version01 to Version84 for Han Xin code. + * Default value is HanXinVersion.Auto. + *
+ */ + public function setHanXinVersion(int $value): void + { + $this->getHanXinParametersDto()->hanXinVersion = $value; + } + + /** + *+ * Level of Reed-Solomon error correction for Han Xin barcode. + * From low to high: L1, L2, L3, L4. see HanXinErrorLevel. + *
+ */ + public function getHanXinErrorLevel(): int + { + return $this->getHanXinParametersDto()->hanXinErrorLevel; + } + + /** + *+ * Level of Reed-Solomon error correction for Han Xin barcode. + * From low to high: L1, L2, L3, L4. see HanXinErrorLevel. + *
+ */ + public function setHanXinErrorLevel(int $value): void + { + $this->getHanXinParametersDto()->hanXinErrorLevel = $value; + } + + /** + *+ * HanXin encoding mode. + * Default value: HanXinEncodeMode::Mixed. + *
+ */ + public function getHanXinEncodeMode(): int + { + return $this->getHanXinParametersDto()->hanXinEncodeMode; + } + + /** + *+ * HanXin encoding mode. + * Default value: HanXinEncodeMode::Mixed. + *
+ */ + public function setHanXinEncodeMode(int $value): void + { + $this->getHanXinParametersDto()->hanXinEncodeMode = $value; + } + + /** + *+ * Extended Channel Interpretation Identifiers. It is used to tell the barcode reader details + * about the used references for encoding the data in the symbol. + * Current implementation consists all well known charset encodings. + *
+ */ + public function getHanXinECIEncoding(): int + { + return $this->getHanXinParametersDto()->hanXinECIEncoding; + } + + /** + *+ * Extended Channel Interpretation Identifiers. It is used to tell the barcode reader details + * about the used references for encoding the data in the symbol. + * Current implementation consists all well known charset encodings. + *
+ */ + public function setHanXinECIEncoding(int $value): void + { + $this->getHanXinParametersDto()->hanXinECIEncoding = $value; + } + + + /** + *+ * Returns a human-readable string representation of this {@code HanXinParameters}. + *
+ * @return string that represents this {@code HanXinParameters}. + */ + public function toString(): string + { + $thriftConnection = new ThriftConnection(); + $client = $thriftConnection->openConnection(); + $str = $client->HanXinParameters_toString($this->getHanXinParametersDto()); + $thriftConnection->closeConnection(); + + return $str; + } +} \ No newline at end of file diff --git a/lib/Generation/HanXinVersion.php b/lib/Generation/HanXinVersion.php new file mode 100644 index 00000000..7e06db00 --- /dev/null +++ b/lib/Generation/HanXinVersion.php @@ -0,0 +1,524 @@ + + * Version of Han Xin Code. + * From Version01 - 23 x 23 modules to Version84 - 189 x 189 modules, increasing in steps of 2 modules per side. + * + */ +class HanXinVersion +{ + /** + *+ * Specifies to automatically pick up the best version. + * This is default value. + *
+ */ + const AUTO = 0; + /** + *+ * Specifies version 1 with 23 x 23 modules. + *
+ */ + const VERSION_01 = 1; + /** + *+ * Specifies version 2 with 25 x 25 modules. + *
+ */ + const VERSION_02 = 2; + /** + *+ * Specifies version 3 with 27 x 27 modules. + *
+ */ + const VERSION_03 = 3; + /** + *+ * Specifies version 4 with 29 x 29 modules. + *
+ */ + const VERSION_04 = 4; + /** + *+ * Specifies version 5 with 31 x 31 modules. + *
+ */ + const VERSION_05 = 5; + /** + *+ * Specifies version 6 with 33 x 33 modules. + *
+ */ + const VERSION_06 = 6; + /** + *+ * Specifies version 7 with 35 x 35 modules. + *
+ */ + const VERSION_07 = 7; + /** + *+ * Specifies version 8 with 37 x 37 modules. + *
+ */ + const VERSION_08 = 8; + /** + *+ * Specifies version 9 with 39 x 39 modules. + *
+ */ + const VERSION_09 = 9; + /** + *+ * Specifies version 10 with 41 x 41 modules. + *
+ */ + const VERSION_10 = 10; + /** + *+ * Specifies version 11 with 43 x 43 modules. + *
+ */ + const VERSION_11 = 11; + /** + *+ * Specifies version 12 with 45 x 45 modules. + *
+ */ + const VERSION_12 = 12; + /** + *+ * Specifies version 13 with 47 x 47 modules. + *
+ */ + const VERSION_13 = 13; + /** + *+ * Specifies version 14 with 49 x 49 modules. + *
+ */ + const VERSION_14 = 14; + /** + *+ * Specifies version 15 with 51 x 51 modules. + *
+ */ + const VERSION_15 = 15; + /** + *+ * Specifies version 16 with 53 x 53 modules. + *
+ */ + const VERSION_16 = 16; + /** + *+ * Specifies version 17 with 55 x 55 modules. + *
+ */ + const VERSION_17 = 17; + /** + *+ * Specifies version 18 with 57 x 57 modules. + *
+ */ + const VERSION_18 = 18; + /** + *+ * Specifies version 19 with 59 x 59 modules. + *
+ */ + const VERSION_19 = 19; + /** + *+ * Specifies version 20 with 61 x 61 modules. + *
+ */ + const VERSION_20 = 20; + /** + *+ * Specifies version 21 with 63 x 63 modules. + *
+ */ + const VERSION_21 = 21; + /** + *+ * Specifies version 22 with 65 x 65 modules. + *
+ */ + const VERSION_22 = 22; + /** + *+ * Specifies version 23 with 67 x 67 modules. + *
+ */ + const VERSION_23 = 23; + /** + *+ * Specifies version 24 with 69 x 69 modules. + *
+ */ + const VERSION_24 = 24; + /** + *+ * Specifies version 25 with 71 x 71 modules. + *
+ */ + const VERSION_25 = 25; + /** + *+ * Specifies version 26 with 73 x 73 modules. + *
+ */ + const VERSION_26 = 26; + /** + *+ * Specifies version 27 with 75 x 75 modules. + *
+ */ + const VERSION_27 = 27; + /** + *+ * Specifies version 28 with 77 x 77 modules. + *
+ */ + const VERSION_28 = 28; + /** + *+ * Specifies version 29 with 79 x 79 modules. + *
+ */ + const VERSION_29 = 29; + /** + *+ * Specifies version 30 with 81 x 81 modules. + *
+ */ + const VERSION_30 = 30; + /** + *+ * Specifies version 31 with 83 x 83 modules. + *
+ */ + const VERSION_31 = 31; + /** + *+ * Specifies version 32 with 85 x 85 modules. + *
+ */ + const VERSION_32 = 32; + /** + *+ * Specifies version 33 with 87 x 87 modules. + *
+ */ + const VERSION_33 = 33; + /** + *+ * Specifies version 34 with 89 x 89 modules. + *
+ */ + const VERSION_34 = 34; + /** + *+ * Specifies version 35 with 91 x 91 modules. + *
+ */ + const VERSION_35 = 35; + /** + *+ * Specifies version 36 with 93 x 93 modules. + *
+ */ + const VERSION_36 = 36; + /** + *+ * Specifies version 37 with 95 x 95 modules. + *
+ */ + const VERSION_37 = 37; + /** + *+ * Specifies version 38 with 97 x 97 modules. + *
+ */ + const VERSION_38 = 38; + /** + *+ * Specifies version 39 with 99 x 99 modules. + *
+ */ + const VERSION_39 = 39; + /** + *+ * Specifies version 40 with 101 x 101 modules. + *
+ */ + const VERSION_40 = 40; + /** + *+ * Specifies version 41 with 103 x 103 modules. + *
+ */ + const VERSION_41 = 41; + /** + *+ * Specifies version 42 with 105 x 105 modules. + *
+ */ + const VERSION_42 = 42; + /** + *+ * Specifies version 43 with 107 x 107 modules. + *
+ */ + const VERSION_43 = 43; + /** + *+ * Specifies version 44 with 109 x 109 modules. + *
+ */ + const VERSION_44 = 44; + /** + *+ * Specifies version 45 with 111 x 111 modules. + *
+ */ + const VERSION_45 = 45; + /** + *+ * Specifies version 46 with 113 x 113 modules. + *
+ */ + const VERSION_46 = 46; + /** + *+ * Specifies version 47 with 115 x 115 modules. + *
+ */ + const VERSION_47 = 47; + /** + *+ * Specifies version 48 with 117 x 117 modules. + *
+ */ + const VERSION_48 = 48; + /** + *+ * Specifies version 49 with 119 x 119 modules. + *
+ */ + const VERSION_49 = 49; + /** + *+ * Specifies version 50 with 121 x 121 modules. + *
+ */ + const VERSION_50 = 50; + /** + *+ * Specifies version 51 with 123 x 123 modules. + *
+ */ + const VERSION_51 = 51; + /** + *+ * Specifies version 52 with 125 x 125 modules. + *
+ */ + const VERSION_52 = 52; + /** + *+ * Specifies version 53 with 127 x 127 modules. + *
+ */ + const VERSION_53 = 53; + /** + *+ * Specifies version 54 with 129 x 129 modules. + *
+ */ + const VERSION_54 = 54; + /** + *+ * Specifies version 55 with 131 x 131 modules. + *
+ */ + const VERSION_55 = 55; + /** + *+ * Specifies version 56 with 133 x 133 modules. + *
+ */ + const VERSION_56 = 56; + /** + *+ * Specifies version 57 with 135 x 135 modules. + *
+ */ + const VERSION_57 = 57; + /** + *+ * Specifies version 58 with 137 x 137 modules. + *
+ */ + const VERSION_58 = 58; + /** + *+ * Specifies version 59 with 139 x 139 modules. + *
+ */ + const VERSION_59 = 59; + /** + *+ * Specifies version 60 with 141 x 141 modules. + *
+ */ + const VERSION_60 = 60; + /** + *+ * Specifies version 61 with 143 x 143 modules. + *
+ */ + const VERSION_61 = 61; + /** + *+ * Specifies version 62 with 145 x 145 modules. + *
+ */ + const VERSION_62 = 62; + /** + *+ * Specifies version 63 with 147 x 147 modules. + *
+ */ + const VERSION_63 = 63; + /** + *+ * Specifies version 64 with 149 x 149 modules. + *
+ */ + const VERSION_64 = 64; + /** + *+ * Specifies version 65 with 151 x 151 modules. + *
+ */ + const VERSION_65 = 65; + /** + *+ * Specifies version 66 with 153 x 153 modules. + *
+ */ + const VERSION_66 = 66; + /** + *+ * Specifies version 67 with 155 x 155 modules. + *
+ */ + const VERSION_67 = 67; + /** + *+ * Specifies version 68 with 157 x 157 modules. + *
+ */ + const VERSION_68 = 68; + /** + *+ * Specifies version 69 with 159 x 159 modules. + *
+ */ + const VERSION_69 = 69; + /** + *+ * Specifies version 70 with 161 x 161 modules. + *
+ */ + const VERSION_70 = 70; + /** + *+ * Specifies version 71 with 163 x 163 modules. + *
+ */ + const VERSION_71 = 71; + /** + *+ * Specifies version 72 with 165 x 165 modules. + *
+ */ + const VERSION_72 = 72; + /** + *+ * Specifies version 73 with 167 x 167 modules. + *
+ */ + const VERSION_73 = 73; + /** + *+ * Specifies version 74 with 169 x 169 modules. + *
+ */ + const VERSION_74 = 74; + /** + *+ * Specifies version 75 with 171 x 171 modules. + *
+ */ + const VERSION_75 = 75; + /** + *+ * Specifies version 76 with 173 x 173 modules. + *
+ */ + const VERSION_76 = 76; + /** + *+ * Specifies version 77 with 175 x 175 modules. + *
+ */ + const VERSION_77 = 77; + /** + *+ * Specifies version 78 with 177 x 177 modules. + *
+ */ + const VERSION_78 = 78; + /** + *+ * Specifies version 79 with 179 x 179 modules. + *
+ */ + const VERSION_79 = 79; + /** + *+ * Specifies version 80 with 181 x 181 modules. + *
+ */ + const VERSION_80 = 80; + /** + *+ * Specifies version 81 with 183 x 183 modules. + *
+ */ + const VERSION_81 = 81; + /** + *+ * Specifies version 82 with 185 x 185 modules. + *
+ */ + const VERSION_82 = 82; + /** + *+ * Specifies version 83 with 187 x 187 modules. + *
+ */ + const VERSION_83 = 83; + /** + *+ * Specifies version 84 with 189 x 189 modules. + *
+ */ + const VERSION_84 = 84; +} \ No newline at end of file diff --git a/lib/Generation/HslaColor.php b/lib/Generation/HslaColor.php new file mode 100644 index 00000000..04c679ae --- /dev/null +++ b/lib/Generation/HslaColor.php @@ -0,0 +1,143 @@ + + * Class for representing HSLA color (Hue, Saturation, Lightness, Alpha) + * + */ +class HslaColor +{ + /** + *+ * Hue [0, 360] + *
+ */ + public $H; + + /** + *+ * Saturation [0, 100] + *
+ */ + public $S; + + /** + *+ * Lightness [0, 100] + *
+ */ + public $L; + + /** + *+ * Alpha (opacity) [0.0f, 1.0f] + *
+ */ + public $A = 0.0; + + + /** + *+ * Constructor for HslaColor + *
+ * + * @param $h Hue [0, 360] + * @param $s Saturation [0, 100] + * @param $l Lightness [0, 100] + * @param $a Alpha (opacity) [0.0f, 1.0f] + */ + public function __construct(int $h, int $s, int $l, float $a) + { +// $this->checkHue($h); + self::checkHue($h); + self::checkSatLight($s); + self::checkSatLight($l); + self::checkAlpha($a); + + $this->H = $h; + $this->S = $s; + $this->L = $l; + $this->A = $a; + } + + private static function checkHue(int $value) + { + if ($value < 0 || $value > 360) + { + throw new Exception("Wrong color value"); + } + } + + private static function checkSatLight(int $value) + { + if ($value < 0 || $value > 100) + { + throw new Exception("Wrong color value"); + } + } + + private static function checkAlpha(float $value) + { + if ($value < 0.0 || $value > 1.0) + { + throw new Exception("Wrong color value"); + } + } + + /** + *+ * Uses https://en.wikipedia.org/wiki/HSL_and_HSV#HSL_to_RGB + *
+ * + * @param hslaColor HSLA color to convert + * @return string with RGBA values + */ + public static function convertHslaToRgba(HslaColor $hslaColor): string + { + $r = 0; + $g = 0; + $b = 0; + + $hueF = $hslaColor->H / 360.0; + $satF = $hslaColor->S / 100.0; + $lightF = $hslaColor->L / 100.0; + + if ($satF == 0) + { + $r = $g = $b = $lightF; + } else + { + $q = $lightF < 0.5 ? $lightF * (1 + $satF) : $lightF + $satF - $lightF * $satF; + $p = 2 * $lightF - $q; + + $r = HslaColor::hueToRgb($p, $q, $hueF + 1.0 / 3.0); + $g = HslaColor::hueToRgb($p, $q, $hueF); + $b = HslaColor::hueToRgb($p, $q, $hueF - 1.0 / 3.0); + } + + $rI = intval($r * 255 + 0.5); + $gI = intval($g * 255 + 0.5); + $bI = intval($b * 255 + 0.5); + $aI = intval($hslaColor->A * 255 + 0.5); + + return sprintf("#%02X%02X%02X%02X", $rI, $gI, $bI, $aI); + } + + private static function hueToRgb(float $p, float $q, float $t): float + { + if ($t < 0.0) $t += 1.0; + if ($t > 1.0) $t -= 1.0; + if ($t < 1.0 / 6.0) return $p + ($q - $p) * 6.0 * $t; + if ($t < 1.0 / 2.0) return $q; + if ($t < 2.0 / 3.0) return $p + ($q - $p) * (2.0 / 3.0 - $t) * 6.0; + return $p; + } +} \ No newline at end of file diff --git a/lib/Generation/ITF14BorderType.php b/lib/Generation/ITF14BorderType.php new file mode 100644 index 00000000..a4a71ca9 --- /dev/null +++ b/lib/Generation/ITF14BorderType.php @@ -0,0 +1,30 @@ +itfParametersDto; + } + + private function setITFParametersDto(ITFParametersDTO $itfParametersDto): void + { + $this->itfParametersDto = $itfParametersDto; + } + + private $itfBorderThickness; + + function __construct(ITFParametersDTO $itfParametersDto) + { + $this->itfParametersDto = $itfParametersDto; + $this->obtainDto(); + $this->initFieldsFromDto(); + } + + public function obtainDto(...$args) + { + } + + public function initFieldsFromDto(): void + { + try + { + $this->itfBorderThickness = new Unit($this->getITFParametersDto()->itfBorderThickness); + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Gets an ITF border (bearer bar) thickness in Unit value. + * Default value: 12pt. + */ + public function getItfBorderThickness(): Unit + { + return $this->itfBorderThickness; + } + + /** + * Sets an ITF border (bearer bar) thickness in Unit value. + * Default value: 12pt. + */ + public function setItfBorderThickness(Unit $value): void + { + try + { + $this->getITFParametersDto()->itfBorderThickness = $value->getUnitDto(); + $this->itfBorderThickness = $value; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Border type of ITF barcode. + * Default value: ITF14BorderType::BAR. + */ + public function getItfBorderType(): int + { + try + { + return $this->getITFParametersDto()->itfBorderType; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Border type of ITF barcode. + * Default value: ITF14BorderType::BAR. + */ + public function setItfBorderType(int $value): void + { + try + { + $this->getITFParametersDto()->itfBorderType = $value; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Size of the quiet zones in xDimension. + * Default value: 10, meaning if xDimension = 2px than quiet zones will be 20px. + * + * @exception IllegalArgumentException + * @return int The QuietZoneCoef parameter value is less than 10. + */ + public function getQuietZoneCoef(): int + { + try + { + return $this->getITFParametersDto()->quietZoneCoef; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Size of the quiet zones in xDimension. + * Default value: 10, meaning if xDimension = 2px than quiet zones will be 20px. + * + * @exception IllegalArgumentException + * @param int The QuietZoneCoef parameter value is less than 10. + */ + public function setQuietZoneCoef(int $value): void + { + try + { + $this->getITFParametersDto()->quietZoneCoef = $value; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Returns a human-readable string representation of this ITFParameters. + * + * @return string that represents this ITFParameters. + */ + public function toString(): string + { + $thriftConnection = new ThriftConnection(); + $client = $thriftConnection->openConnection(); + $str = $client->ITFParameters_toString($this->getITFParametersDto()); + $thriftConnection->closeConnection(); + + return $str; + } +} \ No newline at end of file diff --git a/lib/Generation/ImageParameters.php b/lib/Generation/ImageParameters.php new file mode 100644 index 00000000..de432d64 --- /dev/null +++ b/lib/Generation/ImageParameters.php @@ -0,0 +1,84 @@ +imageParametersDto; + } + + private function setImageParametersDto(ImageParametersDTO $imageParametersDto): void + { + $this->imageParametersDto = $imageParametersDto; + } + + private $svg; + private $pdf; + + function __construct(ImageParametersDTO $imageParametersDto) + { + $this->imageParametersDto = $imageParametersDto; + $this->obtainDto(); + $this->initFieldsFromDto(); + } + + public function obtainDto(...$args) + { + } + + public function initFieldsFromDto(): void + { + $this->svg = new SvgParameters($this->getImageParametersDto()->svg); + $this->pdf = new PdfParameters($this->getImageParametersDto()->pdf); + } + + /** + * SVG parameters + */ + function getSvg(): SvgParameters + { + return $this->svg; + } + + /** + * SVG parameters + */ + function setSvg(SvgParameters $svg): void + { + $this->svg = $svg; + $this->getImageParametersDto()->svg = $svg->getSvgParametersDto(); + } + + /** + *+ * PDF parameters + *
+ */ + function getPdf() + { + return $this->pdf; + } + + /** + *+ * PDF parameters + *
+ */ + function setPdf(PdfParameters $value) + { + $this->pdf = $value; + $this->getImageParametersDto()->pdf = $value->getPdfParametersDto(); + } +} \ No newline at end of file diff --git a/lib/Generation/MacroCharacter.php b/lib/Generation/MacroCharacter.php new file mode 100644 index 00000000..059f0eeb --- /dev/null +++ b/lib/Generation/MacroCharacter.php @@ -0,0 +1,69 @@ +\u001E05\u001D" as decoded data header and "\u001E\u0004" as decoded data trailer. + * 06 Macro craracter is translated to "[)>\u001E06\u001D" as decoded data header and "\u001E\u0004" as decoded data trailer. + *+ * These samples show how to encode Macro Characters in MicroPdf417 and DataMatrix + *+ */ +final class MacroCharacter +{ + /** + * None of Macro Characters are added to barcode data + */ + const NONE = 0; + + /** + * 05 Macro craracter is added to barcode data in first position. + * GS1 Data Identifier ISO 15434 + * Character is translated to "[)>\u001E05\u001D" as decoded data header and "\u001E\u0004" as decoded data trailer. + * + * @code + * //to generate autoidentified GS1 message like this "(10)123ABC(10)123ABC" in ISO 15434 format you need: + * $generator = new BarcodeGenerator(EncodeTypes::DATA_MATRIX, "10123ABC\u001D10123ABC"); + * $generator->getParameters()->getBarcode()->getDataMatrix()->setMacroCharacters(MacroCharacter::MACRO_05); + * $reader = new BarCodeReader($generator->generateBarCodeImage(BarcodeImageFormat::PNG), null, DecodeType::GS_1_DATA_MATRIX); + * foreach($reader->readBarCodes() as $result) + * print("BarCode CodeText: ".$result->getCodeText()); + * @endcode + */ + const MACRO_05 = 5; + + /** + * 06 Macro craracter is added to barcode data in first position. + * ASC MH10 Data Identifier ISO 15434 + * Character is translated to "[)>\u001E06\u001D" as decoded data header and "\u001E\u0004" as decoded data trailer. + */ + const MACRO_06 = 6; +} \ No newline at end of file diff --git a/lib/Generation/MaxiCodeEncodeMode.php b/lib/Generation/MaxiCodeEncodeMode.php new file mode 100644 index 00000000..3467f7ae --- /dev/null +++ b/lib/Generation/MaxiCodeEncodeMode.php @@ -0,0 +1,83 @@ +getParameters()->getBarcode()->getMaxiCode()->setECIEncoding(ECIEncodings::UTF8); + * $generator->save("test.bmp"); + * + * //Bytes mode + * $encodedArr = array( 0xFF, 0xFE, 0xFD, 0xFC, 0xFB, 0xFA, 0xF9 ); + * //encode array to string + * $strBld = ""; + * foreach($encodedArr as $bval) + * { + * $strBld .= $bval; + * } + * $codetext = $strBld; + * $generator = new BarcodeGenerator(EncodeTypes::MAXI_CODE, $codetext); + * $generator->getParameters()->getBarcode()->getMaxiCode()->setMaxiCodeEncodeMode(MaxiCodeEncodeMode.BYTES); + * $generator->save(ApiTests::folder."test2.bmp", BarCodeImageFormat::BMP); + * @endcode + */ +class MaxiCodeEncodeMode +{ + /** + *+ * + * @code + * # to generate autoidentified GS1 message like this "(10)123ABC(10)123ABC" in ISO 15434 format you need: + * $generator = new BarcodeGenerator(EncodeTypes::DATA_MATRIX, "10123ABC\u001D10123ABC"); + * $generator->getParameters()->getBarcode()->getDataMatrix()->setMacroCharacters(MacroCharacter::MACRO_05); + * $reader = new BarCodeReader($generator->generateBarCodeImage(BarcodeImageFormat::PNG), null, DecodeType::GS1DataMatrix); + * foreach($reader->readBarCodes() as $result) + * echo "BarCode CodeText: " . $result->getCodeText(); + * @endcode + * @code + * # Encodes MicroPdf417 with 05 Macro the string: "[)>\u001E05\u001Dabcde1234\u001E\u0004" + * $generator = new BarcodeGenerator(EncodeTypes::MicroPdf417, "abcde1234"); + * $generator->getParameters()->getBarcode()->getPdf417()->setMacroCharacters(MacroCharacter::MACRO_05); + * $reader = new BarCodeReader($generator->generateBarCodeImage(BarcodeImageFormat::PNG), null, DecodeType::MICRO_PDF_417); + * foreach($reader->readBarCodes() as $result) + * echo $result->getCodeText(); + * @endcode + * @code + * # Encodes MicroPdf417 with 06 Macro the string: "[)>\u001E06\u001Dabcde1234\u001E\u0004" + * $generator = new BarcodeGenerator(EncodeTypes::MicroPdf417, "abcde1234"); + * $generator->getParameters()->getBarcode()->getPdf417()->setMacroCharacters(MacroCharacter::MACRO_06); + * $reader = new BarCodeReader($generator->generateBarCodeImage(BarcodeImageFormat::PNG), null, DecodeType::MICRO_PDF_417); + * foreach($reader->readBarCodes() as $result) + * echo $result->getCodeText(); + * @endcode + *+ *+ * In Auto mode, the CodeText is encoded with maximum data compactness. + * Unicode characters are re-encoded in the ECIEncoding specified encoding with the insertion of an ECI identifier. + * If a character is found that is not supported by the selected ECI encoding, an exception is thrown. + *
+ */ + const AUTO = 0; + + /** + * Encode codetext as plain bytes. If it detects any Unicode character, the character will be encoded as two bytes, lower byte first. + * @deprecated + */ + const BYTES = 1; + + /** + *+ *
Extended mode which supports multi ECI modes.
+ *It is better to use MaxiCodeExtCodetextBuilder for extended codetext generation.
+ *Use Display2DText property to set visible text to removing managing characters.
+ *ECI identifiers are set as single slash and six digits identifier "\000026" - UTF8 ECI identifier
+ *All unicode characters after ECI identifier are automatically encoded into correct character codeset.
+ * + * @deprecated + */ + const EXTENDED_CODETEXT = 2; + + /** + * Extended mode which supports multi ECI modes. + * It is better to use MaxiCodeExtCodetextBuilder for extended codetext generation. + * Use Display2DText property to set visible text to removing managing characters. + * ECI identifiers are set as single slash and six digits identifier "\000026" - UTF8 ECI identifier + * All unicode characters after ECI identifier are automatically encoded into correct character codeset. + */ + const EXTENDED = 3; + + /** + *+ * In Binary mode, the CodeText is encoded with maximum data compactness. + * If a Unicode character is found, an exception is thrown. + *
+ */ + const BINARY = 4; + + /** + *+ * In ECI mode, the entire message is re-encoded in the ECIEncoding specified encoding with the insertion of an ECI identifier. + * If a character is found that is not supported by the selected ECI encoding, an exception is thrown. + * Please note that some old (pre 2006) scanners may not support this mode. + *
+ */ + const ECI = 5; +} \ No newline at end of file diff --git a/lib/Generation/MaxiCodeExtCodetextBuilder.php b/lib/Generation/MaxiCodeExtCodetextBuilder.php new file mode 100644 index 00000000..2c9ae7bd --- /dev/null +++ b/lib/Generation/MaxiCodeExtCodetextBuilder.php @@ -0,0 +1,55 @@ +addECICodetext(ECIEncodings::Win1251, "Will"); + * $textBuilder->addECICodetext(ECIEncodings::UTF8, "犬Right狗"); + * $textBuilder->addECICodetext(ECIEncodings::UTF16BE, "犬Power狗"); + * $textBuilder->addPlainCodetext("Plain text"); + * + * //generate codetext + * $codetext = $textBuilder->getExtendedCodetext(); + * + * //generate + * $generator = new BarcodeGenerator(EncodeTypes::MAXI_CODE, $codetext); + * $generator->getParameters()->getBarcode()->getCodeTextParameters()->setTwoDDisplayText("My Text"); + * $generator->save("test.bmp", BarcodeImageFormat.BMP); + * @endcode + */ +class MaxiCodeExtCodetextBuilder extends ExtCodetextBuilder +{ + function __construct() + { + try + { + parent::__construct(); + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + function init(): void + { + } + + protected function getExtCodetextBuilderType(): int + { + return ExtCodetextBuilderType::MAXICODE_EXT_CODETEXT_BUILDER; + } +} \ No newline at end of file diff --git a/lib/Generation/MaxiCodeMode.php b/lib/Generation/MaxiCodeMode.php new file mode 100644 index 00000000..fd80a629 --- /dev/null +++ b/lib/Generation/MaxiCodeMode.php @@ -0,0 +1,111 @@ +setPostalCode("524032140"); + * $maxiCodeCodetext->setCountryCode(056); + * $maxiCodeCodetext->setServiceCategory(999); + * maxiCodeStandartSecondMessage = new MaxiCodeStandartSecondMessage(); + * $maxiCodeStandartSecondMessage->setMessage("Test message"); + * $maxiCodeCodetext->setSecondMessage($maxiCodeStandartSecondMessage); + * $complexGenerator = new ComplexBarcodeGenerator($maxiCodeCodetext); + * $complexGenerator->generateBarCodeImage(BarcodeImageFormat::PNG); + * + * //Mode 2 with structured second message + * $maxiCodeCodetext = new MaxiCodeCodetextMode2(); + * $maxiCodeCodetext->setPostalCode("524032140"); + * $maxiCodeCodetext->setCountryCode(056); + * $maxiCodeCodetext->setServiceCategory(999); + * maxiCodeStructuredSecondMessage = new MaxiCodeStructuredSecondMessage(); + * $maxiCodeStructuredSecondMessage->add("634 ALPHA DRIVE"); + * $maxiCodeStructuredSecondMessage->add("PITTSBURGH"); + * $maxiCodeStructuredSecondMessage->add("PA"); + * $maxiCodeStructuredSecondMessage->setYear(99); + * $maxiCodeCodetext->setSecondMessage($maxiCodeStructuredSecondMessage); + * $complexGenerator = new ComplexBarcodeGenerator($maxiCodeCodetext); + * $complexGenerator->generateBarCodeImage(BarcodeImageFormat::PNG); + * + * //Mode 3 with standart second message + * $maxiCodeCodetext = new MaxiCodeCodetextMode3(); + * $maxiCodeCodetext->setPostalCode("B1050"); + * $maxiCodeCodetext->setCountryCode(056); + * $maxiCodeCodetext->setServiceCategory(999); + * $maxiCodeStandartSecondMessage = new MaxiCodeStandartSecondMessage(); + * $maxiCodeStandartSecondMessage->setMessage("Test message"); + * $maxiCodeCodetext->setSecondMessage($maxiCodeStandartSecondMessage); + * $complexGenerator = new ComplexBarcodeGenerator($maxiCodeCodetext); + * $complexGenerator->generateBarCodeImage(BarcodeImageFormat::PNG); + * + * //Mode 3 with structured second message + * $maxiCodeCodetext = new MaxiCodeCodetextMode3(); + * $maxiCodeCodetext->setPostalCode("B1050"); + * $maxiCodeCodetext->setCountryCode(056); + * $maxiCodeCodetext->setServiceCategory(999); + * $maxiCodeStructuredSecondMessage = new MaxiCodeStructuredSecondMessage(); + * $maxiCodeStructuredSecondMessage->add("634 ALPHA DRIVE"); + * $maxiCodeStructuredSecondMessage->add("PITTSBURGH"); + * $maxiCodeStructuredSecondMessage->add("PA"); + * $maxiCodeStructuredSecondMessage->setYear(99); + * $maxiCodeCodetext->setSecondMessage($maxiCodeStructuredSecondMessage); + * $complexGenerator = new ComplexBarcodeGenerator($maxiCodeCodetext->getConstructedCodetext(); + * $complexGenerator->generateBarCodeImage(BarcodeImageFormat::PNG); + * + * //Mode 4 + * $maxiCodeCodetext = new MaxiCodeStandardCodetext(); + * $maxiCodeCodetext->setMode(MaxiCodeMode::MODE_4); + * $maxiCodeCodetext->setMessage("Test message"); + * $complexGenerator = new ComplexBarcodeGenerator($maxiCodeCodetext->getConstructedCodetext(); + * $complexGenerator->generateBarCodeImage(BarcodeImageFormat::PNG); + * + * //Mode 5 + * $maxiCodeCodetext = new MaxiCodeStandardCodetext(); + * $maxiCodeCodetext->setMode(MaxiCodeMode::MODE_5); + * $maxiCodeCodetext->setMessage("Test message"); + * $complexGenerator = new ComplexBarcodeGenerator($maxiCodeCodetext->getConstructedCodetext()) + * $complexGenerator->generateBarCodeImage(BarcodeImageFormat::PNG); + * + * //Mode 6 + * $maxiCodeCodetext = new MaxiCodeStandardCodetext(); + * $maxiCodeCodetext->setMode(MaxiCodeMode::MODE_6); + * $maxiCodeCodetext->setMessage("Test message"); + * $complexGenerator = new ComplexBarcodeGenerator($maxiCodeCodetext->getConstructedCodetext(); + * $complexGenerator->generateBarCodeImage(BarcodeImageFormat::PNG); + * @endcode + */ +class MaxiCodeMode +{ + /** + * Mode 2 encodes postal information in first message and data in second message. + * Has 9 digits postal code (used only in USA). + */ + const MODE_2 = 2; + + /** + * Mode 3 encodes postal information in first message and data in second message. + * Has 6 alphanumeric postal code, used in the world. + */ + const MODE_3 = 3; + + /** + * Mode 4 encodes data in first and second message, with short ECC correction. + */ + const MODE_4 = 4; + + /** + * Mode 5 encodes data in first and second message, with long ECC correction. + */ + const MODE_5 = 5; + + /** + * Mode 6 encodes data in first and second message, with short ECC correction. + * Used to encode device. + */ + const MODE_6 = 6; +} \ No newline at end of file diff --git a/lib/Generation/MaxiCodeParameters.php b/lib/Generation/MaxiCodeParameters.php new file mode 100644 index 00000000..f23a0759 --- /dev/null +++ b/lib/Generation/MaxiCodeParameters.php @@ -0,0 +1,191 @@ +maxiCodeParametersDto; + } + + private function setMaxiCodeParametersDto(MaxiCodeParametersDTO $maxiCodeParametersDto): void + { + $this->maxiCodeParametersDto = $maxiCodeParametersDto; + } + + function __construct(MaxiCodeParametersDTO $maxiCodeParametersDto) + { + $this->maxiCodeParametersDto = $maxiCodeParametersDto; + $this->obtainDto(); + $this->initFieldsFromDto(); + } + + public function obtainDto(...$args) + { + } + + public function initFieldsFromDto(): void + { + } + + /** + * Gets a MaxiCode encode mode. + */ + public function getMaxiCodeMode(): int + { + return $this->getMaxiCodeParametersDto()->maxiCodeMode; + } + + /** + * Sets a MaxiCode encode mode. + */ + public function setMaxiCodeMode(int $maxiCodeMode): void + { + $this->getMaxiCodeParametersDto()->maxiCodeMode = $maxiCodeMode; + } + + /** + * Gets a MaxiCode encode mode. + */ + public function getMaxiCodeEncodeMode(): int + { + try + { + return $this->getMaxiCodeParametersDto()->maxiCodeEncodeMode; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Sets a MaxiCode encode mode. + */ + public function setMaxiCodeEncodeMode(int $value): void + { + try + { + $this->getMaxiCodeParametersDto()->maxiCodeEncodeMode = $value; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Gets ECI encoding. Used when MaxiCodeEncodeMode is AUTO. + * Default value: ISO-8859-1 + */ + public function getECIEncoding(): int + { + return $this->getMaxiCodeParametersDto()->eCIEncoding; + } + + /** + * Sets ECI encoding. Used when MaxiCodeEncodeMode is AUTO. + * Default value: ISO-8859-1 + */ + public function setECIEncoding(int $ECIEncoding): void + { + $this->getMaxiCodeParametersDto()->eCIEncoding = $ECIEncoding; + } + + /** + * Gets a MaxiCode barcode id in structured append mode. + * ID must be a value between 1 and 8. + * Default value: 0 + */ + public function getMaxiCodeStructuredAppendModeBarcodeId(): int + { + return $this->getMaxiCodeParametersDto()->maxiCodeStructuredAppendModeBarcodeId; + } + + /** + * Sets a MaxiCode barcode id in structured append mode. + * ID must be a value between 1 and 8. + * Default value: 0 + */ + public function setMaxiCodeStructuredAppendModeBarcodeId(int $maxiCodeStructuredAppendModeBarcodeId): void + { + $this->getMaxiCodeParametersDto()->maxiCodeStructuredAppendModeBarcodeId = $maxiCodeStructuredAppendModeBarcodeId; + } + + /** + * Gets a MaxiCode barcodes count in structured append mode. + * Count number must be a value between 2 and 8 (maximum barcodes count). + * Default value: -1 + */ + public function getMaxiCodeStructuredAppendModeBarcodesCount(): int + { + return $this->getMaxiCodeParametersDto()->maxiCodeStructuredAppendModeBarcodesCount; + } + + /** + * Sets a MaxiCode barcodes count in structured append mode. + * Count number must be a value between 2 and 8 (maximum barcodes count). + * Default value: -1 + */ + public function setMaxiCodeStructuredAppendModeBarcodesCount(int $maxiCodeStructuredAppendModeBarcodesCount): void + { + $this->getMaxiCodeParametersDto()->maxiCodeStructuredAppendModeBarcodesCount = $maxiCodeStructuredAppendModeBarcodesCount; + } + + /** + * Height/Width ratio of 2D BarCode module. + */ + public function getAspectRatio(): float + { + try + { + return $this->getMaxiCodeParametersDto()->aspectRatio; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Height/Width ratio of 2D BarCode module. + */ + public function setAspectRatio(float $value): void + { + try + { + $this->getMaxiCodeParametersDto()->aspectRatio = $value; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Returns a human-readable string representation of this MaxiCodeParameters. + * + * @return string that represents this MaxiCodeParameters. + */ + public function toString(): string + { + $thriftConnection = new ThriftConnection(); + $client = $thriftConnection->openConnection(); + $str = $client->MaxiCodeParameters_toString($this->getMaxiCodeParametersDto()); + $thriftConnection->closeConnection(); + + return $str; + } +} \ No newline at end of file diff --git a/lib/Generation/MicroQRVersion.php b/lib/Generation/MicroQRVersion.php new file mode 100644 index 00000000..15ba93e4 --- /dev/null +++ b/lib/Generation/MicroQRVersion.php @@ -0,0 +1,48 @@ + + * Version of MicroQR Code. + * From M1 to M4. + * + */ +class MicroQRVersion +{ + /** + *+ * Specifies to automatically pick up the best version for MicroQR. + * This is default value. + *
+ */ + const AUTO = 0; + + /** + *+ * Specifies version M1 for Micro QR with 11 x 11 modules. + *
+ */ + const M1 = 1; + + /** + *+ * Specifies version M2 for Micro QR with 13 x 13 modules. + *
+ */ + const M2 = 2; + + /** + *+ * Specifies version M3 for Micro QR with 15 x 15 modules. + *
+ */ + const M3 = 3; + + /** + *+ * Specifies version M4 for Micro QR with 17 x 17 modules. + *
+ */ + const M4 = 4; +} \ No newline at end of file diff --git a/lib/Generation/Padding.php b/lib/Generation/Padding.php new file mode 100644 index 00000000..61e832dc --- /dev/null +++ b/lib/Generation/Padding.php @@ -0,0 +1,163 @@ +paddingDto; + } + + private function setPaddingDto(PaddingDTO $paddingDto): void + { + $this->paddingDto = $paddingDto; + } + + private $top; + private $bottom; + private $right; + private $left; + + function __construct(PaddingDTO $paddingDto) + { + $this->paddingDto = $paddingDto; + $this->obtainDto(); + $this->initFieldsFromDto(); + } + + public function obtainDto(...$args) + { + } + + public function initFieldsFromDto(): void + { + $this->top = new Unit($this->getPaddingDto()->top); + $this->bottom = new Unit($this->getPaddingDto()->bottom); + $this->right = new Unit($this->getPaddingDto()->right); + $this->left = new Unit($this->getPaddingDto()->left); + } + + /** + * Top padding. + */ + public function getTop(): Unit + { + return $this->top; + } + + /** + * Top padding. + */ + public function setTop(Unit $value): void + { + try + { + $this->getPaddingDto()->top = $value->getUnitDto(); + $this->top = $value; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Bottom padding. + */ + public function getBottom(): Unit + { + return $this->bottom; + } + + /** + * Bottom padding. + */ + public function setBottom(Unit $value): void + { + try + { + $this->getPaddingDto()->bottom = $value->getUnitDto(); + $this->bottom = $value; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Right padding. + */ + public function getRight(): Unit + { + return $this->right; + } + + /** + * Right padding. + */ + public function setRight(Unit $value): void + { + try + { + $this->getPaddingDto()->right = $value->getUnitDto(); + $this->right = $value; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Left padding. + */ + public function getLeft(): Unit + { + return $this->left; + } + + /** + * Left padding. + */ + public function setLeft(Unit $value): void + { + try + { + $this->getPaddingDto()->left = $value->getUnitDto(); + $this->left = $value; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Returns a human-readable string representation of this Padding. + * + * @return string A string that represents this Padding. + */ + public function toString(): string + { + $thriftConnection = new ThriftConnection(); + $client = $thriftConnection->openConnection(); + $str = $client->Padding_toString($this->getPaddingDto()); + $thriftConnection->closeConnection(); + + return $str; + } +} \ No newline at end of file diff --git a/lib/Generation/PatchCodeParameters.php b/lib/Generation/PatchCodeParameters.php new file mode 100644 index 00000000..a870adc5 --- /dev/null +++ b/lib/Generation/PatchCodeParameters.php @@ -0,0 +1,125 @@ +patchCodeParametersDto; + } + + private function setPatchCodeParametersDto(PatchCodeParametersDTO $patchCodeParametersDto): void + { + $this->patchCodeParametersDto = $patchCodeParametersDto; + } + + function __construct(PatchCodeParametersDTO $patchCodeParametersDto) + { + $this->patchCodeParametersDto = $patchCodeParametersDto; + $this->obtainDto(); + $this->initFieldsFromDto(); + } + + public function obtainDto(...$args) + { + } + + public function initFieldsFromDto(): void + { + } + + /** + * Specifies codetext for an extra QR barcode, when PatchCode is generated in page mode. + */ + public function getExtraBarcodeText(): ?string + { + try + { + $ExtraBarcodeText = $this->getPatchCodeParametersDto()->extraBarcodeText; + if ($ExtraBarcodeText == "null") + { + return null; + } + return $ExtraBarcodeText; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Specifies codetext for an extra QR barcode, when PatchCode is generated in page mode. + */ + public function setExtraBarcodeText(string $value): void + { + try + { + $this->getPatchCodeParametersDto()->extraBarcodeText = $value; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * PatchCode format. Choose PatchOnly to generate single PatchCode. Use page format to generate Patch page with PatchCodes as borders. + * Default value: PatchFormat::PATCH_ONLY + * + * @return + */ + public function getPatchFormat(): int + { + try + { + return $this->getPatchCodeParametersDto()->patchFormat; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * PatchCode format. Choose PatchOnly to generate single PatchCode. Use page format to generate Patch page with PatchCodes as borders. + * Default value: PatchFormat::PATCH_ONLY + */ + public function setPatchFormat(int $value): void + { + try + { + $this->getPatchCodeParametersDto()->patchFormat = $value; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Returns a human-readable string representation of this PatchCodeParameters. + * @return string A string that represents this PatchCodeParameters. + */ + public function toString(): string + { + $thriftConnection = new ThriftConnection(); + $client = $thriftConnection->openConnection(); + $str = $client->PatchCodeParameters_toString($this->getPatchCodeParametersDto()); + $thriftConnection->closeConnection(); + + return $str; + } +} \ No newline at end of file diff --git a/lib/Generation/PatchFormat.php b/lib/Generation/PatchFormat.php new file mode 100644 index 00000000..f8e61306 --- /dev/null +++ b/lib/Generation/PatchFormat.php @@ -0,0 +1,34 @@ + + * Pdf417 barcode encode mode + * + */ +class Pdf417EncodeMode +{ + /** + *+ * In Auto mode, the CodeText is encoded with maximum data compactness. + * Unicode characters are re-encoded in the ECIEncoding specified encoding with the insertion of an ECI identifier. + * If a character is found that is not supported by the selected ECI encoding, an exception is thrown. + *
+ */ + const AUTO = 0; + + /** + *+ * In Binary mode, the CodeText is encoded with maximum data compactness. + * If a Unicode character is found, an exception is thrown. + *
+ */ + const BINARY = 1; + + /** + *+ * In ECI mode, the entire message is re-encoded in the ECIEncoding specified encoding with the insertion of an ECI identifier. + * If a character is found that is not supported by the selected ECI encoding, an exception is thrown. + * Please note that some old (pre 2006) scanners may not support this mode. + *
+ */ + const ECI = 2; + + /** + *+ *
Extended mode which supports multi ECI modes.
+ *It is better to use Pdf417ExtCodetextBuilder for extended codetext generation.
+ *Use Display2DText property to set visible text to removing managing characters.
+ *ECI identifiers are set as single slash and six digits identifier "\000026" - UTF8 ECI identifier
+ *All unicode characters after ECI identifier are automatically encoded into correct character codeset.
+ * + */ + const EXTENDED = 3; +} \ No newline at end of file diff --git a/lib/Generation/Pdf417ErrorLevel.php b/lib/Generation/Pdf417ErrorLevel.php new file mode 100644 index 00000000..b3b23585 --- /dev/null +++ b/lib/Generation/Pdf417ErrorLevel.php @@ -0,0 +1,47 @@ + + * PDF417 parameters. Contains PDF417, MacroPDF417, MicroPDF417 and GS1MicroPdf417 parameters. + * MacroPDF417 requires two fields: Pdf417MacroFileID and Pdf417MacroSegmentID. All other fields are optional. + * MicroPDF417 in Structured Append mode (same as MacroPDF417 mode) requires two fields: Pdf417MacroFileID and Pdf417MacroSegmentID. All other fields are optional. + *+ * These samples show how to encode UCC/EAN-128 non Linked modes in GS1MicroPdf417 + *+ * + */ +class Pdf417Parameters implements Communicator +{ + private $pdf417ParametersDto; + + private function getPdf417ParametersDto(): Pdf417ParametersDTO + { + return $this->pdf417ParametersDto; + } + + private function setPdf417ParametersDto(Pdf417ParametersDTO $pdf417ParametersDto): void + { + $this->pdf417ParametersDto = $pdf417ParametersDto; + } + + function __construct(Pdf417ParametersDTO $pdf417ParametersDto) + { + $this->pdf417ParametersDto = $pdf417ParametersDto; + $this->obtainDto(); + $this->initFieldsFromDto(); + } + + public function obtainDto(...$args) + { + } + + public function initFieldsFromDto(): void + { + } + + /** + * Pdf417 symbology type of BarCode's compaction mode. + * Default value: Pdf417CompactionMode::AUTO. + * @deprecated This property is obsolete and will be removed in future releases. Instead, use the Pdf417EncodeMode property. + */ + public function getPdf417CompactionMode(): int + { + try + { + return $this->getPdf417ParametersDto()->pdf417CompactionMode; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Pdf417 symbology type of BarCode's compaction mode. + * Default value: Pdf417CompactionMode::AUTO. + * @deprecated This property is obsolete and will be removed in future releases. Instead, use the Pdf417EncodeMode property. + */ + public function setPdf417CompactionMode(int $value): void + { + try + { + $this->getPdf417ParametersDto()->pdf417CompactionMode = $value; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Identifies Pdf417 encode mode. + * Default value: Auto. + */ + public function getPdf417EncodeMode(): int + { + return $this->getPdf417ParametersDto()->pdf417EncodeMode; + } + + /** + * Identifies Pdf417 encode mode. + * Default value: Auto. + */ + public function setPdf417EncodeMode(int $value): void + { + $this->getPdf417ParametersDto()->pdf417EncodeMode = $value; + } + + /** + * Gets Pdf417 symbology type of BarCode's error correction level + * ranging from level0 to level8, level0 means no error correction info, + * level8 means best error correction which means a larger picture. + */ + public function getPdf417ErrorLevel(): int + { + try + { + return $this->getPdf417ParametersDto()->pdf417ErrorLevel; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Sets Pdf417 symbology type of BarCode's error correction level + * ranging from level0 to level8, level0 means no error correction info, + * level8 means best error correction which means a larger picture. + */ + public function setPdf417ErrorLevel(int $value): void + { + try + { + $this->getPdf417ParametersDto()->pdf417ErrorLevel = $value; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Whether Pdf417 symbology type of BarCode is truncated (to reduce space). + */ + public function getPdf417Truncate(): bool + { + try + { + return $this->getPdf417ParametersDto()->pdf417Truncate; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Whether Pdf417 symbology type of BarCode is truncated (to reduce space). + */ + public function setPdf417Truncate(bool $value): void + { + try + { + $this->getPdf417ParametersDto()->pdf417Truncate = $value; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Columns count. + */ + public function getColumns(): int + { + try + { + return $this->getPdf417ParametersDto()->columns; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Columns count. + */ + public function setColumns(int $value): void + { + try + { + $this->getPdf417ParametersDto()->columns = $value; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Rows count. + */ + public function getRows(): int + { + try + { + return $this->getPdf417ParametersDto()->rows; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Rows count. + */ + public function setRows(int $value): void + { + try + { + $this->getPdf417ParametersDto()->rows = $value; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Height/Width ratio of 2D BarCode module. + */ + public function getAspectRatio(): float + { + try + { + return $this->getPdf417ParametersDto()->aspectRatio; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Height/Width ratio of 2D BarCode module. + */ + public function setAspectRatio(float $value): void + { + try + { + $this->getPdf417ParametersDto()->aspectRatio = $value; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Getsmacro Pdf417 barcode's file ID. + * Used for MacroPdf417. + */ + public function getPdf417MacroFileID(): int + { + try + { + return $this->getPdf417ParametersDto()->pdf417MacroFileID; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Sets macro Pdf417 barcode's file ID. + * Used for MacroPdf417. + */ + public function setPdf417MacroFileID(int $value): void + { + try + { + $this->getPdf417ParametersDto()->pdf417MacroFileID = $value; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Gets macro Pdf417 barcode's segment ID, which starts from 0, to MacroSegmentsCount - 1. + */ + public function getPdf417MacroSegmentID(): int + { + try + { + return $this->getPdf417ParametersDto()->pdf417MacroSegmentID; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Sets macro Pdf417 barcode's segment ID, which starts from 0, to MacroSegmentsCount - 1. + */ + public function setPdf417MacroSegmentID(int $value): void + { + try + { + $this->getPdf417ParametersDto()->pdf417MacroSegmentID = $value; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Gets macro Pdf417 barcode segments count. + */ + public function getPdf417MacroSegmentsCount(): int + { + try + { + return $this->getPdf417ParametersDto()->pdf417MacroSegmentsCount; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Sets macro Pdf417 barcode segments count. + */ + public function setPdf417MacroSegmentsCount(int $value): void + { + try + { + $this->getPdf417ParametersDto()->pdf417MacroSegmentsCount = $value; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Gets macro Pdf417 barcode file name. + * @return + */ + public function getPdf417MacroFileName(): string + { + try + { + return $this->getPdf417ParametersDto()->pdf417MacroFileName; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Sets macro Pdf417 barcode file name. + * @param string $value + */ + public function setPdf417MacroFileName(string $value) + { + try + { + $this->getPdf417ParametersDto()->pdf417MacroFileName = $value; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Gets macro Pdf417 barcode time stamp. + */ + public function getPdf417MacroTimeStamp(): DateTime + { + try + { + return new DateTime('@' . $this->getPdf417ParametersDto()->pdf417MacroTimeStamp); + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Sets macro Pdf417 barcode time stamp. + */ + public function setPdf417MacroTimeStamp(DateTime $value) + { + try + { + $this->getPdf417ParametersDto()->pdf417MacroTimeStamp = $value->getTimestamp() . ""; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Gets macro Pdf417 barcode sender name. + */ + public function getPdf417MacroSender(): string + { + try + { + return $this->getPdf417ParametersDto()->pdf417MacroSender; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Sets macro Pdf417 barcode sender name. + */ + public function setPdf417MacroSender(string $value) + { + try + { + $this->getPdf417ParametersDto()->pdf417MacroSender = $value; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Gets macro Pdf417 barcode addressee name. + */ + public function getPdf417MacroAddressee(): string + { + try + { + return $this->getPdf417ParametersDto()->pdf417MacroAddressee; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Sets macro Pdf417 barcode addressee name. + */ + public function setPdf417MacroAddressee(string $value) + { + try + { + $this->getPdf417ParametersDto()->pdf417MacroAddressee = $value; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Gets macro Pdf417 file size. + * @return int file size field contains the size in bytes of the entire source file. + */ + public function getPdf417MacroFileSize(): int + { + try + { + return $this->getPdf417ParametersDto()->pdf417MacroFileSize; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Sets macro Pdf417 file size. + * @param int $value The file size field contains the size in bytes of the entire source file. + */ + public function setPdf417MacroFileSize(int $value) + { + try + { + $this->getPdf417ParametersDto()->pdf417MacroFileSize = $value; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Gets macro Pdf417 barcode checksum. + * @return int checksum field contains the value of the 16-bit (2 bytes) CRC checksum using the CCITT-16 polynomial. + */ + public function getPdf417MacroChecksum(): int + { + try + { + return $this->getPdf417ParametersDto()->pdf417MacroChecksum; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Sets macro Pdf417 barcode checksum. + * @param int $value The checksum field contains the value of the 16-bit (2 bytes) CRC checksum using the CCITT-16 polynomial. + */ + public function setPdf417MacroChecksum(int $value) + { + try + { + $this->getPdf417ParametersDto()->pdf417MacroChecksum = $value; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Extended Channel Interpretation Identifiers. It is used to tell the barcode reader details + * about the used references for encoding the data in the symbol. Not applied for Macro PDF417 text fields. + * Current implementation consists all well known charset encodings. + */ + public function getPdf417ECIEncoding(): int + { + try + { + return $this->getPdf417ParametersDto()->pdf417ECIEncoding; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Extended Channel Interpretation Identifiers. It is used to tell the barcode reader details + * about the used references for encoding the data in the symbol. Not applied for Macro PDF417 text fields. + * Current implementation consists all well known charset encodings. + */ + public function setPdf417ECIEncoding(int $value): void + { + try + { + $this->getPdf417ParametersDto()->pdf417ECIEncoding = $value; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Extended Channel Interpretation Identifiers. Applies for Macro PDF417 text fields. + */ + public function getPdf417MacroECIEncoding(): int + { + try + { + return $this->getPdf417ParametersDto()->pdf417MacroECIEncoding; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Extended Channel Interpretation Identifiers. Applies for Macro PDF417 text fields. + */ + public function setPdf417MacroECIEncoding(int $value) + { + try + { + $this->getPdf417ParametersDto()->pdf417MacroECIEncoding = $value; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Used to tell the encoder whether to add Macro PDF417 Terminator (codeword 922) to the segment. + * Applied only for Macro PDF417. + */ + public function getPdf417MacroTerminator(): int + { + try + { + return $this->getPdf417ParametersDto()->pdf417MacroTerminator; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Used to tell the encoder whether to add Macro PDF417 Terminator (codeword 922) to the segment. + * Applied only for Macro PDF417. + */ + public function setPdf417MacroTerminator(int $value) + { + try + { + $this->getPdf417ParametersDto()->pdf417MacroTerminator = $value; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Used to instruct the reader to interpret the data contained within the symbol + * as programming for reader initialization + * @return + */ + public function isReaderInitialization(): bool + { + try + { + return $this->getPdf417ParametersDto()->isReaderInitialization; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Used to instruct the reader to interpret the data contained within the symbol + * as programming for reader initialization + * @param bool $value + */ + public function setReaderInitialization(bool $value): void + { + try + { + $this->getPdf417ParametersDto()->isReaderInitialization = $value; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + *+ * + * # Encodes GS1 UCC/EAN-128 non Linked mode 905 with AI 01 (GTIN) + * $generator = new BarcodeGenerator(EncodeTypes::GS_1_MICRO_PDF_417, "(01)12345678901231"); + * $reader = new BarCodeReader($generator->generateBarCodeImage(BarcodeImageFormat::PNG), null, DecodeType::GS_1_MICRO_PDF_417); + * foreach ($reader->readBarCodes() as $result) + * echo $result->getCodeText(); + * + * # Encodes GS1 UCC/EAN-128 non Linked modes 903, 904 with any AI + * $generator = new BarcodeGenerator(EncodeTypes::GS_1_MICRO_PDF_417, "(241)123456789012345(241)ABCD123456789012345"); + * $reader = new BarCodeReader($generator->generateBarCodeImage(BarcodeImageFormat::PNG), null, DecodeType::GS_1_MICRO_PDF_417); + * foreach ($reader->readBarCodes() as $result) + * echo $result->getCodeText(); + *+ *+ * Macro Characters 05 and 06 values are used to obtain more compact encoding in special modes. + * Can be used only with MicroPdf417 and encodes 916 and 917 MicroPdf417 modes + * Default value: MacroCharacters.None. + *
+ */ + public function getMacroCharacters(): int + { + return $this->getPdf417ParametersDto()->macroCharacters; + } + + /** + *+ * These samples show how to encode Macro Characters in MicroPdf417 + *+ * @code + * # Encodes MicroPdf417 with 05 Macro the string: "[)>\u001E05\u001Dabcde1234\u001E\u0004" + * $generator = new BarcodeGenerator(EncodeTypes::MICRO_PDF_417, "abcde1234"); + * $generator->getParameters()->getBarcode()->getPdf417()->setMacroCharacters(MacroCharacter::MACRO_05); + * $reader = new BarCodeReader($generator->generateBarCodeImage(BarcodeImageFormat::PNG), null, DecodeType::MICRO_PDF_417); + * foreach($reader->readBarCodes() as $result) + * echo $result->getCodeText(); + * @endcode + * + * @code + * # Encodes MicroPdf417 with 06 Macro the string: "[)>\u001E06\u001Dabcde1234\u001E\u0004" + * $generator = new BarcodeGenerator(EncodeTypes::MICRO_PDF_417, "abcde1234"); + * $generator->getParameters()->getBarcode()->getPdf417()->setMacroCharacters(MacroCharacter::MACRO_06); + * $reader = new BarCodeReader($generator->generateBarCodeImage(BarcodeImageFormat::PNG), null, DecodeType::MICRO_PDF_417); + * foreach($reader->readBarCodes() as $result) + * echo $result->getCodeText()); + * @endcode + *+ *+ * Macro Characters 05 and 06 values are used to obtain more compact encoding in special modes. + * Can be used only with MicroPdf417 and encodes 916 and 917 MicroPdf417 modes + * Default value: MacroCharacters.None. + *
+ */ + public function setMacroCharacters(int $value): void + { + $this->getPdf417ParametersDto()->macroCharacters = $value; + } + + /** + *+ * These samples show how to encode Macro Characters in MicroPdf417 + *+ * @code + * # Encodes MicroPdf417 with 05 Macro the string: "[)>\u001E05\u001Dabcde1234\u001E\u0004" + * $generator = new BarcodeGenerator(EncodeTypes::MICRO_PDF_417, "abcde1234"); + * $generator->getParameters()->getBarcode()->getPdf417()->setMacroCharacters(MacroCharacter::MACRO_05); + * $reader = new BarCodeReader($generator->generateBarCodeImage(BarcodeImageFormat::PNG), null, DecodeType::MICRO_PDF_417); + * foreach($reader->readBarCodes() as $result) + * echo $result->getCodeText(); + * + * @endcode + * @code + * + * # Encodes MicroPdf417 with 06 Macro the string: "[)>\u001E06\u001Dabcde1234\u001E\u0004" + * $generator = new BarcodeGenerator(EncodeTypes::MICRO_PDF_417, "abcde1234"); + * $generator->getParameters()->getBarcode()->getPdf417()->setMacroCharacters(MacroCharacter::MACRO_06); + * $reader = new BarCodeReader($generator->generateBarCodeImage(BarcodeImageFormat::PNG), null, DecodeType::MICRO_PDF_417); + * foreach($reader->readBarCodes() as $result) + * echo $result->getCodeText(); + * @endcode + *+ *+ * Defines linked modes with GS1MicroPdf417, MicroPdf417 and Pdf417 barcodes + * With GS1MicroPdf417 symbology encodes 906, 907, 912, 913, 914, 915 "Linked" UCC/EAN-128 modes + * With MicroPdf417 and Pdf417 symbologies encodes 918 linkage flag to associated linear component other than an EAN.UCC + *
+ */ + public function isLinked(): bool + { + return $this->getPdf417ParametersDto()->isLinked; + } + + /** + *+ * These samples show how to encode "Linked" UCC/EAN-128 modes in GS1MicroPdf417 and Linkage Flag (918) in MicroPdf417 and Pdf417 barcodes + *+ * @code + * # Encodes GS1 Linked mode 912 with date field AI 11 (Production date) and AI 10 (Lot number) + * $generator = new BarcodeGenerator(EncodeTypes::GS_1_MICRO_PDF_417, "(11)991231(10)ABCD"); + * $generator->getParameters()->getBarcode()->getPdf417()->setLinked(true); + * $reader = new BarCodeReader($generator->generateBarCodeImage(BarcodeImageFormat::PNG), null, DecodeType::GS_1_MICRO_PDF_417); + * foreach($reader->readBarCodes() as $result) + * echo $result->getCodeText() . " IsLinked:" . $result->getExtended()->getPdf417()->isLinked(); + * + * @endcode + * @code + * # Encodes GS1 Linked mode 912 with date field AI 13 (Packaging date) and AI 21 (Serial number) + * $generator = new BarcodeGenerator(EncodeTypes::GS_1_MICRO_PDF_417, "(13)991231(21)ABCD"); + * $generator->getParameters()->getBarcode()->getPdf417()->setLinked(true); + * $reader = new BarCodeReader($generator->generateBarCodeImage(BarcodeImageFormat::PNG), null, DecodeType::GS_1_MICRO_PDF_417); + * foreach($reader->readBarCodes() as $result) + * echo $result->getCodeText() . " IsLinked:" . $result->getExtended()->getPdf417()->isLinked(); + * + * @endcode + * @code + * # Encodes GS1 Linked mode 912 with date field AI 15 (Sell-by date) and AI 10 (Lot number) + * $generator = new BarcodeGenerator(EncodeTypes::GS_1_MICRO_PDF_417, "(15)991231(10)ABCD"); + * $generator->getParameters()->getBarcode()->getPdf417()->setLinked(true); + * $reader = new BarCodeReader($generator->generateBarCodeImage(BarcodeImageFormat::PNG), null, DecodeType::GS_1_MICRO_PDF_417); + * foreach($reader->readBarCodes() as $result) + * echo $result->getCodeText() . " IsLinked:" . $result->getExtended()->getPdf417()->isLinked(); + * + * @endcode + * @code + * # Encodes GS1 Linked mode 912 with date field AI 17 (Expiration date) and AI 21 (Serial number) + * $generator = new BarcodeGenerator(EncodeTypes::GS_1_MICRO_PDF_417, "(17)991231(21)ABCD"); + * $generator->getParameters()->getBarcode()->getPdf417()->setLinked(true); + * $reader = new BarCodeReader($generator->generateBarCodeImage(BarcodeImageFormat::PNG), null, DecodeType::GS_1_MICRO_PDF_417); + * foreach($reader->readBarCodes() as $result) + * echo $result->getCodeText() . " IsLinked:" . $result->getExtended()->getPdf417()->isLinked(); + * + * @endcode + * @code + * # Encodes GS1 Linked mode 914 with AI 10 (Lot number) + * $generator = new BarcodeGenerator(EncodeTypes::GS_1_MICRO_PDF_417, "(10)ABCD12345"); + * $generator->getParameters()->getBarcode()->getPdf417()->setLinked(true); + * $reader = new BarCodeReader($generator->generateBarCodeImage(BarcodeImageFormat::PNG), null, DecodeType::GS_1_MICRO_PDF_417); + * foreach($reader->readBarCodes() as $result) + * echo $result->getCodeText() . " IsLinked:" . $result->getExtended()->getPdf417()->isLinked(); + * + * @endcode + * @code + * # Encodes GS1 Linked mode 915 with AI 21 (Serial number) + * $generator = new BarcodeGenerator(EncodeTypes::GS_1_MICRO_PDF_417, "(21)ABCD12345"); + * $generator->getParameters()->getBarcode()->getPdf417()->setLinked(true); + * $reader = new BarCodeReader($generator->generateBarCodeImage(BarcodeImageFormat::PNG), null, DecodeType::GS_1_MICRO_PDF_417); + * foreach($reader->readBarCodes() as $result) + * echo $result->getCodeText() . " IsLinked:" . $result->getExtended()->getPdf417()->isLinked(); + * + * @endcode + * @code + * # Encodes GS1 Linked modes 906, 907 with any AI + * $generator = new BarcodeGenerator(EncodeTypes::GS_1_MICRO_PDF_417, "(240)123456789012345"); + * $generator->getParameters()->getBarcode()->getPdf417()->setLinked(true); + * $reader = new BarCodeReader($generator->generateBarCodeImage(BarcodeImageFormat::PNG), null, DecodeType::GS_1_MICRO_PDF_417); + * foreach($reader->readBarCodes() as $result) + * echo $result->getCodeText() . " IsLinked:" . $result->getExtended()->getPdf417()->isLinked(); + * + * @endcode + * @code + * # Encodes MicroPdf417 NON EAN.UCC Linked mode 918 + * $generator = new BarcodeGenerator(EncodeTypes::MICRO_PDF_417, "ABCDE123456789012345678"); + * $generator->getParameters()->getBarcode()->getPdf417()->setLinked(true); + * $reader = new BarCodeReader($generator->generateBarCodeImage(BarcodeImageFormat::PNG), null, DecodeType::MICRO_PDF_417); + * foreach($reader->readBarCodes() as $result) + * echo $result->getCodeText() . " IsLinked:" . $result->getExtended()->getPdf417()->isLinked(); + * + * @endcode + * @code + * # Encodes Pdf417 NON EAN.UCC Linked mode 918 + * $generator = new BarcodeGenerator(EncodeTypes::PDF_417, "ABCDE123456789012345678"); + * $generator->getParameters()->getBarcode()->getPdf417()->setLinked(true); + * $reader = new BarCodeReader($generator->generateBarCodeImage(BarcodeImageFormat::PNG), null, DecodeType::PDF_417); + * foreach($reader->readBarCodes() as $result) + * echo $result->getCodeText() . " IsLinked:" . $result->getExtended()->getPdf417()->isLinked(); + * + * @endcode + *+ *+ * Defines linked modes with GS1MicroPdf417, MicroPdf417 and Pdf417 barcodes + * With GS1MicroPdf417 symbology encodes 906, 907, 912, 913, 914, 915 "Linked" UCC/EAN-128 modes + * With MicroPdf417 and Pdf417 symbologies encodes 918 linkage flag to associated linear component other than an EAN.UCC + *
+ */ + public function setLinked(bool $value): void + { + $this->getPdf417ParametersDto()->isLinked = $value; + } + + /** + *+ * These samples show how to encode "Linked" UCC/EAN-128 modes in GS1MicroPdf417 and Linkage Flag (918) in MicroPdf417 and Pdf417 barcodes + *+ * + * @code + * # Encodes GS1 Linked mode 912 with date field AI 11 (Production date) and AI 10 (Lot number) + * $generator = new BarcodeGenerator(EncodeTypes::GS_1_MICRO_PDF_417, "(11)991231(10)ABCD"); + * $generator->getParameters()->getBarcode()->getPdf417()->setLinked(true); + * $reader = new BarCodeReader($generator->generateBarCodeImage(BarcodeImageFormat::PNG), null, DecodeType::GS_1_MICRO_PDF_417); + * foreach($reader->readBarCodes() as $result) + * echo $result->getCodeText() . " IsLinked:" . $result->getExtended()->getPdf417()->isLinked(); + * # Encodes GS1 Linked mode 912 with date field AI 13 (Packaging date) and AI 21 (Serial number) + * @endcode + * @code + * $generator = new BarcodeGenerator(EncodeTypes::GS_1_MICRO_PDF_417, "(13)991231(21)ABCD"); + * $generator->getParameters()->getBarcode()->getPdf417()->setLinked(true); + * $reader = new BarCodeReader($generator->generateBarCodeImage(BarcodeImageFormat::PNG), null, DecodeType::GS_1_MICRO_PDF_417); + * foreach($reader->readBarCodes() as $result) + * echo $result->getCodeText() . " IsLinked:" . $result->getExtended()->getPdf417()->isLinked(); + * @endcode + * @code + * # Encodes GS1 Linked mode 912 with date field AI 15 (Sell-by date) and AI 10 (Lot number) + * $generator = new BarcodeGenerator(EncodeTypes::GS_1_MICRO_PDF_417, "(15)991231(10)ABCD"); + * $generator->getParameters()->getBarcode()->getPdf417()->setLinked(true); + * $reader = new BarCodeReader($generator->generateBarCodeImage(BarcodeImageFormat::PNG), null, DecodeType::GS_1_MICRO_PDF_417); + * foreach($reader->readBarCodes() as $result) + * echo $result->getCodeText() . " IsLinked:" . $result->getExtended()->getPdf417()->isLinked(); + * @endcode + * @code + * # Encodes GS1 Linked mode 912 with date field AI 17 (Expiration date) and AI 21 (Serial number) + * $generator = new BarcodeGenerator(EncodeTypes::GS_1_MICRO_PDF_417, "(17)991231(21)ABCD"); + * $generator->getParameters()->getBarcode()->getPdf417()->setLinked(true); + * $reader = new BarCodeReader($generator->generateBarCodeImage(BarcodeImageFormat::PNG), null, DecodeType::GS_1_MICRO_PDF_417); + * foreach($reader->readBarCodes() as $result) + * echo $result->getCodeText() . " IsLinked:" . $result->getExtended()->getPdf417()->isLinked(); + * @endcode + * @code + * # Encodes GS1 Linked mode 914 with AI 10 (Lot number) + * $generator = new BarcodeGenerator(EncodeTypes::GS_1_MICRO_PDF_417, "(10)ABCD12345"); + * $generator->getParameters()->getBarcode()->getPdf417()->setLinked(true); + * $reader = new BarCodeReader($generator->generateBarCodeImage(BarcodeImageFormat::PNG), null, DecodeType::GS_1_MICRO_PDF_417); + * foreach($reader->readBarCodes() as $result) + * echo $result->getCodeText() . " IsLinked:" . $result->getExtended()->getPdf417()->isLinked(); + * @endcode + * @code + * # Encodes GS1 Linked mode 915 with AI 21 (Serial number) + * $generator = new BarcodeGenerator(EncodeTypes::GS_1_MICRO_PDF_417, "(21)ABCD12345"); + * $generator->getParameters()->getBarcode()->getPdf417()->setLinked(true); + * $reader = new BarCodeReader($generator->generateBarCodeImage(BarcodeImageFormat::PNG), null, DecodeType::GS_1_MICRO_PDF_417); + * foreach($reader->readBarCodes() as $result) + * echo $result->getCodeText() . " IsLinked:" . $result->getExtended()->getPdf417()->isLinked(); + * @endcode + * @code + * # Encodes GS1 Linked modes 906, 907 with any AI + * $generator = new BarcodeGenerator(EncodeTypes::GS_1_MICRO_PDF_417, "(240)123456789012345"); + * $generator->getParameters()->getBarcode()->getPdf417()->setLinked(true); + * $reader = new BarCodeReader($generator->generateBarCodeImage(BarcodeImageFormat::PNG), null, DecodeType::GS_1_MICRO_PDF_417); + * foreach($reader->readBarCodes() as $result) + * echo $result->getCodeText() . " IsLinked:" . $result->getExtended()->getPdf417()->isLinked(); + * @endcode + * @code + * # Encodes MicroPdf417 NON EAN.UCC Linked mode 918 + * $generator = new BarcodeGenerator(EncodeTypes::MICRO_PDF_417, "ABCDE123456789012345678"); + * $generator->getParameters()->getBarcode()->getPdf417()->setLinked(true); + * $reader = new BarCodeReader($generator->generateBarCodeImage(BarcodeImageFormat::PNG), null, DecodeType::MICRO_PDF_417); + * foreach($reader->readBarCodes() as $result) + * echo $result->getCodeText() . " IsLinked:" . $result->getExtended()->getPdf417()->isLinked(); + * @endcode + * @code + * # Encodes Pdf417 NON EAN.UCC Linked mode 918 + * $generator = new BarcodeGenerator(EncodeTypes::PDF_417, "ABCDE123456789012345678"); + * $generator->getParameters()->getBarcode()->getPdf417()->setLinked(true); + * $reader = new BarCodeReader($generator->generateBarCodeImage(BarcodeImageFormat::PNG), null, DecodeType::PDF_417); + * foreach($reader->readBarCodes() as $result) + * echo $result->getCodeText() . " IsLinked:" . $result->getExtended()->getPdf417()->isLinked(); + * @endcode + *+ *+ * Can be used only with MicroPdf417 and encodes Code 128 emulation modes + * Can encode FNC1 in second position modes 908 and 909, also can encode 910 and 911 which just indicate that recognized MicroPdf417 can be interpret as Code 128 + *
+ */ + public function isCode128Emulation(): bool + { + return $this->getPdf417ParametersDto()->isCode128Emulation; + } + + /** + *+ * These samples show how to encode Code 128 emulation modes with FNC1 in second position and without. In this way MicroPdf417 can be decoded as Code 128 barcode + *+ * + * @code + * # Encodes MicroPdf417 in Code 128 emulation mode with FNC1 in second position and Application Indicator "a", mode 908. + * $generator = new BarcodeGenerator(EncodeTypes::MICRO_PDF_417, "a\u001d1222322323"); + * $generator->getParameters()->getBarcode()->getPdf417()->setCode128Emulation(true); + * $reader = new BarCodeReader($generator->generateBarCodeImage(BarcodeImageFormat::PNG), null, DecodeType::MICRO_PDF_417); + * foreach($reader->readBarCodes() as $result) + * echo $result->getCodeText() . " IsCode128Emulation:" . $result->getExtended()->getPdf417()->isCode128Emulation(); + * @endcode + * @code + * # Encodes MicroPdf417 in Code 128 emulation mode with FNC1 in second position and Application Indicator "99", mode 909. + * $generator = new BarcodeGenerator(EncodeTypes::MICRO_PDF_417, "99\u001d1222322323"); + * $generator->getParameters()->getBarcode()->getPdf417()->setCode128Emulation(true); + * $reader = new BarCodeReader($generator->generateBarCodeImage(BarcodeImageFormat::PNG), null, DecodeType::MICRO_PDF_417); + * foreach($reader->readBarCodes() as $result) + * echo $result->getCodeText() . " IsCode128Emulation:" . $result->getExtended()->getPdf417()->isCode128Emulation(); + * @endcode + * @code + * # Encodes MicroPdf417 in Code 128 emulation mode, modes 910, 911 + * $generator = new BarcodeGenerator(EncodeTypes::MICRO_PDF_417, "123456789012345678"); + * $generator->getParameters()->getBarcode()->getPdf417()->setCode128Emulation(true); + * $reader = new BarCodeReader($generator->generateBarCodeImage(BarcodeImageFormat::PNG), null, DecodeType::MICRO_PDF_417); + * foreach($reader->readBarCodes() as $result) + * echo $result->getCodeText() . " IsCode128Emulation:" + result.Extended.Pdf417.IsCode128Emulation().toString()); + * @endcode + *+ *+ * Can be used only with MicroPdf417 and encodes Code 128 emulation modes + * Can encode FNC1 in second position modes 908 and 909, also can encode 910 and 911 which just indicate that recognized MicroPdf417 can be interpret as Code 128 + *
+ */ + public function setCode128Emulation(bool $value): void + { + $this->getPdf417ParametersDto()->isCode128Emulation = $value; + } + + /** + * Returns a human-readable string representation of this Pdf417Parameters. + * + * @return string that represents this Pdf417Parameters. + */ + public function toString(): string + { + $thriftConnection = new ThriftConnection(); + $client = $thriftConnection->openConnection(); + $str = $client->Pdf417Parameters_toString($this->getPdf417ParametersDto()); + $thriftConnection->closeConnection(); + + return $str; + } +} \ No newline at end of file diff --git a/lib/Generation/PdfParameters.php b/lib/Generation/PdfParameters.php new file mode 100644 index 00000000..4a4b4696 --- /dev/null +++ b/lib/Generation/PdfParameters.php @@ -0,0 +1,165 @@ +pdfParametersDto; + } + + private function setPdfParametersDto(PdfParametersDTO $pdfParametersDto): void + { + $this->pdfParametersDto = $pdfParametersDto; + } + + function __construct(PdfParametersDTO $pdfParametersDto) + { + $this->pdfParametersDto = $pdfParametersDto; + $this->obtainDto(); + $this->initFieldsFromDto(); + } + + public function obtainDto(...$args) + { + } + + public function initFieldsFromDto(): void + { + } + + /** + *+ * These samples show how to encode Code 128 emulation modes with FNC1 in second position and without. In this way MicroPdf417 can be decoded as Code 128 barcode + *+ * + * @code + * # Encodes MicroPdf417 in Code 128 emulation mode with FNC1 in second position and Application Indicator "a", mode 908. + * $generator = new BarcodeGenerator(EncodeTypes::MICRO_PDF_417, "a\u001d1222322323"); + * $generator->getParameters()->getBarcode()->getPdf417()->setCode128Emulation(true); + * $reader = new BarCodeReader($generator->generateBarCodeImage(BarcodeImageFormat::PNG), null, DecodeType::MICRO_PDF_417); + * foreach($reader->readBarCodes() as $result) + * echo $result->getCodeText() . " IsCode128Emulation:" + result.Extended.Pdf417.IisCode128Emulation().toString()); + * @endcode + * @code + * # Encodes MicroPdf417 in Code 128 emulation mode with FNC1 in second position and Application Indicator "99", mode 909. + * $generator = new BarcodeGenerator(EncodeTypes::MICRO_PDF_417, "99\u001d1222322323"); + * $generator->getParameters()->getBarcode()->getPdf417()->setCode128Emulation(true); + * $reader = new BarCodeReader($generator->generateBarCodeImage(BarcodeImageFormat::PNG), null, DecodeType::MICRO_PDF_417); + * foreach($reader->readBarCodes() as $result) + * echo $result->getCodeText() . " IsCode128Emulation:" . $result->getExtended()->getPdf417()->isCode128Emulation(); + * @endcode + * @code + * # Encodes MicroPdf417 in Code 128 emulation mode, modes 910, 911 + * $generator = new BarcodeGenerator(EncodeTypes::MICRO_PDF_417, "123456789012345678"); + * $generator->getParameters()->getBarcode()->getPdf417()->setCode128Emulation(true); + * $reader = new BarCodeReader($generator->generateBarCodeImage(BarcodeImageFormat::PNG), null, DecodeType::MICRO_PDF_417); + * foreach($reader->readBarCodes() as $result) + * echo $result->getCodeText() . " IsCode128Emulation:" . $result->getExtended()->getPdf417()->isCode128Emulation())); + * @endcode + *+ *+ * Nullable. CMYK color value of bar code. Null means CMYK color is not used, instead normal RGB color is used. + *
+ */ + function getCMYKBarColor(): CMYKColor + { + return CMYKColor::parseCMYK($this->getPdfParametersDto()->cmykBarColor); + } + + /** + *+ * Nullable. CMYK color value of bar code. Null means CMYK color is not used, instead normal RGB color is used. + *
+ */ + function setCMYKBarColor(CMYKColor $value): void + { + $this->getPdfParametersDto()->cmykBarColor = $value != null ? $value->formatCMYK() : null; + } + + /** + *+ * Nullable. CMYK back color value. Null means CMYK color is not used, instead normal RGB color is used. + *
+ */ + public function getCMYKBackColor(): CMYKColor + { + return CMYKColor::parseCMYK($this->getPdfParametersDto()->cmykBackColor); + } + + /** + *+ * Nullable. CMYK back color value. Null means CMYK color is not used, instead normal RGB color is used. + *
+ */ + public function setCMYKBackColor(CMYKColor $value): void + { + $this->getPdfParametersDto()->cmykBackColor = ($value != null ? $value->formatCMYK() : null); + } + + /** + *+ * Nullable. CMYK color value of Codetext. Null means CMYK color is not used, instead normal RGB color is used. + *
+ */ + public function getCMYKCodetextColor(): CMYKColor + { + return CMYKColor::parseCMYK($this->getPdfParametersDto()->cmykCodetextColor); + } + + /** + *+ * Nullable. CMYK color value of Codetext. Null means CMYK color is not used, instead normal RGB color is used. + *
+ */ + public function setCMYKCodetextColor(CMYKColor $value): void + { + $this->getPdfParametersDto()->cmykCodetextColor = $value != null ? $value->formatCMYK() : null; + } + + /** + *+ * Nullable. CMYK color value of caption above. Null means CMYK color is not used, instead normal RGB color is used. + *
+ */ + public function getCMYKCaptionAboveColor(): CMYKColor + { + return CMYKColor::parseCMYK($this->getPdfParametersDto()->cmykCaptionAboveColor); + } + + /** + *+ * Nullable. CMYK color value of caption above. Null means CMYK color is not used, instead normal RGB color is used. + *
+ */ + public function setCMYKCaptionAboveColor(CMYKColor $value): void + { + $this->getPdfParametersDto()->cmykCaptionAboveColor = $value != null ? $value->formatCMYK() : null; + } + + /** + *+ * Nullable. CMYK color value of caption below. Null means CMYK color is not used, instead normal RGB color is used. + *
+ */ + public function getCMYKCaptionBelowColor(): CMYKColor + { + return CMYKColor::parseCMYK($this->getPdfParametersDto()->cmykCaptionBelowColor); + } + + /** + *+ * Nullable. CMYK color value of caption below. Null means CMYK color is not used, instead normal RGB color is used. + *
+ */ + public function setCMYKCaptionBelowColor(CMYKColor $value): void + { + $this->getPdfParametersDto()->cmykCaptionBelowColor = $value->formatCMYK(); + } + + /** + *+ * Are paths used instead of text (use if Unicode characters are not displayed) + * Default value: false. + *
+ */ + public function isTextAsPath(): bool + { + return $this->getPdfParametersDto()->textAsPath; + } + + /** + *+ * Are paths used instead of text (use if Unicode characters are not displayed) + * Default value: false. + *
+ */ + public function setTextAsPath(bool $value): void + { + $this->getPdfParametersDto()->textAsPath = $value; + } +} \ No newline at end of file diff --git a/lib/Generation/PostalParameters.php b/lib/Generation/PostalParameters.php new file mode 100644 index 00000000..abfe30fa --- /dev/null +++ b/lib/Generation/PostalParameters.php @@ -0,0 +1,100 @@ +postalParametersDto; + } + + private function setPostalParametersDto(PostalParametersDTO $postalParametersDto): void + { + $this->postalParametersDto = $postalParametersDto; + } + + private $postalShortBarHeight; + + function __construct(PostalParametersDTO $postalParametersDto) + { + $this->postalParametersDto = $postalParametersDto; + $this->obtainDto(); + $this->initFieldsFromDto(); + } + + public function obtainDto(...$args) + { + } + + public function initFieldsFromDto(): void + { + try + { + $this->postalShortBarHeight = new Unit($this->getPostalParametersDto()->postalShortBarHeight); + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Short bar's height of Postal barcodes. + */ + public function getPostalShortBarHeight(): Unit + { + try + { + return $this->postalShortBarHeight; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Short bar's height of Postal barcodes. + */ + public function setPostalShortBarHeight(Unit $value): void + { + try + { + $this->getPostalParametersDto()->postalShortBarHeight = $value->getUnitDto(); + $this->postalShortBarHeight = $value; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Returns a human-readable string representation of this PostalParameters. + * + * @return string A string that represents this PostalParameters. + */ + public function toString(): string + { + $thriftConnection = new ThriftConnection(); + $client = $thriftConnection->openConnection(); + $str = $client->PostalParameters_toString($this->getPostalParametersDto()); + $thriftConnection->closeConnection(); + + return $str; + } +} \ No newline at end of file diff --git a/lib/Generation/QREncodeMode.php b/lib/Generation/QREncodeMode.php new file mode 100644 index 00000000..b8dd132f --- /dev/null +++ b/lib/Generation/QREncodeMode.php @@ -0,0 +1,148 @@ + + * Encoding mode for QR barcodes. + * + *+ *+ * Example how to use ECI encoding + *+ * $generator = new BarcodeGenerator(EncodeTypes::QR, "12345TEXT"); + * $generator->getParameters()->getBarcode()->getQR()->setQrEncodeMode(QREncodeMode::ECI_ENCODING); + * $generator->getParameters()->getBarcode()->getQR()->setQrECIEncoding(ECIEncodings::UTF8); + * $generator->save("test.png", BarcodeImageFormat::PNG); + *+ *+ */ +class QREncodeMode +{ + /** + * In Auto mode, the CodeText is encoded with maximum data compactness. + * Unicode characters are encoded in kanji mode if possible, or they are re-encoded in the ECIEncoding specified encoding with the insertion of an ECI identifier. + * If a character is found that is not supported by the selected ECI encoding, an exception is thrown. + */ + + const AUTO = 0; + /** + * Encode codetext as plain bytes. If it detects any Unicode character, the character will be encoded as two bytes, lower byte first. + * @deprecated This property is obsolete and will be removed in future releases. Instead, use the 'SetCodeText' method to convert the message to byte array with specified encoding. + */ + const BYTES = 1; + + /** + * Encode codetext with UTF8 encoding with first ByteOfMark character. + * @deprecated This property is obsolete and will be removed in future releases. Instead, use the 'SetCodeText' method with UTF8 encoding to add a byte order mark (BOM) and encode the message. After that, the CodeText can be encoded using the 'Auto' mode. + */ + const UTF_8_BOM = 2; + + + /** + * Encode codetext with UTF8 encoding with first ByteOfMark character. It can be problems with some barcode scanners. + * @deprecated This property is obsolete and will be removed in future releases. Instead, use the 'SetCodeText' method with BigEndianUnicode encoding to add a byte order mark (BOM) and encode the message. After that, the CodeText can be encoded using the 'Auto' mode. + */ + const UTF_16_BEBOM = 3; + + /** + * Encode codetext with value set in the ECIEncoding property. It can be problems with some old (pre 2006) barcode scanners. + * This mode is not supported by MicroQR barcodes. + * @deprecated This property is obsolete and will be removed in future releases. Instead, use ECI option. + */ + const ECI_ENCODING = 4; + + /** + * Extended Channel mode which supports FNC1 first position, FNC1 second position and multi ECI modes. + * It is better to use QrExtCodetextBuilder for extended codetext generation. + * Use Display2DText property to set visible text to removing managing characters. + * Encoding Principles: + * All symbols "\" must be doubled "\\" in the codetext. + * FNC1 in first position is set in codetext as as "<FNC1>" + * FNC1 in second position is set in codetext as as "<FNC1(value)>". The value must be single symbols (a-z, A-Z) or digits from 0 to 99. + * Group Separator for FNC1 modes is set as 0x1D character '\\u001D' + * If you need to insert "<FNC1>" string into barcode write it as "<\FNC1>" + * ECI identifiers are set as single slash and six digits identifier "\000026" - UTF8 ECI identifier + * To disable current ECI mode and convert to default JIS8 mode zero mode ECI indetifier is set. "\000000" + * All unicode characters after ECI identifier are automatically encoded into correct character codeset. + * This mode is not supported by MicroQR barcodes. + * @deprecated This property is obsolete and will be removed in future releases. Instead, use the 'Extended' encode mode. + */ + const EXTENDED_CODETEXT = 5; + + /** + * Extended Channel mode which supports FNC1 first position, FNC1 second position and multi ECI modes. + * It is better to use QrExtCodetextBuilder for extended codetext generation. + * Use Display2DText property to set visible text to removing managing characters. + * Encoding Principles: + * All symbols "\" must be doubled "\\" in the codetext. + * FNC1 in first position is set in codetext as as "<FNC1>" + * FNC1 in second position is set in codetext as as "<FNC1(value)>". The value must be single symbols (a-z, A-Z) or digits from 0 to 99. + * Group Separator for FNC1 modes is set as 0x1D character '\\u001D' + * If you need to insert "<FNC1>" string into barcode write it as "<\FNC1>" + * ECI identifiers are set as single slash and six digits identifier "\000026" - UTF8 ECI identifier + * To disable current ECI mode and convert to default JIS8 mode zero mode ECI indetifier is set. "\000000" + * All unicode characters after ECI identifier are automatically encoded into correct character codeset. + * This mode is not supported by MicroQR barcodes. + */ + const EXTENDED = 6; + + /** + * In Binary mode, the CodeText is encoded with maximum data compactness. + * If a Unicode character is found, an exception is thrown. + */ + const BINARY = 7; + + /** + * In ECI mode, the entire message is re-encoded in the ECIEncoding specified encoding with the insertion of an ECI identifier. + * If a character is found that is not supported by the selected ECI encoding, an exception is thrown. + * Please note that some old (pre 2006) scanners may not support this mode. + * This mode is not supported by MicroQR barcodes. + */ + const ECI = 8; +} \ No newline at end of file diff --git a/lib/Generation/QREncodeType.php b/lib/Generation/QREncodeType.php new file mode 100644 index 00000000..c036c9c9 --- /dev/null +++ b/lib/Generation/QREncodeType.php @@ -0,0 +1,23 @@ +addFNC1FirstPosition(); + * $lTextBuilder->addPlainCodetext("000%89%%0"); + * $lTextBuilder->addFNC1GroupSeparator(); + * $lTextBuilder->addPlainCodetext("12345<FNC1>"); + * //generate codetext + * $lCodetext = lTextBuilder->getExtendedCodetext(); + * @endcode + * + * Example how to generate FNC1 second position for Extended Mode + * @code + * //create codetext + * $lTextBuilder = new QrExtCodetextBuilder(); + * $lTextBuilder->addFNC1SecondPosition("12"); + * $lTextBuilder->addPlainCodetext("TRUE3456"); + * //generate codetext + * $lCodetext = lTextBuilder->getExtendedCodetext(); + * @endcode + * + * Example how to generate multi ECI mode for Extended Mode + * @code + * //create codetext + * $lTextBuilder = new QrExtCodetextBuilder(); + * $lTextBuilder->addECICodetext(ECIEncodings::Win1251, "Will"); + * $lTextBuilder->addECICodetext(ECIEncodings::UTF8, "Right"); + * $lTextBuilder->addECICodetext(ECIEncodings::UTF16BE, "Power"); + * $lTextBuilder->addPlainCodetext("t\\e\\\\st"); + * //generate codetext + * $lCodetext = $lTextBuilder->getExtendedCodetext(); + * @endcode + */ +class QrExtCodetextBuilder extends ExtCodetextBuilder +{ + function __construct() + { + try + { + parent::__construct(); + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + function init(): void + { + } + + /** + * Adds FNC1 in first position to the extended codetext items + */ + function addFNC1FirstPosition(): void + { + try + { + $extCodeItemDTO = new \Aspose\Barcode\Bridge\ExtCodeItemDTO(); + $extCodeItemDTO->extCodeItemType = ExtCodeItemType::FNC_1_FIRST_POSITION; + $extCodeItemDTO->arguments = array(); + array_push($this->_list, $extCodeItemDTO); + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Adds FNC1 in second position to the extended codetext items + * + * @param string $codetext Value of the FNC1 in the second position + */ + function addFNC1SecondPosition(string $codetext): void + { + try + { + $extCodeItemDTO = new \Aspose\Barcode\Bridge\ExtCodeItemDTO(); + $extCodeItemDTO->extCodeItemType = ExtCodeItemType::FNC_1_SECOND_POSITION; + $extCodeItemDTO->arguments = array($codetext); + array_push($this->_list, $extCodeItemDTO); + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Adds Group Separator (GS - '\\u001D') to the extended codetext items + */ + function addFNC1GroupSeparator(): void + { + try + { + $extCodeItemDTO = new \Aspose\Barcode\Bridge\ExtCodeItemDTO(); + $extCodeItemDTO->extCodeItemType = ExtCodeItemType::FNC_1_GROUP_SEPARATOR; + $extCodeItemDTO->arguments = array(); + array_push($this->_list, $extCodeItemDTO); + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + protected function getExtCodetextBuilderType(): int + { + return ExtCodetextBuilderType::QR_EXT_CODETEXT_BUILDER; + } +} \ No newline at end of file diff --git a/lib/Generation/QrParameters.php b/lib/Generation/QrParameters.php new file mode 100644 index 00000000..e84758f4 --- /dev/null +++ b/lib/Generation/QrParameters.php @@ -0,0 +1,330 @@ +qrParametersDto; + } + + private function setQrParametersDto(QrParametersDTO $qrParametersDto): void + { + $this->qrParametersDto = $qrParametersDto; + } + + private $structuredAppend; + + function __construct(QrParametersDTO $qrParametersDto) + { + $this->qrParametersDto = $qrParametersDto; + $this->obtainDto(); + $this->initFieldsFromDto(); + } + + public function obtainDto(...$args) + { + } + + public function initFieldsFromDto(): void + { + try + { + $this->structuredAppend = new QrStructuredAppendParameters($this->getQrParametersDto()->structuredAppend); + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * QR structured append parameters. + */ + public function getStructuredAppend(): QrStructuredAppendParameters + { + return $this->structuredAppend; + } + + /** + * QR structured append parameters. + */ + public function setStructuredAppend(QrStructuredAppendParameters $value) + { + try + { + $this->structuredAppend = $value; + $this->getQrParametersDto()->structuredAppend = $value->getQrStructuredAppendParametersDto(); + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Extended Channel Interpretation Identifiers. It is used to tell the barcode reader details + * about the used references for encoding the data in the symbol. + * Current implementation consists all well known charset encodings. + */ + public function getQrECIEncoding(): int + { + try + { + return $this->getQrParametersDto()->qrECIEncoding; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Extended Channel Interpretation Identifiers. It is used to tell the barcode reader details + * about the used references for encoding the data in the symbol. + * Current implementation consists all well known charset encodings. + */ + public function setQrECIEncoding(int $value): void + { + try + { + $this->getQrParametersDto()->qrECIEncoding = $value; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * QR symbology type of BarCode's encoding mode. + * Default value: QREncodeMode::AUTO. + */ + public function getQrEncodeMode(): int + { + try + { + return $this->getQrParametersDto()->qrEncodeMode; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * QR symbology type of BarCode's encoding mode. + * Default value: QREncodeMode::AUTO. + */ + public function setQrEncodeMode(int $value): void + { + try + { + $this->getQrParametersDto()->qrEncodeMode = $value; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * QR / MicroQR selector mode. Select ForceQR for standard QR symbols, Auto for MicroQR. + */ + public function getQrEncodeType(): int + { + try + { + return $this->getQrParametersDto()->qrEncodeType; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * QR / MicroQR selector mode. Select ForceQR for standard QR symbols, Auto for MicroQR. + */ + public function setQrEncodeType(int $value): void + { + try + { + $this->getQrParametersDto()->qrEncodeType = $value; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Level of Reed-Solomon error correction for QR barcode. + * From low to high: LEVEL_L, LEVEL_M, LEVEL_Q, LEVEL_H. + * @see QRErrorLevel. + */ + public function getQrErrorLevel(): int + { + try + { + return $this->getQrParametersDto()->qrErrorLevel; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Level of Reed-Solomon error correction for QR barcode. + * From low to high: LEVEL_L, LEVEL_M, LEVEL_Q, LEVEL_H. + * @see QRErrorLevel. + */ + public function setQrErrorLevel(int $value): void + { + try + { + $this->getQrParametersDto()->qrErrorLevel = $value; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Version of QR Code. + * From Version1 to Version40 for QR code and from M1 to M4 for MicroQr. + * Default value is QRVersion::AUTO. + */ + public function getQrVersion(): int + { + try + { + return $this->getQrParametersDto()->qrVersion; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Version of QR Code. + * From Version1 to Version40 for QR code and from M1 to M4 for MicroQr. + * Default value is QRVersion::AUTO. + */ + public function setQrVersion(int $value): void + { + try + { + $this->getQrParametersDto()->qrVersion = $value; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + *+ * Example how to use FNC1 first position in Extended Mode + *+ * $textBuilder = new QrExtCodetextBuilder(); + * $textBuilder->addPlainCodetext("000%89%%0"); + * $textBuilder->addFNC1GroupSeparator(); + * $textBuilder->addPlainCodetext("12345<FNC1>"); + * //generate barcode + * $generator = new BarcodeGenerator(EncodeTypes::QR); + * $generator->setCodeText(textBuilder->getExtended()); + * $generator->getParameters()->getBarcode()->getQR()->setQrEncodeMode(QREncodeMode::EXTENDED_CODETEXT); + * $generator->getParameters()->getBarcode()->getCodeTextParameters()->setTwoDDisplayText("My Text"); + * $generator->save("d:/test.png", BarcodeImageFormat::PNG); + *+ * * + * This sample shows how to use FNC1 second position in Extended Mode. + *+ * + * //create codetext + * $textBuilder = new QrExtCodetextBuilder(); + * $textBuilder->addFNC1SecondPosition("12"); + * $textBuilder->addPlainCodetext("TRUE3456"); + * //generate barcode + * $generator = new BarcodeGenerator(EncodeTypes::QR); + * $generator->setCodeText(textBuilder->getExtended()); + * $generator->getParameters()->getBarcode()->getCodeTextParameters()->setTwoDDisplayText("My Text"); + * $generator->save("d:/test.png", BarcodeImageFormat::PNG); + *+ * + * This sample shows how to use multi ECI mode in Extended Mode. + *+ * + * //create codetext + * $textBuilder = new QrExtCodetextBuilder(); + * $textBuilder->addECICodetext(ECIEncodings::Win1251, "Will"); + * $textBuilder->addECICodetext(ECIEncodings::UTF8, "Right"); + * $textBuilder->addECICodetext(ECIEncodings::UTF16BE, "Power"); + * $textBuilder->addPlainCodetext("t\e\\st"); + * //generate barcode + * $generator = new BarcodeGenerator(EncodeTypes::QR); + * $generator->setCodeText(textBuilder->getExtended()); + * $generator->getParameters()->getBarcode()->getQR()->setQrEncodeMode(QREncodeMode::EXTENDED_CODETEXT); + * $generator->getParameters()->getBarcode()->getCodeTextParameters()->setTwoDDisplayText("My Text"); + * $generator->save("d:/test.png", BarcodeImageFormat::PNG); + *+ *+ * Version of MicroQR Code. From version M1 to version M4. + * Default value is MicroQRVersion.Auto. + *
+ */ + public function getMicroQRVersion(): int + { + return $this->getQrParametersDto()->microQRVersion; + } + + /** + *+ * Version of MicroQR Code. From version M1 to version M4. + * Default value is MicroQRVersion.Auto. + *
+ */ + public function setMicroQRVersion(int $value): void + { + $this->getQrParametersDto()->microQRVersion = $value; + } + + /** + *+ * Version of RectMicroQR Code. From version R7x59 to version R17x139. + * Default value is RectMicroQRVersion.Auto. + *
+ */ + public function getRectMicroQrVersion(): int + { + return $this->getQrParametersDto()->rectMicroQrVersion; + } + + /** + *+ * Version of RectMicroQR Code. From version R7x59 to version R17x139. + * Default value is RectMicroQRVersion.Auto. + *
+ */ + public function setRectMicroQrVersion(int $value): void + { + $this->getQrParametersDto()->rectMicroQrVersion = $value; + } + + /** + * Height/Width ratio of 2D BarCode module. + */ + public function getAspectRatio(): float + { + try + { + return $this->getQrParametersDto()->aspectRatio; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Height/Width ratio of 2D BarCode module. + */ + public function setAspectRatio(float $value): void + { + try + { + $this->getQrParametersDto()->aspectRatio = $value; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Returns a human-readable string representation of this QrParameters. + * + * @return string that represents this QrParameters. + */ + public function toString(): string + { + $thriftConnection = new ThriftConnection(); + $client = $thriftConnection->openConnection(); + $str = $client->QrParameters_toString($this->getQrParametersDto()); + $thriftConnection->closeConnection(); + + return $str; + } +} \ No newline at end of file diff --git a/lib/Generation/QrStructuredAppendParameters.php b/lib/Generation/QrStructuredAppendParameters.php new file mode 100644 index 00000000..3328964a --- /dev/null +++ b/lib/Generation/QrStructuredAppendParameters.php @@ -0,0 +1,131 @@ +qrStructuredAppendParametersDto; + } + + private function setQrStructuredAppendParametersDto(QrStructuredAppendParametersDTO $qrStructuredAppendParametersDto): void + { + $this->qrStructuredAppendParametersDto = $qrStructuredAppendParametersDto; + } + + function __construct(QrStructuredAppendParametersDTO $qrStructuredAppendParametersDto) + { + $this->qrStructuredAppendParametersDto = $qrStructuredAppendParametersDto; + $this->obtainDto(); + $this->initFieldsFromDto(); + } + + public function obtainDto(...$args) + { + } + + public function initFieldsFromDto(): void + { + } + + /** + * Gets the QR structured append mode parity data. + */ + public function getParityByte(): int + { + try + { + return $this->getQrStructuredAppendParametersDto()->parityByte; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Sets the QR structured append mode parity data. + */ + public function setParityByte(int $value) + { + try + { + $this->getQrStructuredAppendParametersDto()->parityByte = $value; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Gets the index of the QR structured append mode barcode. Index starts from 0. + */ + public function getSequenceIndicator(): int + { + try + { + return $this->getQrStructuredAppendParametersDto()->sequenceIndicator; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Sets the index of the QR structured append mode barcode. Index starts from 0. + */ + public function setSequenceIndicator(int $value) + { + try + { + $this->getQrStructuredAppendParametersDto()->sequenceIndicator = $value; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Gets the QR structured append mode barcodes quantity. Max value is 16. + */ + public function getTotalCount(): int + { + try + { + return $this->getQrStructuredAppendParametersDto()->totalCount; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Sets the QR structured append mode barcodes quantity. Max value is 16. + */ + public function setTotalCount(int $value) + { + try + { + $this->getQrStructuredAppendParametersDto()->totalCount = $value; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } +} \ No newline at end of file diff --git a/lib/Generation/RectMicroQRVersion.php b/lib/Generation/RectMicroQRVersion.php new file mode 100644 index 00000000..681600b5 --- /dev/null +++ b/lib/Generation/RectMicroQRVersion.php @@ -0,0 +1,244 @@ + + * Version of RectMicroQR Code. + * From version R7x43 to version R17x139. + * + */ +class RectMicroQRVersion +{ + /** + *+ * Specifies to automatically pick up the best version for RectMicroQR. + * This is default value. + *
+ */ + const AUTO = 0; + + /** + *+ * Specifies version with 7 x 43 modules. + *
+ */ + const R7x43 = 1; + + /** + *+ * Specifies version with 7 x 59 modules. + *
+ */ + const R7x59 = 2; + + /** + *+ * Specifies version with 7 x 77 modules. + *
+ */ + const R7x77 = 3; + + /** + *+ * Specifies version with 7 x 99 modules. + *
+ */ + const R7x99 = 4; + + /** + *+ * Specifies version with 7 x 139 modules. + *
+ */ + const R7x139 = 5; + + /** + *+ * Specifies version with 9 x 43 modules. + *
+ */ + const R9x43 = 6; + + /** + *+ * Specifies version with 9 x 59 modules. + *
+ */ + const R9x59 = 7; + + /** + *+ * Specifies version with 9 x 77 modules. + *
+ */ + const R9x77 = 8; + + /** + *+ * Specifies version with 9 x 99 modules. + *
+ */ + const R9x99 = 9; + + /** + *+ * Specifies version with 9 x 139 modules. + *
+ */ + const R9x139 = 10; + + /** + *+ * Specifies version with 11 x 27 modules. + *
+ */ + const R11x27 = 11; + + /** + *+ * Specifies version with 11 x 43 modules. + *
+ */ + const R11x43 = 12; + + /** + *+ * Specifies version with 11 x 59 modules. + *
+ */ + const R11x59 = 13; + + /** + *+ * Specifies version with 11 x 77 modules. + *
+ */ + const R11x77 = 14; + + /** + *+ * Specifies version with 11 x 99 modules. + *
+ */ + const R11x99 = 15; + + /** + *+ * Specifies version with 11 x 139 modules. + *
+ */ + const R11x139 = 16; + + /** + *+ * Specifies version with 13 x 27 modules. + *
+ */ + const R13x27 = 17; + + /** + *+ * Specifies version with 13 x 43 modules. + *
+ */ + const R13x43 = 18; + + /** + *+ * Specifies version with 13 x 59 modules. + *
+ */ + const R13x59 = 19; + + /** + *+ * Specifies version with 13 x 77 modules. + *
+ */ + const R13x77 = 20; + + /** + *+ * Specifies version with 13 x 99 modules. + *
+ */ + const R13x99 = 21; + + /** + *+ * Specifies version with 13 x 139 modules. + *
+ */ + const R13x139 = 22; + + /** + *+ * Specifies version with 15 x 43 modules. + *
+ */ + const R15x43 = 23; + + /** + *+ * Specifies version with 15 x 59 modules. + *
+ */ + const R15x59 = 24; + + /** + *+ * Specifies version with 15 x 77 modules. + *
+ */ + const R15x77 = 25; + + /** + *+ * Specifies version with 15 x 99 modules. + *
+ */ + const R15x99 = 26; + + /** + *+ * Specifies version with 15 x 139 modules. + *
+ */ + const R15x139 = 27; + + /** + *+ * Specifies version with 17 x 43 modules. + *
+ */ + const R17x43 = 28; + + /** + *+ * Specifies version with 17 x 59 modules. + *
+ */ + const R17x59 = 29; + + /** + *+ * Specifies version with 17 x 77 modules. + *
+ */ + const R17x77 = 30; + + /** + *+ * Specifies version with 17 x 99 modules. + *
+ */ + const R17x99 = 31; + + /** + *+ * Specifies version with 17 x 139 modules. + *
+ */ + const R17x139 = 32; +} \ No newline at end of file diff --git a/lib/Generation/SupplementParameters.php b/lib/Generation/SupplementParameters.php new file mode 100644 index 00000000..cec485a1 --- /dev/null +++ b/lib/Generation/SupplementParameters.php @@ -0,0 +1,114 @@ +supplementParametersDto; + } + + private function setSupplementParametersDto(SupplementParametersDTO $supplementParametersDto): void + { + $this->supplementParametersDto = $supplementParametersDto; + } + + private $_space; + + function __construct(SupplementParametersDTO $supplementParametersDto) + { + $this->supplementParametersDto = $supplementParametersDto; + $this->obtainDto(); + $this->initFieldsFromDto(); + } + + public function obtainDto(...$args) + { + } + + public function initFieldsFromDto(): void + { + try + { + $this->_space = new Unit($this->getSupplementParametersDto()->supplementSpace); + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Supplement data following BarCode. + */ + public function getSupplementData(): ?string + { + try + { + $SupplementData = $this->getSupplementParametersDto()->supplementData; + if ($SupplementData == "null") + { + return null; + } + return $SupplementData; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Supplement data following BarCode. + */ + public function setSupplementData(string $value): void + { + try + { + $this->getSupplementParametersDto()->supplementData = $value; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Space between main the BarCode and supplement BarCode in Unit value. + * + * @exception IllegalArgumentException + * The Space parameter value is less than 0. + */ + public function getSupplementSpace(): Unit + { + return $this->_space; + } + + /** + * Returns a human-readable string representation of this SupplementParameters. + * + * @return string that represents this SupplementParameters. + */ + public function toString(): string + { + $thriftConnection = new ThriftConnection(); + $client = $thriftConnection->openConnection(); + $str = $client->SupplementParameters_toString($this->getSupplementParametersDto()); + $thriftConnection->closeConnection(); + + return $str; + } +} \ No newline at end of file diff --git a/lib/Generation/SvgColorMode.php b/lib/Generation/SvgColorMode.php new file mode 100644 index 00000000..9c0c2594 --- /dev/null +++ b/lib/Generation/SvgColorMode.php @@ -0,0 +1,38 @@ + + * Possible modes for filling color in svg file, RGB is default and supported by SVG 1.1. + * RGBA, HSL, HSLA is allowed in SVG 2.0 standard. + * Even in RGB opacity will be set through "fill-opacity" parameter + * + */ +class SvgColorMode +{ + /** + *+ * RGB mode, example: fill="#ff5511" fill-opacity="0.73". Default mode. + *
+ */ + const RGB = 0; + /** + *+ * RGBA mode, example: fill="rgba(255, 85, 17, 0.73)" + *
+ */ + const RGBA = 1; + /** + *+ * HSL mode, example: fill="hsl(17, 100%, 53%)" fill-opacity="0.73" + *
+ */ + const HSL = 2; + /** + *+ * HSLA mode, example: fill="hsla(30, 50%, 70%, 0.8)" + *
+ */ + const HSLA = 3; +} \ No newline at end of file diff --git a/lib/Generation/SvgParameters.php b/lib/Generation/SvgParameters.php new file mode 100644 index 00000000..ae46b219 --- /dev/null +++ b/lib/Generation/SvgParameters.php @@ -0,0 +1,99 @@ +svgParametersDto; + } + + private function setSvgParametersDto(SvgParametersDTO $svgParametersDto): void + { + $this->svgParametersDto = $svgParametersDto; + } + + function __construct(SvgParametersDTO $svgParametersDto) + { + $this->svgParametersDto = $svgParametersDto; + $this->obtainDto(); + $this->initFieldsFromDto(); + } + + public function obtainDto(...$args) + { + } + + public function initFieldsFromDto(): void + { + } + + /** + * Does SVG image contain explicit size in pixels (recommended) + * Default value: true. + */ + function isExplicitSizeInPixels(): bool + { + return $this->getSvgParametersDto()->isExplicitSizeInPixels; + } + + /** + * Does SVG image contain explicit size in pixels (recommended) + * Default value: true. + */ + function setExplicitSizeInPixels(bool $explicitSizeInPixels): void + { + $this->getSvgParametersDto()->isExplicitSizeInPixels = $explicitSizeInPixels; + } + + /** + * Does SVG image contain text as text element rather than paths (recommended) + * Default value: true. + */ + function isTextDrawnInTextElement(): bool + { + return $this->getSvgParametersDto()->isTextDrawnInTextElement; + } + + /** + * Does SVG image contain text as text element rather than paths (recommended) + * Default value: true. + */ + function setTextDrawnInTextElement(bool $isTextDrawnInTextElement): void + { + $this->getSvgParametersDto()->isTextDrawnInTextElement = $isTextDrawnInTextElement; + } + + + /** + *+ * Possible modes for filling color in svg file, RGB is default and supported by SVG 1.1. + * RGBA, HSL, HSLA is allowed in SVG 2.0 standard. + * Even in RGB opacity will be set through "fill-opacity" parameter + *
+ */ + function setSvgColorMode(int $svgColorMode): void + { + $this->getSvgParametersDto()->svgColorMode = $svgColorMode; + } + + + /** + * Possible modes for filling color in svg file, RGB is default and supported by SVG 1.1. + * RGBA, HSL, HSLA is allowed in SVG 2.0 standard. + * Even in RGB opacity will be set through "fill-opacity" parameter + */ + function getSvgColorMode(): int + { + return $this->getSvgParametersDto()->svgColorMode; + } +} \ No newline at end of file diff --git a/lib/Generation/TextAlignment.php b/lib/Generation/TextAlignment.php new file mode 100644 index 00000000..4a5444b2 --- /dev/null +++ b/lib/Generation/TextAlignment.php @@ -0,0 +1,24 @@ +getParameters()->getBarcode()->getGS1CompositeBar()->setLinearComponentType(EncodeTypes::GS1_CODE_128); + * $generator->getParameters()->getBarcode()->getGS1CompositeBar()->setTwoDComponentType(TwoDComponentType::CC_A); + * + * // Aspect ratio of 2D component + * $generator->getParameters()->getBarcode()->getPdf417()->setAspectRatio(3); + * /// + * // X-Dimension of 1D and 2D components + * $generator->getParameters()->getBarcode()->getXDimension()->setPixels(3); + * /// + * // Height of 1D component + * $generator->getParameters()->getBarcode()->getBarHeight()->setPixels(100); + * /// + * $generator->save("test.png", BarcodeImageFormat::PNG); + * @endcode + */ +class TwoDComponentType +{ + /** + * Auto select type of 2D component + */ + const AUTO = 0; + + /** + * CC-A type of 2D component. It is a structural variant of MicroPDF417 + */ + const CC_A = 1; + + /** + * CC-B type of 2D component. It is a MicroPDF417 symbol. + */ + const CC_B = 2; + + /** + * CC-C type of 2D component. It is a PDF417 symbol. + */ + const CC_C = 3; +} \ No newline at end of file diff --git a/lib/Generation/Unit.php b/lib/Generation/Unit.php new file mode 100644 index 00000000..c63fa329 --- /dev/null +++ b/lib/Generation/Unit.php @@ -0,0 +1,247 @@ +getParameters()->getBarcode()->getBarHeight()->setMillimeters(10); + * $generator->save("test.png", BarcodeImageFormat::PNG); + * @endcode + */ +class Unit implements Communicator +{ + private $unitDto; + + function getUnitDto(): UnitDTO + { + return $this->unitDto; + } + + private function setUnitDto(UnitDTO $unitDto): void + { + $this->unitDto = $unitDto; + } + + public function __construct($source) + { + try + { + $this->unitDto = self::initUnit($source); + $this->obtainDto(); + $this->initFieldsFromDto(); + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + static function initUnit($source) + { + if ($source instanceof Unit) + { + return $source->getUnitDto(); + } elseif ($source instanceof UnitDTO) + return $source; + throw new InvalidArgumentException(); + } + + public function obtainDto(...$args) + { + } + + public function initFieldsFromDto(): void + { + // TODO: Implement init() method. + } + + /** + * Gets size value in pixels. + */ + public function getPixels(): float + { + $thriftConnection = new ThriftConnection(); + $client = $thriftConnection->openConnection(); + $pixels = $client->Unit_getPixels($this->getUnitDto()); + $thriftConnection->closeConnection(); + + return $pixels; + } + + /** + * Sets size value in pixels. + */ + public function setPixels(float $value): void + { + try + { + $this->getUnitDto()->units = $value; + $this->getUnitDto()->graphicsUnit = GraphicsUnit::PIXEL; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Gets size value in inches. + */ + public function getInches(): float + { + $thriftConnection = new ThriftConnection(); + $client = $thriftConnection->openConnection(); + $inches = $client->Unit_getInches($this->getUnitDto()); + $thriftConnection->closeConnection(); + + return $inches; + } + + /** + * Sets size value in inches. + */ + public function setInches(float $value): void + { + try + { + $this->getUnitDto()->units = $value; + $this->getUnitDto()->graphicsUnit = GraphicsUnit::INCH; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Gets size value in millimeters. + */ + public function getMillimeters(): float + { + $thriftConnection = new ThriftConnection(); + $client = $thriftConnection->openConnection(); + $millimeters = $client->Unit_getMillimeters($this->getUnitDto()); + $thriftConnection->closeConnection(); + + return $millimeters; + } + + /** + * Sets size value in millimeters. + */ + public function setMillimeters(float $value): void + { + try + { + $this->getUnitDto()->units = $value; + $this->getUnitDto()->graphicsUnit = GraphicsUnit::MILLIMETER; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Gets size value in point. + */ + public function getPoint(): float + { + $thriftConnection = new ThriftConnection(); + $client = $thriftConnection->openConnection(); + $point = $client->Unit_getPoint($this->getUnitDto()); + $thriftConnection->closeConnection(); + + return $point; + } + + /** + * Sets size value in point. + */ + public function setPoint(float $value): void + { + try + { + $this->getUnitDto()->units = $value; + $this->getUnitDto()->graphicsUnit = GraphicsUnit::POINT; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Gets size value in document units. + */ + public function getDocument(): float + { + $thriftConnection = new ThriftConnection(); + $client = $thriftConnection->openConnection(); + $document = $client->Unit_getDocument($this->getUnitDto()); + $thriftConnection->closeConnection(); + + return $document; + } + + /** + * Sets size value in document units. + */ + public function setDocument(float $value): void + { + try + { + $this->getUnitDto()->units = $value; + $this->getUnitDto()->graphicsUnit = GraphicsUnit::DOCUMENT; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Returns a human-readable string representation of this Unit. + * + * @return string that represents this Unit. + */ + public function toString(): string + { + $thriftConnection = new ThriftConnection(); + $client = $thriftConnection->openConnection(); + $str = $client->Unit_toString($this->getUnitDto()); + $thriftConnection->closeConnection(); + + return $str; + } + + /** + * Determines whether this instance and a specified object, + * which must also be a Unit object, have the same value. + * + * @param Unit $obj The Unit to compare to this instance. + * @return true if obj is a Unit and its value is the same as this instance; + * otherwise, false. If obj is null, the method returns false. + */ + public function equals(Unit $obj): bool + { + $thriftConnection = new ThriftConnection(); + $client = $thriftConnection->openConnection(); + $isEquals = $client->Unit_equals($this->getUnitDTO(), $obj->getUnitDTO()); + $thriftConnection->closeConnection(); + + return $isEquals; + } +} \ No newline at end of file diff --git a/lib/Recognition.php b/lib/Recognition.php deleted file mode 100644 index 1f79f553..00000000 --- a/lib/Recognition.php +++ /dev/null @@ -1,4409 +0,0 @@ -readBarCodes() as $result) - * { - * print("BarCode Type: ".$result->getCodeTypeName()); - * print("BarCode CodeText: ".$result->getCodeText()); - * } - * @endcode - */ -class BarCodeReader implements Communicator -{ - private $barCodeReaderDto; - - private function getBarCodeReaderDto(): BarcodeReaderDTO - { - return $this->barCodeReaderDto; - } - - private function setBarCodeReaderDto(BarcodeReaderDTO $barCodeReaderDto): void - { - $this->barCodeReaderDto = $barCodeReaderDto; -// $this->initFieldsFromDto(); - } - - private QualitySettings $qualitySettings; - private BarcodeSettings $barcodeSettings; - private $imageResource; - private $areas; - private $decodeTypes; - - function __construct($imageResource, $areas, $decodeTypes) - { - $this->imageResource = $imageResource; - $this->areas = $areas; - $this->decodeTypes = $decodeTypes; - $this->setBarCodeReaderDto($this->obtainDto()); //TODO redundant ? - $this->initFieldsFromDto(); - } - - public function obtainDto(...$args): BarcodeReaderDTO - { - $thriftConnection = new ThriftConnection(); - $client = $thriftConnection->openConnection(); - $barcodeReaderDTO = $client->BarcodeReader_ctor(); - $thriftConnection->closeConnection(); - return $barcodeReaderDTO; - } - - public function initFieldsFromDto() - { - $this->qualitySettings = new QualitySettings($this->barCodeReaderDto->qualitySettings); - $this->barcodeSettings = new BarcodeSettings($this->barCodeReaderDto->barcodeSettings); - - if ($this->imageResource !== null) { - $this->initializeImageRelatedFields(); - $this->processDecodeTypes(); - } else { - $this->validateNullState(); - } - } - - /** - * Process Image Related Parameters - */ - private function initializeImageRelatedFields(): void - { - $this->barCodeReaderDto->base64Image = CommonUtility::convertImageResourceToBase64($this->imageResource); - $this->barCodeReaderDto->areas = CommonUtility::convertAreasToStringFormattedAreas($this->areas); - } - - /** - * Detect Decode Types - */ - private function processDecodeTypes(): void - { - $decodeTypes = $this->decodeTypes; - if (is_null($decodeTypes)) { - $decodeTypes = [DecodeType::ALL_SUPPORTED_TYPES]; - } elseif (is_int($decodeTypes)) { - $decodeTypes = [$decodeTypes]; - $this->decodeTypes = $decodeTypes; - } elseif (!is_array($decodeTypes)) { - throw new InvalidArgumentException("Invalid type for decodeTypes. Expected int, array, or null, got " . gettype($decodeTypes)); - } - - if (CommonUtility::isClassContainsConstantValueFromArray(DecodeType::class, $decodeTypes)) { - $this->barCodeReaderDto->barCodeDecodeTypes = $decodeTypes; - } - } - - /** - * Ensures that when an image is missing, other parameters are also absent. - * - * @throws BarcodeException - */ - private function validateNullState(): void - { - if ($this->areas !== null || $this->decodeTypes !== null) { - throw new BarcodeException('Illegal arguments. If $imageResource = null then $areas and $decodeTypes should be null'); - } - } - - - /** - * Determines whether any of the given decode types is included into - * @param array $decodeTypes Types to verify. - * @return bool Value is a true if any types are included into. - */ - public function containsAny(...$decodeTypes): bool - { - try { - foreach ($decodeTypes as $decodeType) { - if (DecodeType::containsAny($decodeType, $this->getBarCodeReaderDto()->barCodeDecodeTypes)) - return true; - } - return false; - } catch (Exception $ex) { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - - protected function init(): void - { - $this->qualitySettings = new QualitySettings($this->barCodeReaderDto->qualitySettings); - $this->barcodeSettings = new BarcodeSettings($this->barCodeReaderDto->qualitySettings); - } - - /** - * Reads BarCodeResult from the image. - * - * @code - * This sample shows how to read barcodes with BarCodeReader - * $reader = new BarCodeReader("test.png", null, array(DecodeType::CODE_39, DecodeType::CODE_128)); - * foreach($reader->readBarCodes() as $result) - * print("BarCode CodeText: ".$result->getCodeText()); - * $reader = new BarCodeReader("test.png", null, array(DecodeType::CODE_39, DecodeType::CODE_128)); - * $reader->readBarCodes(); - * for($i = 0; $reader->getFoundCount() > $i; ++$i) - * print("BarCode CodeText: ".$reader->getFoundBarCodes()[i]->getCodeText()); - * - * @return array of recognized {@code BarCodeResult}s on the image. If nothing is recognized, zero array is returned. - * @throws BarcodeException - */ - public function readBarCodes(bool $passLicense = false): array - { - try { - $thriftConnection = new ThriftConnection(); - $client = $thriftConnection->openConnection(); - // Deciding if the license should be used - $licenseContent = $passLicense ? License::getLicenseContent() : null; - // Passing the license or null - $barcodeReaderDTO = $client->BarcodeReader_readBarCodes($this->barCodeReaderDto, $licenseContent); - $this->setBarCodeReaderDto($barcodeReaderDTO); - $thriftConnection->closeConnection(); - } catch (Exception $exc) { - CommonUtility::println($exc->getMessage()); - CommonUtility::println("Stack trace: " . $exc->getTraceAsString()); - //TODO BARCODEPHP-919 Make fixes and improvements in exception handling on the Java and PHP sides - throw CommonUtility::convertBarcodeExceptionDto($exc); - } - return $this->getFoundBarCodes(); - } - - /** - * Gets recognized BarCodeResult array - * - * This sample shows how to read barcodes with BarCodeReader - * @code - * $reader = new BarCodeReader("test.png", DecodeType::CODE_39, DecodeType::CODE_128); - * $reader->readBarCodes(); - * for($i = 0; $reader->getFoundCount() > $i; ++$i) - * { - * print("BarCode CodeText: ". $reader->getFoundBarCodes()[$i]->getCodeText()); - * } - * @endcode - * Value: The recognized BarCodeResult array - */ - function getFoundBarCodes(): array - { - // TODO Implement not recognized behavior - $recognizedResults = array(); - $dtoRef = $this->barCodeReaderDto; - foreach ($dtoRef->foundBarCodes as $foundBarcode) { - $recognizedResults[] = new BarCodeResult($foundBarcode); - } - - return $recognizedResults; - } - - /** - * Gets the timeout of recognition process in milliseconds. - * - * @code - * $reader = new BarCodeReader("test.png"); - * $reader->setTimeout(5000); - * foreach($reader->readBarCodes() as $result) - * print("BarCode CodeText: ".$result->getCodeText()); - * @endcode - * @return int timeout. - */ - public function getTimeout(): int - { - return $this->barCodeReaderDto->timeout; - } - - /** - * Sets the timeout of recognition process in milliseconds. - * - * @code - * $reader = new BarCodeReader("test.png"); - * $reader->setTimeout(5000); - * foreach($reader->readBarCodes() as $result) - * print("BarCode CodeText: ".$result->getCodeText()); - * @endcode - * @param int $value The timeout. - */ - public function setTimeout(int $value): void - { - $this->barCodeReaderDto->timeout = $value; - } - - /** - * Gets recognized barcodes count - * - * This sample shows how to read barcodes with BarCodeReader - * @code - * $reader = new BarCodeReader("test.png", null, DecodeType::CODE_39, DecodeType::CODE_128); - * $reader->readBarCodes(); - * for($i = 0; $reader->getFoundCount() > $i; ++$i) - * print("BarCode CodeText: ".$reader->getFoundBarCodes()[i]->getCodeText()); - * @endcode - * Value: The recognized barcodes count - */ - public function getFoundCount(): int - { - return sizeof($this->getFoundBarCodes()); - } - - /** - * QualitySettings allows to configure recognition quality and speed manually. - * You can quickly set up QualitySettings by embedded presets: HighPerformance, NormalQuality, - * HighQuality, MaxBarCodes or you can manually configure separate options. - * Default value of QualitySettings is NormalQuality. - * @code - * This sample shows how to use QualitySettings with BarCodeReader - * - * $reader = new BarCodeReader("test.png"); - * //set high performance mode - * $reader->setQualitySettings(QualitySettings::getHighPerformance()); - * foreach($reader->readBarCodes() as $result) - * print("BarCode CodeText: ".$result->getCodeText()); - * $reader = new BarCodeReader("test.png", null, array(DecodeType::CODE_39, DecodeType::CODE_128)); - * //normal quality mode is set by default - * foreach($reader->readBarCodes() as $result) - * print("BarCode CodeText: ".$result->getCodeText()); - * $reader = new BarCodeReader("test.png", null, array(DecodeType::CODE_39, DecodeType::CODE_128)); - * //set high performance mode - * $reader->setQualitySettings(QualitySettings::getHighPerformance()); - * //set separate options - * foreach($reader->readBarCodes() as $result) - * print("BarCode CodeText: ".$result->getCodeText()); - * - * @return QualitySettings to configure recognition quality and speed. - */ - public final function getQualitySettings(): QualitySettings - { - return $this->qualitySettings; - } - - /** - * QualitySettings allows to configure recognition quality and speed manually. - * You can quickly set up QualitySettings by embedded presets: HighPerformance, NormalQuality, - * HighQuality, MaxBarCodes or you can manually configure separate options. - * Default value of QualitySettings is NormalQuality. - * @code - * This sample shows how to use QualitySettings with BarCodeReader - * - * $reader = new BarCodeReader("test.png"); - * //set high performance mode - * $reader->setQualitySettings(QualitySettings::getHighPerformance()); - * foreach($reader->readBarCodes() as $result) - * print("BarCode CodeText: ".$result->getCodeText()); - * $reader = new BarCodeReader("test.png", null, array(DecodeType::CODE_39, DecodeType::CODE_128)); - * //normal quality mode is set by default - * foreach($reader->readBarCodes() as $result) - * print("BarCode CodeText: ".$result->getCodeText()); - * $reader = new BarCodeReader("test.png", null, array(DecodeType::CODE_39, DecodeType::CODE_128)); - * //set high performance mode - * $reader->setQualitySettings(QualitySettings::getHighPerformance()); - * //set separate options - * foreach($reader->readBarCodes() as $result) - * print("BarCode CodeText: ".$result->getCodeText()); - * - * @param QualitySettings $qualitySettings - */ - public function setQualitySettings(QualitySettings $qualitySettings): void - { - $this->barCodeReaderDto->qualitySettings = $qualitySettings->getQualitySettingsDTO(); - $this->qualitySettings = new QualitySettings($this->barCodeReaderDto->qualitySettings); - } - - /** - * The main BarCode decoding parameters. Contains parameters which make influence on recognized data. - * @return BarcodeSettings BarCode decoding parameters - */ - public function getBarcodeSettings(): BarcodeSettings - { - return $this->barcodeSettings; - } - - /** - * Sets bitmap image and areas for recognition. - * Must be called before ReadBarCodes() method. - * - * This sample shows how to detect Code39 and Code128 barcodes. - * @code - * $bmp = "test.png"; - * $reader = new BarCodeReader(); - * $reader->setBarCodeReadType(array(DecodeType::CODE_39, DecodeType::CODE_128)); - * $width, $height; - * list($width, $height) = getimagesize('path_to_image') - * $reader->setBarCodeImage($bmp, new Rectangle[] { new Rectangle(0, 0, $width, $height) }); - * foreach($reader->readBarCodes() as $result) - * { - * print("BarCode Type: ".$result->getCodeTypeName()); - * print("BarCode CodeText: ".$result->getCodeText()); - * } - * @endcode - * @param $imageResource - * @param Rectangle|null ...$areas areas list for recognition - * @throws BarcodeException - */ - public final function setBarCodeImage($imageResource, ?Rectangle ...$areas): void - { - try { - $this->barCodeReaderDto->base64Image = CommonUtility::convertImageResourceToBase64($imageResource); - $this->barCodeReaderDto->areas = CommonUtility::convertAreasToStringFormattedAreas($areas); - if(is_null($this->barCodeReaderDto->barCodeDecodeTypes) || sizeof($this->barCodeReaderDto->barCodeDecodeTypes) == 0) - $this->barCodeReaderDto->barCodeDecodeTypes = array(DecodeType::ALL_SUPPORTED_TYPES); - } catch (Exception $ex) { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - /** - * Sets SingleDecodeType type array for recognition. - * Must be called before readBarCodes() method. - * - * This sample shows how to detect Code39 and Code128 barcodes. - * - * @code - * $reader = new BarCodeReader(); - * $reader->setBarCodeReadType(DecodeType::CODE_39_STANDARD, DecodeType::CODE_128); - * $reader->setBarCodeImage("test.png"); - * foreach($reader->readBarCodes() as $result) - * { - * print("BarCode Type: ".$result->getCodeTypeName()); - * print("BarCode CodeText: ".$result->getCodeText()); - * } - * @endcode - * - * @param array $types The SingleDecodeType type array to read. - */ - public function setBarCodeReadType(int ...$types): void - { - foreach ($types as $type) - if (!is_int($type)) { - throw new TypeError("Argument 1 passed to BarCodeReader::setBarCodeReadType() must be of the type int"); - } - $this->barCodeReaderDto->barCodeDecodeTypes = $types; - } - - public function getBarCodeDecodeType() : array - { - return $this->decodeTypes; - } - - /** - * Exports BarCode properties to the xml-file specified - * @param string $xmlFile The path to xml file - * @return bool Whether or not export completed successfully. - * Returns True in case of success; False Otherwise - */ - public function exportToXml(string $xmlFile): bool - { - try - { - $thriftConnection = new ThriftConnection(); - $client = $thriftConnection->openConnection(); - //TODO BARCODEPHP-677 Implement the passing of license file content from PHP to Java - $xmlData = $client->BarcodeReader_exportToXml($this->barCodeReaderDto); - $thriftConnection->closeConnection(); - $isContentExported = $xmlData != null; - if ($isContentExported) - { - file_put_contents($xmlFile, $xmlData); - } - return $isContentExported; - } - catch (Exception $ex) - { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - /** - * Import BarCode properties from xml file - * @param string $resource The name of the xml file or path to http resource - * @return BarCodeReader - * @throws BarcodeException - */ - public static function importFromXml(string $resource): BarCodeReader - { - try - { - if (CommonUtility::isPath($resource)) - { - $resource = fopen($resource, "r"); - } - $xmlData = (stream_get_contents($resource)); - $offset = 6; - $xmlData = substr($xmlData, $offset, strlen($xmlData) - $offset); - $thriftConnection = new ThriftConnection(); - $client = $thriftConnection->openConnection(); - - $barCodeReaderDto = $client->BarcodeReader_importFromXml($xmlData); - $thriftConnection->closeConnection(); - - return BarCodeReader::construct($barCodeReaderDto); - } - catch (Exception $ex) - { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - private static function construct(BarcodeReaderDTO $barCodeReaderDto): BarCodeReader - { - $barcodeReader = new BarCodeReader(null, null, null); - $barcodeReader->setBarCodeReaderDto($barCodeReaderDto); - return $barcodeReader; - } -} - - -/** - * The main BarCode decoding parameters. Contains parameters which make influence on recognized data. - */ -class BarcodeSettings implements Communicator -{ - - private BarcodeSettingsDTO $barcodeSettingsDto; - - private function getBarcodeSettingsDto(): BarcodeSettingsDTO - { - return $this->barcodeSettingsDto; - } - - private function setBarcodeSettingsDto(BarcodeSettingsDTO $barcodeSettingsDto): void - { - $this->barcodeSettingsDto = $barcodeSettingsDto; - $this->initFieldsFromDto(); - } - - private AustraliaPostSettings $_australiaPost; - - /** - * BarcodeSettings copy constructor - * @param BarcodeSettingsDTO $barcodeSettingsDto - */ - function __construct(BarcodeSettingsDTO $barcodeSettingsDto) - { - $this->barcodeSettingsDto = $barcodeSettingsDto; - $this->obtainDto(); - $this->initFieldsFromDto(); - } - - public function obtainDto(...$args) - { - } - - public function initFieldsFromDto(): void - { - $this->_australiaPost = new AustraliaPostSettings($this->getBarcodeSettingsDto()->australiaPost); - } - - /** - * Enable checksum validation during recognition for 1D and Postal barcodes. - * Default is treated as Yes for symbologies which must contain checksum, as No where checksum only possible. - * Checksum never used: Codabar, PatchCode, Pharmacode, DataLogic2of5 - * Checksum is possible: Code39 Standard/Extended, Standard2of5, Interleaved2of5, ItalianPost25, Matrix2of5, MSI, ItalianPost25, DeutschePostIdentcode, DeutschePostLeitcode, VIN - * Checksum always used: Rest symbologies - * - * @code - * - * $generator = new BarcodeGenerator(EncodeTypes::EAN_13, "1234567890128"); - * $generator->save("c:/test.png", BarcodeImageFormat::PNG); - * $reader = new BarCodeReader("c:/test.png", null, DecodeType::EAN_13); - * //checksum disabled - * $reader->getBarcodeSettings()->setChecksumValidation(ChecksumValidation::OFF); - * foreach($reader->readBarCodes() as $result) - * { - * echo ("BarCode CodeText: ".$result->getCodeText()); - * echo ("BarCode Value: " . $result->getExtended()->getOneD()->getValue()); - * echo ("BarCode Checksum: " . $result->getExtended()->getOneD()->getCheckSum()); - * } - * $reader = new BarCodeReader("c:\\test.png", null, DecodeType::EAN_13); - * //checksum enabled - * $reader->getBarcodeSettings()->setChecksumValidation(ChecksumValidation::ON); - * foreach($reader->readBarCodes() as $result) - * { - * echo ("BarCode CodeText: " . $result->CodeText); - * echo ("BarCode Value: " . $result->getExtended()->getOneD()->getValue()); - * echo ("BarCode Checksum: " . $result->getExtended()->getOneD()->getCheckSum()); - * } - * @endcode - * @return int Enable checksum validation during recognition for 1D and Postal barcodes. - */ - public function getChecksumValidation(): int - { - return $this->getBarcodeSettingsDto()->checksumValidation; - } - - /** - * Enable checksum validation during recognition for 1D and Postal barcodes. - * Default is treated as Yes for symbologies which must contain checksum, as No where checksum only possible. - * Checksum never used: Codabar, PatchCode, Pharmacode, DataLogic2of5 - * Checksum is possible: Code39 Standard/Extended, Standard2of5, Interleaved2of5, ItalianPost25, Matrix2of5, MSI, ItalianPost25, DeutschePostIdentcode, DeutschePostLeitcode, VIN - * Checksum always used: Rest symbologies - * - * @code - * - * $generator = new BarcodeGenerator(EncodeTypes::EAN_13, "1234567890128"); - * $generator->save("c:/test.png", BarcodeImageFormat::PNG); - * $reader = new BarCodeReader("c:/test.png", DecodeType::EAN_13); - * //checksum disabled - * $reader->getBarcodeSettings()->setChecksumValidation(ChecksumValidation::OFF); - * foreach($reader->readBarCodes() as $result) - * { - * echo ("BarCode CodeText: ".$result->getCodeText()); - * echo ("BarCode Value: " . $result->getExtended()->getOneD()->getValue()); - * echo ("BarCode Checksum: " . $result->getExtended()->getOneD()->getCheckSum()); - * } - * $reader = new BarCodeReader(@"c:\test.png", DecodeType::EAN_13); - * //checksum enabled - * $reader->getBarcodeSettings()->setChecksumValidation(ChecksumValidation::ON); - * foreach($reader->readBarCodes() as $result) - * { - * echo ("BarCode CodeText: " . $result->CodeText); - * echo ("BarCode Value: " . $result->getExtended()->getOneD()->getValue()); - * echo ("BarCode Checksum: " . $result->getExtended()->getOneD()->getCheckSum()); - * } - * @endcode - * @param int $value Enable checksum validation during recognition for 1D and Postal barcodes. - */ - public function setChecksumValidation(int $value): void - { - $this->getBarcodeSettingsDto()->checksumValidation = ($value); - } - - /** - * Strip FNC1, FNC2, FNC3 characters from codetext. Default value is false. - * - * @code - * - * $generator = new BarcodeGenerator(EncodeTypes::GS_1_CODE_128, "(02)04006664241007(37)1(400)7019590754"); - * $generator->save("c:/test.png", BarcodeImageFormat::PNG); - * $reader = new BarCodeReader("c:/test.png", DecodeType::CODE_128); - * - * //StripFNC disabled - * $reader->getBarcodeSettings()->setStripFNC(false); - * foreach($reader->readBarCodes() as $result) - * { - * echo ("BarCode CodeText: ".$result->getCodeText()); - * } - * - * $reader = new BarCodeReader("c:/test.png", DecodeType::CODE_128); - * - * //StripFNC enabled - * $reader->getBarcodeSettings()->setStripFNC(true); - * foreach($reader->readBarCodes() as $result) - * { - * echo ("BarCode CodeText: ".$result->getCodeText()); - * } - * @endcode - * - * @return bool Strip FNC1, FNC2, FNC3 characters from codetext. Default value is false. - */ - public function getStripFNC(): bool - { - return $this->getBarcodeSettingsDto()->stripFNC; - } - - /** - * Strip FNC1, FNC2, FNC3 characters from codetext. Default value is false. - * - * @code - * - * $generator = new BarcodeGenerator(EncodeTypes::GS_1_CODE_128, "(02)04006664241007(37)1(400)7019590754"); - * $generator->save("c:/test.png", BarcodeImageFormat::PNG); - * $reader = new BarCodeReader("c:/test.png", DecodeType::CODE_128); - * - * //StripFNC disabled - * $reader->getBarcodeSettings()->setStripFNC(false); - * foreach($reader->readBarCodes() as $result) - * { - * echo ("BarCode CodeText: ".$result->getCodeText()); - * } - * - * $reader = new BarCodeReader("c:/test.png", DecodeType::CODE_128); - * - * //StripFNC enabled - * $reader->getBarcodeSettings()->setStripFNC(true); - * foreach($reader->readBarCodes() as $result) - * { - * echo ("BarCode CodeText: ".$result->getCodeText()); - * } - * @endcode - * - * @param bool $value Strip FNC1, FNC2, FNC3 characters from codetext. Default value is false. - */ - public function setStripFNC(bool $value): void - { - $this->getBarcodeSettingsDto()->stripFNC = $value; - } - - /** - * The flag which force engine to detect codetext encoding for Unicode codesets. Default value is true. - * - * @code - * - * $generator = new BarcodeGenerator(EncodeTypes::QR, "Слово")) - * $im = $generator->generateBarcodeImage(BarcodeImageFormat::PNG); - * - * //detects encoding for Unicode codesets is enabled - * $reader = new BarCodeReader($im, DecodeType::QR); - * $reader->getBarcodeSettings()->setDetectEncoding(true); - * foreach($reader->readBarCodes() as $result) - * echo ("BarCode CodeText: ".$result->getCodeText()); - * - * //detect encoding is disabled - * $reader = new BarCodeReader($im, DecodeType::QR); - * $reader->getBarcodeSettings()->setDetectEncoding(false); - * foreach($reader->readBarCodes() as $result) - * echo ("BarCode CodeText: ".$result->getCodeText()); - * @endcode - * - * @return bool The flag which force engine to detect codetext encoding for Unicode codesets - */ - public function getDetectEncoding(): bool - { - return $this->getBarcodeSettingsDto()->detectEncoding; - } - - public function setDetectEncoding(bool $value): void - { - $this->getBarcodeSettingsDto()->detectEncoding = $value; - } - - /** - * Gets AustraliaPost decoding parameters - * @return AustraliaPostSettings The AustraliaPost decoding parameters which make influence on recognized data of AustraliaPost symbology - */ - public function getAustraliaPost(): AustraliaPostSettings - { - return $this->_australiaPost; - } -} - -/** - * AustraliaPost decoding parameters. Contains parameters which make influence on recognized data of AustraliaPost symbology. - */ -class AustraliaPostSettings implements Communicator -{ - - private AustraliaPostSettingsDTO $australiaPostSettingsDto; - - private function getAustraliaPostSettingsDto(): AustraliaPostSettingsDTO - { - return $this->australiaPostSettingsDto; - } - - private function setAustraliaPostSettingsDto(AustraliaPostSettingsDTO $australiaPostSettingsDto): void - { - $this->australiaPostSettingsDto = $australiaPostSettingsDto; - } - - /** - * AustraliaPostSettings constructor - */ - function __construct(AustraliaPostSettingsDTO $australiaPostSettingsDto) - { - $this->australiaPostSettingsDto = $australiaPostSettingsDto; - $this->obtainDto(); - $this->initFieldsFromDto(); - } - - public function initFieldsFromDto(): void - { - } - - public function obtainDto(...$args) - { - } - - /** - * Gets or sets the Interpreting Type for the Customer Information of AustralianPost BarCode.DEFAULT is CustomerInformationInterpretingType.OTHER. - * @return int The interpreting type (CTable, NTable or Other) of customer information for AustralianPost BarCode - */ - public function getCustomerInformationInterpretingType(): int - { - return $this->getAustraliaPostSettingsDto()->customerInformationInterpretingType; - } - - /** - * Gets or sets the Interpreting Type for the Customer Information of AustralianPost BarCode.DEFAULT is CustomerInformationInterpretingType.OTHER. - * @param int $value The interpreting type (CTable, NTable or Other) of customer information for AustralianPost BarCode - */ - public function setCustomerInformationInterpretingType(int $value): void - { - $this->getAustraliaPostSettingsDto()->customerInformationInterpretingType = $value; - } - - /** - * The flag which force AustraliaPost decoder to ignore last filling patterns in Customer Information Field during decoding as CTable method. - * CTable encoding method does not have any gaps in encoding table and sequnce "333" of filling paterns is decoded as letter "z". - * - * @code - * - * $generator = new BarcodeGenerator(EncodeTypes::AUSTRALIA_POST, "5912345678AB"); - * $generator->getParameters()->getBarcode()->getAustralianPost()->setAustralianPostEncodingTable(CustomerInformationInterpretingType::C_TABLE); - * $image = generator->generateBarCodeImage(BarcodeImageFormat::PNG); - * $reader = new BarCodeReader($image, null, DecodeType::AUSTRALIA_POST); - * $reader->getBarcodeSettings()->getAustraliaPost()->setCustomerInformationInterpretingType(CustomerInformationInterpretingType::C_TABLE); - * $reader->getBarcodeSettings()->getAustraliaPost()->setIgnoreEndingFillingPatternsForCTable(true); - * foreach($reader->readBarCodes() as $result) - * echo("BarCode Type: ".$result->getCodeType()); - * echo("BarCode CodeText: ".$result->getCodeText()); - * } - * @endcode - * - * @return bool The flag which force AustraliaPost decoder to ignore last filling patterns during CTable method decoding - */ - public function getIgnoreEndingFillingPatternsForCTable(): bool - { - return $this->getAustraliaPostSettingsDto()->ignoreEndingFillingPatternsForCTable; - } - - /** - * The flag which force AustraliaPost decoder to ignore last filling patterns in Customer Information Field during decoding as CTable method. - * CTable encoding method does not have any gaps in encoding table and sequnce "333" of filling paterns is decoded as letter "z". - * - * @code - * - * $generator = new BarcodeGenerator(EncodeTypes::AUSTRALIA_POST, "5912345678AB"); - * $generator->getParameters()->getBarcode()->getAustralianPost()->setAustralianPostEncodingTable(CustomerInformationInterpretingType::C_TABLE); - * $image = generator->generateBarCodeImage(BarcodeImageFormat::PNG); - * $reader = new BarCodeReader($image, null, DecodeType::AUSTRALIA_POST); - * $reader->getBarcodeSettings()->getAustraliaPost()->setCustomerInformationInterpretingType(CustomerInformationInterpretingType::C_TABLE); - * $reader->getBarcodeSettings()->getAustraliaPost()->setIgnoreEndingFillingPatternsForCTable(true); - * foreach($reader->readBarCodes() as $result) - * echo("BarCode Type: ".$result->getCodeType()); - * echo("BarCode CodeText: ".$result->getCodeText()); - * } - * @endcode - * - * @param bool $value The flag which force AustraliaPost decoder to ignore last filling patterns during CTable method decoding - */ - public function setIgnoreEndingFillingPatternsForCTable(bool $value): void - { - $this->getAustraliaPostSettingsDto()->ignoreEndingFillingPatternsForCTable = $value; - } -} - -/** - * QualitySettings allows to configure recognition quality and speed manually. - * You can quickly set up QualitySettings by embedded presets: HighPerformance, NormalQuality, - * HighQuality, MaxBarCodes or you can manually configure separate options. - * Default value of QualitySettings is NormalQuality. - * - * This sample shows how to use QualitySettings with BarCodeReader - * @code - * $reader = new BarCodeReader("test.png", null, array(DecodeType::CODE_39, DecodeType::CODE_128)); - * //set high performance mode - * $reader->setQualitySettings(QualitySettings::getHighPerformance()); - * foreach($reader->readBarCodes() as $result) - * print("BarCode CodeText: ".$result->getCodeText()); - * $reader = new BarCodeReader("test.png", null, array(DecodeType::CODE_39, DecodeType::CODE_128)); - * //normal quality mode is set by default - * foreach($reader->readBarCodes() as $result) - * print("BarCode CodeText: ".$result->getCodeText()); - * $reader = new BarCodeReader("test.png", null, array(DecodeType::CODE_39, DecodeType::CODE_128)); - * //set high quality mode with low speed recognition - * $reader->setQualitySettings(QualitySettings::getHighQuality()); - * foreach($reader->readBarCodes() as $result) - * print("BarCode CodeText: ".$result->getCodeText()); - * $reader = new BarCodeReader("test.png", null, array(DecodeType::CODE_39, DecodeType::CODE_128)); - * //set max barcodes mode, which tries to find all possible barcodes, even incorrect. The slowest recognition mode - * $reader->setQualitySettings(QualitySettings::getMaxBarCodes()); - * foreach($reader->readBarCodes() as $result) - * print("BarCode CodeText: ".$result->getCodeText()); - * $reader = new BarCodeReader("test.png", null, array(DecodeType::CODE_39, DecodeType::CODE_128)); - * //set high performance mode - * $reader->setQualitySettings(QualitySettings::getHighPerformance()); - * //set separate options - * foreach($reader->readBarCodes() as $result) - * print("BarCode CodeText: ".$result->getCodeText()); - * $reader = new BarCodeReader("test.png", null, array(DecodeType::CODE_39, DecodeType::CODE_128)); - * //default mode is NormalQuality - * //set separate options - * foreach($reader->readBarCodes() as $result) - * print("BarCode CodeText: ".$result->getCodeText()); - * @endcode - */ -final class QualitySettings implements Communicator -{ - private QualitySettingsDTO $qualitySettingsDTO; - - /** - * @return QualitySettingsDTO instance - */ - function getQualitySettingsDTO() : QualitySettingsDTO - { - return $this->qualitySettingsDTO; - } - - /** - * @param $qualitySettingsDTO QualitySettingsDTO instance - */ - private function setQualitySettingsDTO(QualitySettingsDTO $qualitySettingsDTO): void - { - $this->qualitySettingsDTO = $qualitySettingsDTO; - $this->initFieldsFromDto(); - } - - function __construct(QualitySettingsDTO $qualitySettingsDTO) - { - $this->qualitySettingsDTO = $qualitySettingsDTO; - $this->obtainDto(); - $this->initFieldsFromDto(); - } - - public function obtainDto(...$args) - { - } - - public function initFieldsFromDto() - { - } - - /** - * HighPerformance recognition quality preset. High quality barcodes are recognized well in this mode. - * - * @code - * $reader = new BarCodeReader("test.png"); - * $reader->setQualitySettings(QualitySettings::getHighPerformance()); - * @return QualitySettings HighPerformance recognition quality preset. - * @endcode - * @throws BarcodeException - */ - public static function getHighPerformance(): QualitySettings - { - try { - $thriftConnection = new ThriftConnection(); - $client = $thriftConnection->openConnection(); - $qualitySettingsDTO = $client->QualitySettings_getHighPerformance(); - $thriftConnection->closeConnection(); - return new QualitySettings($qualitySettingsDTO); - } catch (Exception $ex) { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - /** - * NormalQuality recognition quality preset. Suitable for the most of barcodes - * - * @code - * $reader = new BarCodeReader("test.png"); - * $reader->setQualitySettings(QualitySettings::getNormalQuality()); - * @endcode - * - * @return QualitySettings NormalQuality recognition quality preset. - * @throws BarcodeException - */ - public static function getNormalQuality(): QualitySettings - { - try { - $thriftConnection = new ThriftConnection(); - $client = $thriftConnection->openConnection(); - $qualitySettingsDTO = $client->QualitySettings_getNormalQuality(); - $thriftConnection->closeConnection(); - return new QualitySettings($qualitySettingsDTO); - } catch (Exception $ex) { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - /** - * HighQuality recognition quality preset. This preset is developed for low quality barcodes. - * - * @code - * $reader = new BarCodeReader("test.png"); - * $reader->setQualitySettings(QualitySettings::getHighQuality()); - * @endcode - * @return QualitySettings HighQuality recognition quality preset. - * @throws BarcodeException - */ - public static function getHighQuality(): QualitySettings - { - try { - $thriftConnection = new ThriftConnection(); - $client = $thriftConnection->openConnection(); - $qualitySettingsDTO = $client->QualitySettings_getHighQuality(); - $thriftConnection->closeConnection(); - return new QualitySettings($qualitySettingsDTO); - } catch (Exception $ex) { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - /** - *- * MaxQuality recognition quality preset. This preset is developed to recognize all possible barcodes, even incorrect barcodes. - *
Value: - * MaxQuality recognition quality preset. - * - */ - public static function getMaxQuality(): QualitySettings - { - try { - $thriftConnection = new ThriftConnection(); - $client = $thriftConnection->openConnection(); - $qualitySettingsDTO = $client->QualitySettings_getMaxQuality(); - $thriftConnection->closeConnection(); - return new QualitySettings($qualitySettingsDTO); - } catch (Exception $ex) { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - /** - * Recognition mode which sets size (from 1 to infinity) of barcode minimal element: matrix cell or bar. - * @return int : size (from 1 to infinity) of barcode minimal element: matrix cell or bar. - */ - public function getXDimension(): int - { - return $this->qualitySettingsDTO->xDimension; - } - - /** - * Recognition mode which sets size (from 1 to infinity) of barcode minimal element: matrix cell or bar. - * @param int : size (from 1 to infinity) of barcode minimal element: matrix cell or bar. - */ - public function setXDimension(int $value): void - { - $this->qualitySettingsDTO->xDimension = $value; - } - - /** - * Minimal size of XDimension in pixels which is used with UseMinimalXDimension. - * @return float : Minimal size of XDimension in pixels which is used with UseMinimalXDimension. - */ - public function getMinimalXDimension(): float - { - return $this->qualitySettingsDTO->minimalXDimension; - } - - /** - * Minimal size of XDimension in pixels which is used with UseMinimalXDimension. - * @param $value : Minimal size of XDimension in pixels which is used with UseMinimalXDimension. - */ - public function setMinimalXDimension(float $value): void - { - $this->qualitySettingsDTO->minimalXDimension = $value; - } - - /** - *- * This sample shows how to use MaxQuality mode - *- * - * $reader = new BarCodeReader("test.png"null, null, array(DecodeType::CODE_39_FULL_ASCII, DecodeType::CODE_128)); - * { - * $reader->setQualitySettings(QualitySettings::getMaxQuality()); - * foreach($reader->readBarCodes() as $result) - * echo ($result->getCodeText()); - * } - *- *- * Mode which enables methods to recognize barcode elements with the selected quality. Barcode element with lower quality requires more hard methods which slows the recognition. - * @return int : Mode which enables methods to recognize barcode elements with the selected quality. - */ - public function getBarcodeQuality(): int - { - return $this->qualitySettingsDTO->barcodeQuality; - } - - /** - * Mode which enables methods to recognize barcode elements with the selected quality. Barcode element with lower quality requires more hard methods which slows the recognition. - * @param $value : Mode which enables methods to recognize barcode elements with the selected quality. - */ - public function setBarcodeQuality(int $value): void - { - $this->qualitySettingsDTO->barcodeQuality = $value; - } - - /** - *
- * Deconvolution (image restorations) mode which defines level of image degradation. Originally deconvolution is a function which can restore image degraded - * (convoluted) by any natural function like blur, during obtaining image by camera. Because we cannot detect image function which corrupt the image, - * we have to check most well know functions like sharp or mathematical morphology. - * @return int : Deconvolution mode which defines level of image degradation. - */ - public function getDeconvolution(): int - { - return $this->qualitySettingsDTO->deconvolution; - } - - /** - * Deconvolution (image restorations) mode which defines level of image degradation. Originally deconvolution is a function which can restore image degraded - * (convoluted) by any natural function like blur, during obtaining image by camera. Because we cannot detect image function which corrupt the image, - * we have to check most well know functions like sharp or mathematical morphology. - * @param $value : Deconvolution mode which defines level of image degradation. - */ - public function setDeconvolution(int $value): void - { - $this->qualitySettingsDTO->deconvolution = $value; - } - - /** - * Mode which enables or disables additional recognition of barcodes on images with inverted colors (luminance). - * @return int : Additional recognition of barcodes on images with inverse colors - */ - public function getInverseImage(): int - { - return $this->qualitySettingsDTO->inverseImage; - } - - /** - * Mode which enables or disables additional recognition of barcodes on images with inverted colors (luminance). - * @param $value : Additional recognition of barcodes on images with inverse colors - */ - public function setInverseImage(int $value): void - { - $this->qualitySettingsDTO->inverseImage = $value; - } - - /** - *
- * Mode which enables or disables additional recognition of color barcodes on color images. - * @return int : Additional recognition of color barcodes on color images. - */ - public function getComplexBackground(): int - { - return $this->qualitySettingsDTO->complexBackground; - } - - /** - * Mode which enables or disables additional recognition of color barcodes on color images. - * @param $value : Additional recognition of color barcodes on color images. - */ - public function setComplexBackground(int $value): void - { - $this->qualitySettingsDTO->complexBackground = $value; - } - - /** - * Allows engine to recognize barcodes which has incorrect checksumm or incorrect values. Mode can be used to recognize damaged barcodes with incorrect text. - * @return bool : Allows engine to recognize incorrect barcodes. - */ - public function getAllowIncorrectBarcodes(): bool - { - return $this->qualitySettingsDTO->allowIncorrectBarcodes; - } - - /** - * Allows engine to recognize barcodes which has incorrect checksumm or incorrect values. Mode can be used to recognize damaged barcodes with incorrect text. - * @param $value : Allows engine to recognize incorrect barcodes. - */ - public function setAllowIncorrectBarcodes(bool $value): void - { - $this->qualitySettingsDTO->allowIncorrectBarcodes = $value; - } -} - - -/** - * Stores recognized barcode data like SingleDecodeType type, {string} codetext, - * BarCodeRegionParameters region and other parameters - * - * This sample shows how to obtain BarCodeResult. - * @code - * $generator = new BarcodeGenerator(EncodeTypes::Code128, "12345"); - * $generator->save("test.png"); - * $reader = new BarCodeReader("test.png", DecodeType::CODE_39, DecodeType::CODE_128); - * foreach($reader->readBarCodes() as $result) - * { - * print("BarCode Type: ".$result->getCodeTypeName()); - * print("BarCode CodeText: ".$result->getCodeText()); - * print("BarCode Confidence: ".$result->getConfidence()); - * print("BarCode ReadingQuality: ".$result->getReadingQuality()); - * print("BarCode Angle: ".$result->getRegion()->getAngle()); - * } - * @endcode - */ -class BarCodeResult implements Communicator -{ - private BarCodeRegionParameters $region; - private BarCodeExtendedParameters $extended; - private BarCodeResultDTO $barCodeResultDTO; - - /** - * @return BarCodeResultDTO instance - */ - private function getBarCodeResultDTO() : BarCodeResultDTO - { - return $this->barCodeResultDTO; - } - - /** - * @param $barCodeResultDTO - */ - private function setBarCodeResultDTO($barCodeResultDTO): void - { - $this->barCodeResultDTO = $barCodeResultDTO; - } - - function __construct(BarCodeResultDTO $barCodeResultDTO) - { - $this->barCodeResultDTO = $barCodeResultDTO; - $this->obtainDto(); - $this->initFieldsFromDto(); - } - - public function obtainDto(...$args) - { - // TODO: Implement obtainDto() method. - } - - public function initFieldsFromDto(): void - { - $this->region = new BarCodeRegionParameters($this->getBarCodeResultDTO()->region); - $this->extended = new BarCodeExtendedParameters($this->getBarCodeResultDTO()->extended); - } - - /** - * @return float Gets the reading quality. Works for 1D and postal barcodes. Value: The reading quality percent - * @throws BarcodeException - */ - public function getReadingQuality(): float - { - try { - return $this->getBarCodeResultDTO()->readingQuality; - } catch (Exception $ex) { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - /** - *
- * Gets the code text with encoding. - *
- * @return A string containing recognized code text. - * @param encoding The encoding for codetext. - */ - function getCodeText(?string $encoding) : string - { - if($encoding == null || $encoding == "") - { - return $this->getBarCodeResultDTO()->codeText; - } - else - { - try - { - $thriftConnection = new ThriftConnection(); - $client = $thriftConnection->openConnection(); - $codeText = $client->BarcodeResult_getCodeTextWithEncoding($this->getBarCodeResultDTO()->codeBytes, $encoding); - $thriftConnection->closeConnection(); - return $codeText; - } catch (Exception $ex) { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - } - - function getCodeType() - { - return $this->getBarCodeResultDTO()->codeType; - } - - function getCodeBytes() - { - return explode(",", $this->getBarCodeResultDTO()->codeBytes); - } - - function getCodeTypeName() - { - return $this->getBarCodeResultDTO()->codeTypeName; - } - - function getConfidence() - { - return $this->getBarCodeResultDTO()->confidence; - } - - function getExtended(): BarCodeExtendedParameters - { - return $this->extended; - } - - function getRegion(): BarCodeRegionParameters - { - return $this->region; - } -} - -/** - * Represents the recognized barcode's region and barcode angle - * - * This sample shows how to get barcode Angle and bounding quadrangle values - * @code - * $generator = new BarcodeGenerator(EncodeTypes::Code128, "12345"); - * $generator->save("test.png"); - * $reader = new BarCodeReader("test.png", null, array( DecodeType::CODE_39, DecodeType::CODE_128)); - * foreach($reader->readBarCodes() as $result) - * { - * print("BarCode CodeText: ".$result->getCodeText()); - * print("BarCode Angle: ".$result->getRegion()->getAngle()); - * print("BarCode Quadrangle: ".$result->getRegion()->getQuadrangle()); - * } - * @endcode - */ -final class BarCodeRegionParameters implements Communicator -{ - private $quad; - private $rect; - private array $points; - private BarCodeRegionParametersDTO $barCodeRegionParametersDTO; - - /** - * @return BarCodeRegionParametersDTO instance - */ - private function getBarCodeRegionParametersDTO() : BarCodeRegionParametersDTO - { - return $this->barCodeRegionParametersDTO; - } - - /** - * @param $barCodeRegionParametersDTO - */ - private function setBarCodeRegionParametersDTO($barCodeRegionParametersDTO): void - { - $this->barCodeRegionParametersDTO = $barCodeRegionParametersDTO; - } - - function __construct(BarCodeRegionParametersDTO $barCodeRegionParametersDTO) - { - $this->barCodeRegionParametersDTO = $barCodeRegionParametersDTO; - $this->obtainDto(); - $this->initFieldsFromDto(); - } - - public function obtainDto(...$args) - { - // TODO: Implement obtainDto() method. - } - - public function initFieldsFromDto(): void - { - try { - $this->quad = Quadrangle::construct($this->getBarCodeRegionParametersDTO()->quad); - $this->rect = Rectangle::construct($this->getBarCodeRegionParametersDTO()->rectangle); - $this->points = self::convertJavaPoints($this->getBarCodeRegionParametersDTO()->points); - } catch (Exception $ex) { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - private static function convertJavaPoints($javaPoints): array - { - $points = array(); - for ($i = 0; $i < sizeof($javaPoints); $i++) { - $points[$i] = Point::construct($javaPoints[$i]); - } - - return $points; - } - - /** - * @return Quadrangle Gets Quadrangle bounding barcode region Value: Returns Quadrangle bounding barcode region - */ - public function getQuadrangle(): Quadrangle - { - return $this->quad; - } - - /** - * @return float Gets the angle of the barcode (0-360). Value: The angle for barcode (0-360). - * @throws BarcodeException - */ - public function getAngle(): float - { - try { - return $this->getBarCodeRegionParametersDTO()->angle; - } catch (Exception $ex) { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - /** - * - */ - /** - * @return array Gets Points array bounding barcode region Value: Returns Points array bounding barcode region - */ - public function getPoints(): array - { - return $this->points; - } - - /** - * @return Rectangle Gets Rectangle bounding barcode region Value: Returns Rectangle bounding barcode region - */ - public function getRectangle(): Rectangle - { - return $this->rect; - } - - /** - * Returns a value indicating whether this instance is equal to a specified BarCodeRegionParameters value. - * - * @param BarCodeRegionParameters $obj An System.Object value to compare to this instance. - * @return bool true if obj has the same value as this instance; otherwise, false. - */ - public function equals(BarCodeRegionParameters $obj): bool - { - $thriftConnection = new ThriftConnection(); - $client = $thriftConnection->openConnection(); - $isEquals = $client->BarCodeRegionParameters_equals($this->getBarCodeRegionParametersDTO(), $obj->getBarCodeRegionParametersDTO()); - $thriftConnection->closeConnection(); - - return $isEquals; - } - - /** - * Returns a human-readable string representation of this BarCodeRegionParameters. - * - * @return string A string that represents this BarCodeRegionParameters. - */ - public function toString(): string - { - try { - return $this->getBarCodeRegionParametersDTO()->toString; - } catch (Exception $ex) { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } -} - - -/** - * - * Stores a set of four Points that represent a Quadrangle region. - * - */ -class Quadrangle implements Communicator -{ - private Point $leftTop; - private Point $rightTop; - private Point $rightBottom; - private Point $leftBottom; - private QuadrangleDTO $quadrangleDTO; - - /** - * @return QuadrangleDTO instance - */ - private function getQuadrangleDTO() : QuadrangleDTO - { - return $this->quadrangleDTO; - } - - /** - * @param QuadrangleDTO $quadrangleDTO - */ - private function setQuadrangleDTO(QuadrangleDTO $quadrangleDTO): void - { - $this->quadrangleDTO = $quadrangleDTO; - } - - /** - * Represents a Quadrangle structure with its properties left uninitialized.Value: Quadrangle - */ - public static function EMPTY(): Quadrangle - { - return new Quadrangle(new Point(0, 0), new Point(0, 0), new Point(0, 0), new Point(0, 0)); - } - - static function construct(QuadrangleDTO $quadrangleDTO): Quadrangle - { - $quadrangle = Quadrangle::EMPTY(); - $quadrangle->setQuadrangleDTO($quadrangleDTO); - $quadrangle->initFieldsFromDto(); - return $quadrangle; - } - - /** - * Initializes a new instance of the Quadrangle structure with the describing points. - * - * @param Point $leftTop A Point that represents the left-top corner of the Quadrangle. - * @param Point $rightTop A Point that represents the right-top corner of the Quadrangle. - * @param Point $rightBottom A Point that represents the right-bottom corner of the Quadrangle. - * @param Point $leftBottom A Point that represents the left-bottom corner of the Quadrangle. - */ - public function __construct(Point $leftTop, Point $rightTop, Point $rightBottom, Point $leftBottom) - { - $this->quadrangleDTO = new QuadrangleDTO(); - $this->getQuadrangleDTO()->leftTop = $leftTop->getPointDTO(); - $this->getQuadrangleDTO()->rightTop = $rightTop->getPointDTO(); - $this->getQuadrangleDTO()->rightBottom = $rightBottom->getPointDTO(); - $this->getQuadrangleDTO()->leftBottom = $leftBottom->getPointDTO(); - $this->initFieldsFromDto(); - } - - public function obtainDto(...$args) - { - // TODO: Implement obtainDto() method. - } - - public function initFieldsFromDto(): void - { - $this->leftTop = Point::construct($this->getQuadrangleDTO()->leftTop); - $this->rightTop = Point::construct($this->getQuadrangleDTO()->rightTop); - $this->rightBottom = Point::construct($this->getQuadrangleDTO()->rightBottom); - $this->leftBottom = Point::construct($this->getQuadrangleDTO()->leftBottom); - } - - /** - * Gets left-top corner Point of Quadrangle regionValue: A left-top corner Point of Quadrangle region - */ - public function getLeftTop(): Point - { - return $this->leftTop; - } - - /** - * Gets left-top corner Point of Quadrangle regionValue: A left-top corner Point of Quadrangle region - */ - public function setLeftTop(Point $value): void - { - try { - $this->leftTop = $value; - $this->getQuadrangleDTO()->leftTop = $value->getPointDTO(); - } catch (Exception $ex) { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - /** - * Gets right-top corner Point of Quadrangle regionValue: A right-top corner Point of Quadrangle region - */ - public function getRightTop(): Point - { - return $this->rightTop; - } - - /** - * Gets right-top corner Point of Quadrangle regionValue: A right-top corner Point of Quadrangle region - */ - public function setRightTop(Point $value): void - { - try { - $this->rightTop = $value; - $this->getQuadrangleDTO()->rightTop = $value->getPointDTO(); - } catch (Exception $ex) { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - /** - * Gets right-bottom corner Point of Quadrangle regionValue: A right-bottom corner Point of Quadrangle region - */ - public function getRightBottom(): Point - { - return $this->rightBottom; - } - - /** - * Gets right-bottom corner Point of Quadrangle regionValue: A right-bottom corner Point of Quadrangle region - */ - public function setRightBottom(Point $value): void - { - try { - $this->rightBottom = $value; - $this->getQuadrangleDTO()->rightBottom = $value->getPointDTO(); - } catch (Exception $ex) { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - /** - * Gets left-bottom corner Point of Quadrangle regionValue: A left-bottom corner Point of Quadrangle region - */ - public function getLeftBottom(): Point - { - return $this->leftBottom; - } - - /** - * Gets left-bottom corner Point of Quadrangle regionValue: A left-bottom corner Point of Quadrangle region - */ - public function setLeftBottom(Point $value): void - { - try { - $this->leftBottom = $value; - $this->getQuadrangleDTO()->leftBottom = $value->getPointDTO(); - } catch (Exception $ex) { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - /** - * Tests whether all Points of this Quadrangle have values of zero.Value: Returns true if all Points of this Quadrangle have values of zero; otherwise, false. - */ - public function isEmpty(): bool - { - return $this->equals(Quadrangle::EMPTY()); - } - - /** - * Determines if the specified Point is contained within this Quadrangle structure. - * - * @param Point $pt - * @return bool Returns true if Point is contained within this Quadrangle structure; otherwise, false. - * @throws BarcodeException - */ - public function containsPoint(Point $pt): bool - { - try - { - $thriftConnection = new ThriftConnection(); - $client = $thriftConnection->openConnection(); - $containsPointResponse = $client->Quadrangle_containsPoint($this->getQuadrangleDTO(), $pt->getPointDTO()); - $thriftConnection->closeConnection(); - return $containsPointResponse; - } catch (Exception $ex) { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - /** - * Determines if the specified point is contained within this Quadrangle structure. - * - * @param int $x The x point cordinate. - * @param int $y The y point cordinate. - * @return bool Returns true if point is contained within this Quadrangle structure; otherwise, false. - */ - public function containsCoordinates(int $x, int $y): bool - { - try - { - $thriftConnection = new ThriftConnection(); - $client = $thriftConnection->openConnection(); - $containsPointResponse = $client->Quadrangle_containsCoordinates($this->getQuadrangleDTO(), $x, $y); - $thriftConnection->closeConnection(); - return $containsPointResponse; - } catch (Exception $ex) { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - /** - * Determines if the specified Quadrangle is contained or intersect this Quadrangle structure. - * - * @param Quadrangle The Quadrangle to test. - * @return bool Returns true if Quadrangle is contained or intersect this Quadrangle structure; otherwise, false. - */ - public function containsQuadrangle(Quadrangle $quad): bool - { - try { - $thriftConnection = new ThriftConnection(); - $client = $thriftConnection->openConnection(); - $containsPointResponse = $client->Quadrangle_containsQuadrangle($this->getQuadrangleDTO(), $quad->getQuadrangleDTO()); - $thriftConnection->closeConnection(); - return $containsPointResponse; - } catch (Exception $ex) { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - /** - * Determines if the specified Rectangle is contained or intersect this Quadrangle structure. - * - * @param Rectangle $rect - * @return bool Returns true if Rectangle is contained or intersect this Quadrangle structure; otherwise, false. - * @throws BarcodeException - */ - public function containsRectangle(Rectangle $rect): bool - { - try { - $thriftConnection = new ThriftConnection(); - $client = $thriftConnection->openConnection(); - $containsPointResponse = $client->Quadrangle_containsRectangle($this->getQuadrangleDTO(), $rect->getRectangleDto()); - $thriftConnection->closeConnection(); - return $containsPointResponse; - } catch (Exception $ex) { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - /** - * Returns a value indicating whether this instance is equal to a specified Quadrangle value. - * - * @param Quadrangle $obj - * @return bool true if obj has the same value as this instance; otherwise, false. - */ - public function equals(Quadrangle $obj): bool - { - $thriftConnection = new ThriftConnection(); - $client = $thriftConnection->openConnection(); - $isEquals = $client->Quadrangle_equals($this->getQuadrangleDTO(), $obj->getQuadrangleDTO()); - $thriftConnection->closeConnection(); - - return $isEquals; - } - - /** - * Returns a human-readable string representation of this Quadrangle. - * - * @return string A string that represents this Quadrangle. - */ - public function toString(): string - { - $thriftConnection = new ThriftConnection(); - $client = $thriftConnection->openConnection(); - $str = $client->Quadrangle_toString($this->getQuadrangleDTO()); - $thriftConnection->closeConnection(); - - return $str; - } - - /** - * Creates Rectangle bounding this Quadrangle - * - * @return Rectangle returns Rectangle bounding this Quadrangle - */ - public function getBoundingRectangle(): Rectangle - { - try { - $thriftConnection = new ThriftConnection(); - $client = $thriftConnection->openConnection(); - $boundingRectangleDTO = $client->Quadrangle_getBoundingRectangle($this->getQuadrangleDTO()); - $thriftConnection->closeConnection(); - return Rectangle::construct($boundingRectangleDTO); - } catch (Exception $ex) { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } -} - -/** - *- *This example shows how to use {@code GetCodeText}:
- *- * $gen = new BarcodeGenerator(EncodeTypes::DATA_MATRIX, null); - * $gen->setCodeText("車種名", "932"); - * $gen->save("barcode.png", BarCodeImageFormat::PNG); - * - * $reader = new BarCodeReader("barcode.png", null, DecodeType::DATA_MATRIX); - * $results = $reader->readBarCodes(); - * for($i = 0; i < sizeof($results); $i++) - * { - * $result = $results[$i]; - * echo("BarCode CodeText: " . $result->getCodeText("932")); - * } - *- *- * Stores extended parameters of recognized barcode - *
- */ -class BarCodeExtendedParameters implements Communicator -{ - private $_oneDParameters; - private $_code128Parameters; - private $_qrParameters; - private $_pdf417Parameters; - private $_dataBarParameters; - private $_maxiCodeParameters; - private $_dotCodeExtendedParameters; - private $_dataMatrixExtendedParameters; - private $_aztecExtendedParameters; - private $_gs1CompositeBarExtendedParameters; - private BarCodeExtendedParametersDTO $barCodeExtendedParametersDTO; - private $_codabarExtendedParameters; - - /** - * @return BarCodeExtendedParametersDTO instance - */ - private function getBarCodeExtendedParametersDTO() : BarCodeExtendedParametersDTO - { - return $this->barCodeExtendedParametersDTO; - } - - /** - * @param BarCodeExtendedParametersDTO $barCodeExtendedParametersDTO - */ - private function setBarCodeExtendedParametersDTO(BarCodeExtendedParametersDTO $barCodeExtendedParametersDTO): void - { - $this->barCodeExtendedParametersDTO = $barCodeExtendedParametersDTO; - } - - function __construct(BarCodeExtendedParametersDTO $barCodeExtendedParametersDTO) - { - $this->barCodeExtendedParametersDTO = $barCodeExtendedParametersDTO; - $this->obtainDto(); - $this->initFieldsFromDto(); - } - - public function obtainDto(...$args) - { - // TODO: Implement obtainDto() method. - } - - public function initFieldsFromDto(): void - { - try { - $this->_oneDParameters = new OneDExtendedParameters($this->getBarCodeExtendedParametersDTO()->oneDParameters); - $this->_code128Parameters = new Code128ExtendedParameters($this->getBarCodeExtendedParametersDTO()->code128Parameters); - $this->_qrParameters = new QRExtendedParameters($this->getBarCodeExtendedParametersDTO()->qrParameters); - $this->_pdf417Parameters = new Pdf417ExtendedParameters($this->getBarCodeExtendedParametersDTO()->pdf417Parameters); - $this->_dataBarParameters = new DataBarExtendedParameters($this->getBarCodeExtendedParametersDTO()->dataBarParameters); - $this->_maxiCodeParameters = new MaxiCodeExtendedParameters($this->getBarCodeExtendedParametersDTO()->maxiCodeParameters); - $this->_dotCodeExtendedParameters = new DotCodeExtendedParameters($this->getBarCodeExtendedParametersDTO()->dotCodeExtendedParameters); - $this->_dataMatrixExtendedParameters = new DataMatrixExtendedParameters($this->getBarCodeExtendedParametersDTO()->dataMatrixExtendedParameters); - $this->_aztecExtendedParameters = new AztecExtendedParameters($this->getBarCodeExtendedParametersDTO()->aztecExtendedParameters); - $this->_gs1CompositeBarExtendedParameters = new GS1CompositeBarExtendedParameters($this->getBarCodeExtendedParametersDTO()->gs1CompositeBarExtendedParameters); - $this->_codabarExtendedParameters = new CodabarExtendedParameters($this->getBarCodeExtendedParametersDTO()->codabarExtendedParameters); - } catch (Exception $ex) { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - /** Gets a DataBar additional information DataBarExtendedParameters of recognized barcode - * @return DataBarExtendedParameters A DataBar additional information DataBarExtendedParameters of recognized barcode - */ - public function getDataBar(): DataBarExtendedParameters - { - return $this->_dataBarParameters; - } - - /** - * Gets a MaxiCode additional informationof recognized barcode - * - * @return MaxiCodeExtendedParameters A MaxiCode additional information of recognized barcode - */ - public function getMaxiCode(): MaxiCodeExtendedParameters - { - return $this->_maxiCodeParameters; - } - - /** - * Gets a DotCode additional information{@code DotCodeExtendedParameters} of recognized barcode
Value: A DotCode additional information{@code DotCodeExtendedParameters} of recognized barcode - */ - public function getDotCode(): DotCodeExtendedParameters - { - return $this->_dotCodeExtendedParameters; - } - - /** - *Gets a DotCode additional information{@code DotCodeExtendedParameters} of recognized barcode
Value: A DotCode additional information{@code DotCodeExtendedParameters} of recognized barcode - */ - public function getDataMatrix(): DataMatrixExtendedParameters - { - return $this->_dataMatrixExtendedParameters; - } - - /** - *Gets a Aztec additional information{@code AztecExtendedParameters} of recognized barcode
Value: A Aztec additional information{@code AztecExtendedParameters} of recognized barcode - */ - public function getAztec(): AztecExtendedParameters - { - return $this->_aztecExtendedParameters; - } - - /** - *Gets a GS1CompositeBar additional information{@code GS1CompositeBarExtendedParameters} of recognized barcode
Value: A GS1CompositeBar additional information{@code GS1CompositeBarExtendedParameters} of recognized barcode - */ - public function getGS1CompositeBar(): GS1CompositeBarExtendedParameters - { - return $this->_gs1CompositeBarExtendedParameters; - } - - /** - * Gets a Codabar additional information{@code CodabarExtendedParameters} of recognized barcode - * @return CodabarExtendedParameters additional information - */ - public function getCodabar() : CodabarExtendedParameters - { - return $this->_codabarExtendedParameters; - } - - /** - * @return OneDExtendedParameters Gets a special data OneDExtendedParameters of 1D recognized barcode Value: A special data OneDExtendedParameters of 1D recognized barcode - */ - public function getOneD(): OneDExtendedParameters - { - return $this->_oneDParameters; - } - - /** - * @return Code128ExtendedParameters Gets a special data Code128ExtendedParameters of Code128 recognized barcode Value: A special data Code128ExtendedParameters of Code128 recognized barcode - */ - public function getCode128(): Code128ExtendedParameters - { - return $this->_code128Parameters; - } - - /** - * @return QRExtendedParameters Gets a QR Structured Append information QRExtendedParameters of recognized barcode Value: A QR Structured Append information QRExtendedParameters of recognized barcode - */ - public function getQR(): QRExtendedParameters - { - return $this->_qrParameters; - } - - /** - * @return Pdf417ExtendedParameters Gets a MacroPdf417 metadata information Pdf417ExtendedParameters of recognized barcode Value: A MacroPdf417 metadata information Pdf417ExtendedParameters of recognized barcode - */ - public function getPdf417(): Pdf417ExtendedParameters - { - return $this->_pdf417Parameters; - } - - /** - * Returns a value indicating whether this instance is equal to a specified BarCodeExtendedParameters value. - * - * @param BarCodeExtendedParameters $obj An System.Object value to compare to this instance. - * @return bool true if obj has the same value as this instance; otherwise, false. - */ - public function equals(BarCodeExtendedParameters $obj): bool - { - $thriftConnection = new ThriftConnection(); - $client = $thriftConnection->openConnection(); - $isEquals = $client->BarCodeExtendedParameters_equals($this->getBarCodeExtendedParametersDTO(), $obj->getBarCodeExtendedParametersDTO()); - $thriftConnection->closeConnection(); - - return $isEquals; - } - - /** - * Returns a human-readable string representation of this BarCodeExtendedParameters. - * - * @return string A string that represents this BarCodeExtendedParameters. - */ - public function toString(): string - { - try { - return $this->getBarCodeExtendedParametersDTO()->toString; // TODO need to implement - } catch (Exception $ex) { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } -} - - -/** - * - * Stores special data of 1D recognized barcode like separate codetext and checksum - * - * This sample shows how to get 1D barcode value and checksum - * @code - * $generator = new BarcodeGenerator(EncodeTypes::EAN_13, "1234567890128"); - * $generator->save("test.png"); - * $reader = new BarCodeReader("test.png", DecodeType::EAN_13); - * foreach($reader->readBarCodes() as $result) - * { - * print("BarCode Type: ".$result->getCodeTypeName()); - * print("BarCode CodeText: ".$result->getCodeText()); - * print("BarCode Value: ".$result->getExtended()->getOneD()->getValue()); - * print("BarCode Checksum: ".$result->getExtended()->getOneD()->getCheckSum()); - * } - * @endcode - */ -final class OneDExtendedParameters implements Communicator -{ - private OneDExtendedParametersDTO $oneDExtendedParametersDTO; - - /** - * @return OneDExtendedParametersDTO instance - */ - private function getOneDExtendedParametersDTO() : OneDExtendedParametersDTO - { - return $this->oneDExtendedParametersDTO; - } - - /** - * @param $oneDExtendedParametersDTO - */ - private function setOneDExtendedParametersDTO($oneDExtendedParametersDTO): void - { - $this->oneDExtendedParametersDTO = $oneDExtendedParametersDTO; - } - - function __construct(OneDExtendedParametersDTO $oneDExtendedParametersDTO) - { - $this->oneDExtendedParametersDTO = $oneDExtendedParametersDTO; - $this->obtainDto(); - $this->initFieldsFromDto(); - } - - public function obtainDto(...$args) - { - // TODO: Implement obtainDto() method. - } - - public function initFieldsFromDto(): void - { - } - - /** - * Gets the codetext of 1D barcodes without checksum. Value: The codetext of 1D barcodes without checksum. - */ - public function getValue(): string - { - try { - return $this->getOneDExtendedParametersDTO()->value; - } catch (Exception $ex) { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - /** - * Gets the checksum for 1D barcodes. Value: The checksum for 1D barcode. - */ - public function getCheckSum(): string - { - try { - return $this->getOneDExtendedParametersDTO()->checkSum; - } catch (Exception $ex) { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - /** - * Tests whether all parameters has only default values - * @return bool Returns { true} if all parameters has only default values; otherwise, { false}. - * @throws BarcodeException - */ - public function isEmpty(): bool - { - try { - return $this->getOneDExtendedParametersDTO()->empty; - } catch (Exception $ex) { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - /** - * Returns a value indicating whether this instance is equal to a specified OneDExtendedParameters value. - * - * @param OneDExtendedParameters obj An System.Object value to compare to this instance. - * @return bool true if obj has the same value as this instance; otherwise, false. - */ - public function equals(OneDExtendedParameters $obj): bool - { - $thriftConnection = new ThriftConnection(); - $client = $thriftConnection->openConnection(); - $isEquals = $client->OneDExtendedParameters_equals($this->getOneDExtendedParametersDTO(), $obj->getOneDExtendedParametersDTO()); - $thriftConnection->closeConnection(); - - return $isEquals; - } - - /** - * Returns a human-readable string representation of this OneDExtendedParameters. - * - * @return string A string that represents this OneDExtendedParameters. - */ - public function toString(): string - { - try { - return $this->getOneDExtendedParametersDTO()->toString; - } catch (Exception $ex) { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } -} - -/** - * - * Stores special data of Code128 recognized barcode - * Represents the recognized barcode's region and barcode angle - * - * This sample shows how to get code128 raw values - * @code - * $generator = new BarcodeGenerator(EncodeTypes::CODE_128, "12345"); - * $generator->save("test.png"); - * $reader = new BarCodeReader("test.png", DecodeType::CODE_128); - * foreach($reader->readBarCodes() as $result) - * { - * print("BarCode Type: ".$result->getCodeTypeName()); - * print("BarCode CodeText: ".$result->getCodeText()); - * print("Code128 Data Portions: ".$result->getExtended()->getCode128()); - * } - * @endcode - */ -final class Code128ExtendedParameters implements Communicator -{ - private array $code128DataPortions; - private Code128ExtendedParametersDTO $code128ExtendedParametersDTO; - - /** - * @return Code128ExtendedParametersDTO instance - */ - private function getCode128ExtendedParametersDTO() : Code128ExtendedParametersDTO - { - return $this->code128ExtendedParametersDTO; - } - - /** - * @param Code128ExtendedParametersDTO $code128ExtendedParametersDTO - */ - private function setCode128ExtendedParametersDTO(Code128ExtendedParametersDTO $code128ExtendedParametersDTO): void - { - $this->code128ExtendedParametersDTO = $code128ExtendedParametersDTO; - } - - function __construct(Code128ExtendedParametersDTO $code128ExtendedParametersDTO) - { - $this->code128ExtendedParametersDTO = $code128ExtendedParametersDTO; - $this->obtainDto(); - $this->initFieldsFromDto(); - } - - public function obtainDto(...$args) - { - // TODO: Implement obtainDto() method. - } - - public function initFieldsFromDto(): void - { - try { - $this->code128DataPortions = self::convertCode128DataPortions($this->getCode128ExtendedParametersDTO()->code128DataPortions); - } catch (Exception $ex) { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - private static function convertCode128DataPortions($javaCode128DataPortions): array - { - $code128DataPortions = array(); - for ($i = 0; $i < sizeof($javaCode128DataPortions); $i++) { - $code128DataPortions[] = new Code128DataPortion($javaCode128DataPortions[$i]); - } - return $code128DataPortions; - } - - /** - * Gets Code128DataPortion array of recognized Code128 barcode Value: Array of the Code128DataPortion. - */ - public function getCode128DataPortions(): array - { - return $this->code128DataPortions; - } - - public function isEmpty(): bool - { - try { - return $this->getCode128ExtendedParametersDTO()->empty; - } catch (Exception $ex) { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - /** - * Returns a value indicating whether this instance is equal to a specified Code128ExtendedParameters value. - * - * @param Code128ExtendedParameters obj An System.Object value to compare to this instance. - * @return bool true if obj has the same value as this instance; otherwise, false. - */ - public function equals(Code128ExtendedParameters $obj): bool - { - $thriftConnection = new ThriftConnection(); - $client = $thriftConnection->openConnection(); - $isEquals = $client->Code128ExtendedParameters_equals($this->getCode128ExtendedParametersDTO(), $obj->getCode128ExtendedParametersDTO()); - $thriftConnection->closeConnection(); - - return $isEquals; - } - - /** - * Returns a human-readable string representation of this Code128ExtendedParameters. - * - * @return string A string that represents this Code128ExtendedParameters. - */ - public function toString(): string - { - try { - return $this->getCode128ExtendedParametersDTO()->toString;// TODO need to implement - } catch (Exception $ex) { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } -} - - -/** - * - * Stores a QR Structured Append information of recognized barcode - * - * This sample shows how to get QR Structured Append data - * @code - * $reader = new BarCodeReader("test.png", DecodeType::QR); - * foreach($reader->readBarCodes() as $result) - * { - * print("BarCode Type: ".$result->getCodeTypeName()); - * print("BarCode CodeText: ".$result->getCodeText()); - * print("QR Structured Append Quantity: ".$result->getExtended()->getQR()->getQRStructuredAppendModeBarCodesQuantity()); - * print("QR Structured Append Index: ".$result->getExtended()->getQR()->getQRStructuredAppendModeBarCodeIndex()); - * print("QR Structured Append ParityData: ".$result->getExtended()->getQR()->getQRStructuredAppendModeParityData()); - * } - * @endcode - */ -final class QRExtendedParameters implements Communicator -{ - private QRExtendedParametersDTO $qrExtendedParametersDTO; - - /** - * @return QRExtendedParametersDTO instance - */ - private function getQRExtendedParametersDTO() : QRExtendedParametersDTO - { - return $this->qrExtendedParametersDTO; - } - - /** - * @param $qrExtendedParametersDTO - */ - private function setQRExtendedParametersDTO($qrExtendedParametersDTO): void - { - $this->qrExtendedParametersDTO = $qrExtendedParametersDTO; - } - - function __construct(QRExtendedParametersDTO $qrExtendedParametersDTO) - { - $this->qrExtendedParametersDTO = $qrExtendedParametersDTO; - $this->obtainDto(); - $this->initFieldsFromDto(); - } - - public function obtainDto(...$args) - { - // TODO: Implement obtainDto() method. - } - - public function initFieldsFromDto(): void - { - // TODO: Implement init() method. - } - - /** - * Gets the QR structured append mode barcodes quantity. Default value is -1.Value: The quantity of the QR structured append mode barcode. - */ - public function getQRStructuredAppendModeBarCodesQuantity(): int - { - try { - return $this->getQRExtendedParametersDTO()->qRStructuredAppendModeBarCodesQuantity; - } catch (Exception $ex) { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - /** - * Gets the index of the QR structured append mode barcode. Index starts from 0. Default value is -1.Value: The quantity of the QR structured append mode barcode. - */ - public function getQRStructuredAppendModeBarCodeIndex(): int - { - try { - return $this->getQRExtendedParametersDTO()->qRStructuredAppendModeBarCodeIndex; - } catch (Exception $ex) { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - /** - * Version of recognized QR Code. From Version1 to Version40. - * return recognized QR Code - */ - public function getQRVersion() : int - { - return $this->getQRExtendedParametersDTO()->qrVersion; - } - - /** - * Version of recognized MicroQR Code. From M1 to M4. - * return recognized MicroQR Code. From M1 to M4. - */ - public function getMicroQRVersion() : int - { - return $this->getQRExtendedParametersDTO()->microQRVersion; - } - - /** - * Version of recognized RectMicroQR Code. From R7x43 to R17x139. - * @return int of recognized RectMicroQR Code - */ - public function getRectMicroQRVersion() : int - { - return $this->getQRExtendedParametersDTO()->rectMicroQRVersion; - } - - /** - * Reed-Solomon error correction level of recognized barcode. From low to high: LevelL, LevelM, LevelQ, LevelH. - * @return int error correction level of recognized barcode. - */ - public function getQRErrorLevel() : int - { - return $this->getQRExtendedParametersDTO()->qrErrorLevel; - } - - - /** - * Gets the QR structured append mode parity data. Default value is -1.Value: The index of the QR structured append mode barcode. - */ - public function getQRStructuredAppendModeParityData(): int - { - try { - return $this->getQRExtendedParametersDTO()->qRStructuredAppendModeParityData; - } catch (Exception $ex) { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - public function isEmpty(): bool - { - try { - return $this->getQRExtendedParametersDTO()->empty; - } catch (Exception $ex) { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - /** - * Returns a value indicating whether this instance is equal to a specified QRExtendedParameters value. - * - * @param QRExtendedParameters $obj An object value to compare to this instance. - * @return bool true if obj has the same value as this instance; otherwise, false. - */ - public function equals(QRExtendedParameters $obj): bool - { - $thriftConnection = new ThriftConnection(); - $client = $thriftConnection->openConnection(); - $isEquals = $client->QRExtendedParameters_equals($this->getQRExtendedParametersDTO(), $obj->getQRExtendedParametersDTO()); - $thriftConnection->closeConnection(); - - return $isEquals; - } - - /** - * Returns a human-readable string representation of this QRExtendedParameters. - * - * @return string A string that represents this QRExtendedParameters. - */ - public function toString(): string - { - try { - return $this->getQRExtendedParametersDTO()->toString; - } catch (Exception $ex) { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } -} - -/** - * - * Stores a MacroPdf417 metadata information of recognized barcode - * - * This sample shows how to get Macro Pdf417 metadata - * @code - * $generator = new BarcodeGenerator(EncodeTypes::MacroPdf417, "12345"); - * $generator->getParameters()->getBarcode()->getPdf417()->setPdf417MacroFileID(10); - * $generator->getParameters()->getBarcode()->getPdf417()->setPdf417MacroSegmentsCount(2); - * $generator->getParameters()->getBarcode()->getPdf417()->setPdf417MacroSegmentID(1); - * $generator->save("test.png"); - * $reader = new BarCodeReader("test.png", DecodeType::MACRO_PDF_417); - * foreach($reader->readBarCodes() as $result) - * { - * print("BarCode Type: ".$result->getCodeTypeName()); - * print("BarCode CodeText: ".$result->getCodeText()); - * print("Macro Pdf417 FileID: ".$result->getExtended()->getPdf417()->getMacroPdf417FileID()); - * print("Macro Pdf417 Segments: ".$result->getExtended()->getPdf417()->getMacroPdf417SegmentsCount()); - * print("Macro Pdf417 SegmentID: ".$result->getExtended()->getPdf417()->getMacroPdf417SegmentID()); - * } - * @endcode - */ -final class Pdf417ExtendedParameters implements Communicator -{ - private Pdf417ExtendedParametersDTO $pdf417ExtendedParametersDTO; - - /** - * @return Pdf417ExtendedParametersDTO instance - */ - private function getPdf417ExtendedParametersDTO() : Pdf417ExtendedParametersDTO - { - return $this->pdf417ExtendedParametersDTO; - } - - /** - * @param $pdf417ExtendedParametersDTO - */ - private function setQRExtendedParametersDTO($pdf417ExtendedParametersDTO): void - { - $this->pdf417ExtendedParametersDTO = $pdf417ExtendedParametersDTO; - } - - function __construct(Pdf417ExtendedParametersDTO $pdf417ExtendedParametersDTO) - { - $this->pdf417ExtendedParametersDTO = $pdf417ExtendedParametersDTO; - $this->obtainDto(); - $this->initFieldsFromDto(); - } - - public function obtainDto(...$args) - { - // TODO: Implement obtainDto() method. - } - - public function initFieldsFromDto(): void - { - // TODO: Implement init() method. - } - - /** - * Gets the file ID of the barcode, only available with MacroPdf417.Value: The file ID for MacroPdf417 - */ - public function getMacroPdf417FileID(): string - { - try { - return $this->getPdf417ExtendedParametersDTO()->macroPdf417FileID; - } catch (Exception $ex) { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - /** - * Gets the segment ID of the barcode,only available with MacroPdf417.Value: The segment ID of the barcode. - */ - public function getMacroPdf417SegmentID(): int - { - try { - return $this->getPdf417ExtendedParametersDTO()->macroPdf417SegmentID; - } catch (Exception $ex) { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - /** - * Gets macro pdf417 barcode segments count. Default value is -1.Value: Segments count. - */ - public function getMacroPdf417SegmentsCount(): int - { - try { - return $this->getPdf417ExtendedParametersDTO()->macroPdf417SegmentsCount; - } catch (Exception $ex) { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - /** - * Macro PDF417 file name (optional). - * @return string File name. - */ - public function getMacroPdf417FileName(): string - { - try { - return $this->getPdf417ExtendedParametersDTO()->macroPdf417FileName; - } catch (Exception $ex) { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - /** - * Macro PDF417 file size (optional). - * @return int File size. - */ - public function getMacroPdf417FileSize(): int - { - try { - return $this->getPdf417ExtendedParametersDTO()->macroPdf417FileSize; - } catch (Exception $ex) { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - /** - * Macro PDF417 sender name (optional). - * @return string Sender name - */ - public function getMacroPdf417Sender(): string - { - try { - return $this->getPdf417ExtendedParametersDTO()->macroPdf417Sender; - } catch (Exception $ex) { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - /** - * Macro PDF417 addressee name (optional). - * @return string Addressee name. - */ - public function getMacroPdf417Addressee(): string - { - try { - return $this->getPdf417ExtendedParametersDTO()->macroPdf417Addressee; - } catch (Exception $ex) { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - /** - * Macro PDF417 time stamp (optional). - * @return DateTime Time stamp. - */ - public function getMacroPdf417TimeStamp(): DateTime - { - try { - return new DateTime('@' . $this->getPdf417ExtendedParametersDTO()->macroPdf417TimeStamp); - } catch (Exception $ex) { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - /** - * Macro PDF417 checksum (optional). - * @return int Checksum. - */ - public function getMacroPdf417Checksum(): int - { - try { - return $this->getPdf417ExtendedParametersDTO()->macroPdf417Checksum; - } catch (Exception $ex) { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - /** - * Indicates whether the segment is the last segment of a Macro PDF417 file. - */ - public function getMacroPdf417Terminator(): bool - { - try { - return $this->getPdf417ExtendedParametersDTO()->macroPdf417Terminator; - } catch (Exception $ex) { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - /** - *Used to instruct the reader to interpret the data contained within the symbol as programming for reader initialization.
Value: Reader initialization flag - */ - public function isReaderInitialization(): bool - { - return $this->getPdf417ExtendedParametersDTO()->isReaderInitialization; - } - - /** - *Flag that indicates that the barcode must be linked to 1D barcode.
Value: Linkage flag - */ - public function isLinked(): bool - { - return $this->getPdf417ExtendedParametersDTO()->isLinked; - } - - /** - * Flag that indicates that the MicroPdf417 barcode encoded with 908, 909, 910 or 911 Code 128 emulation codewords. - * @return bool 128 emulation flag - */ - public function isCode128Emulation(): bool - { - return $this->getPdf417ExtendedParametersDTO()->isCode128Emulation; - } - - /** - * Returns a value indicating whether this instance is equal to a specified Pdf417ExtendedParameters value. - * - * @param Pdf417ExtendedParameters $obj An System.Object value to compare to this instance. - * @return bool true if obj has the same value as this instance; otherwise, false. - */ - public function equals(Pdf417ExtendedParameters $obj): bool - { - $thriftConnection = new ThriftConnection(); - $client = $thriftConnection->openConnection(); - $isEquals = $client->Pdf417ExtendedParameters_equals($this->getPdf417ExtendedParametersDTO(), $obj->getPdf417ExtendedParametersDTO()); - $thriftConnection->closeConnection(); - - return $isEquals; - } - - /** - * Returns a human-readable string representation of this Pdf417ExtendedParameters. - * @return string A string that represents this Pdf417ExtendedParameters. - * @throws BarcodeException - */ - public function toString(): string - { - try { - return $this->getPdf417ExtendedParametersDTO()->toString;// TODO implement - } catch (Exception $ex) { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - -} - - -/** - * Stores a DataBar additional information of recognized barcode - * - * @code - * $reader = new BarCodeReader("test.png", DecodeType::DATABAR_OMNI_DIRECTIONAL); - * - * foreach($reader->readBarCodes() as $result) - * { - * print("BarCode Type: ".result->getCodeTypeName()); - * print("BarCode CodeText: ".result->getCodeText()); - * print("QR Structured Append Quantity: ".result->getExtended()->getQR()->getQRStructuredAppendModeBarCodesQuantity()); - * } - * @endcode - */ -class DataBarExtendedParameters implements Communicator -{ - private DataBarExtendedParametersDTO $dataBarExtendedParametersDTO; - - /** - * @return DataBarExtendedParametersDTO instance - */ - private function getDataBarExtendedParametersDTO() : DataBarExtendedParametersDTO - { - return $this->dataBarExtendedParametersDTO; - } - - /** - * @param $dataBarExtendedParametersDTO - */ - private function setQRExtendedParametersDTO($dataBarExtendedParametersDTO): void - { - $this->dataBarExtendedParametersDTO = $dataBarExtendedParametersDTO; - } - - function __construct(DataBarExtendedParametersDTO $dataBarExtendedParametersDTO) - { - $this->dataBarExtendedParametersDTO = $dataBarExtendedParametersDTO; - $this->obtainDto(); - $this->initFieldsFromDto(); - } - - public function obtainDto(...$args) - { - // TODO: Implement obtainDto() method. - } - - public function initFieldsFromDto(): void - { - // TODO: Implement init() method. - } - - /** - * Gets the DataBar 2D composite component flag. Default value is false. - * @return bool The DataBar 2D composite component flag. - */ - public function is2DCompositeComponent(): bool - { - try { - return $this->getDataBarExtendedParametersDTO()->is2DCompositeComponent; - } catch (Exception $ex) { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - /** - * Returns a value indicating whether this instance is equal to a specified DataBarExtendedParameters value. - * @param DataBarExtendedParameters $obj An System.Object value to compare to this instance. - * @return bool true if obj has the same value as this instance; otherwise, false. - */ - public function equals(DataBarExtendedParameters $obj): bool - { - $thriftConnection = new ThriftConnection(); - $client = $thriftConnection->openConnection(); - $isEquals = $client->DataBarExtendedParameters_equals($this->getDataBarExtendedParametersDTO(), $obj->getDataBarExtendedParametersDTO()); - $thriftConnection->closeConnection(); - - return $isEquals; - } - - /** - * Returns a human-readable string representation of this DataBarExtendedParameters. - * @return string A string that represents this DataBarExtendedParameters. - */ - public function toString(): string - { - try { - return $this->getDataBarExtendedParametersDTO()->toString; - } catch (Exception $ex) { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } -} - - -/** - * Stores a MaxiCode additional information of recognized barcode - */ -class MaxiCodeExtendedParameters implements Communicator -{ - private MaxiCodeExtendedParametersDTO $maxiCodeExtendedParametersDTO; - - /** - * @return MaxiCodeExtendedParametersDTO instance - */ - private function getMaxiCodeExtendedParametersDTO() : MaxiCodeExtendedParametersDTO - { - return $this->maxiCodeExtendedParametersDTO; - } - - /** - * @param $maxiCodeExtendedParametersDTO - */ - private function setMaxiCodeExtendedParametersDTO($maxiCodeExtendedParametersDTO): void - { - $this->maxiCodeExtendedParametersDTO = $maxiCodeExtendedParametersDTO; - } - - function __construct(MaxiCodeExtendedParametersDTO $maxiCodeExtendedParametersDTO) - { - $this->maxiCodeExtendedParametersDTO = $maxiCodeExtendedParametersDTO; - $this->obtainDto(); - $this->initFieldsFromDto(); - } - - public function obtainDto(...$args) - { - // TODO: Implement obtainDto() method. - } - - public function initFieldsFromDto(): void - { - // TODO: Implement init() method. - } - - /** - * Gets a MaxiCode encode mode. - * Default value: Mode4 - */ - public function getMaxiCodeMode(): int - { - return $this->getMaxiCodeExtendedParametersDTO()->maxiCodeMode; - } - - /** - * Sets a MaxiCode encode mode. - * Default value: Mode4 - */ - public function setMaxiCodeMode(int $maxiCodeMode): void - { - $this->getMaxiCodeExtendedParametersDTO()->maxiCodeMode = $maxiCodeMode; - } - - /** - * Gets a MaxiCode barcode id in structured append mode. - * Default value: 0 - */ - public function getMaxiCodeStructuredAppendModeBarcodeId(): int - { - return $this->getMaxiCodeExtendedParametersDTO()->maxiCodeStructuredAppendModeBarcodeId; - } - - /** - * Sets a MaxiCode barcode id in structured append mode. - * Default value: 0 - */ - public function setMaxiCodeStructuredAppendModeBarcodeId(int $value): void - { - $this->getMaxiCodeExtendedParametersDTO()->maxiCodeStructuredAppendModeBarcodeId = $value; - } - - /** - * Gets a MaxiCode barcodes count in structured append mode. - * Default value: -1 - */ - public function getMaxiCodeStructuredAppendModeBarcodesCount(): int - { - return $this->getMaxiCodeExtendedParametersDTO()->maxiCodeStructuredAppendModeBarcodesCount; - } - - /** - * Sets a MaxiCode barcodes count in structured append mode. - * Default value: -1 - */ - public function setMaxiCodeStructuredAppendModeBarcodesCount(int $value): void - { - $this->getMaxiCodeExtendedParametersDTO()->maxiCodeStructuredAppendModeBarcodesCount = $value; - } - - /** - * Returns a value indicating whether this instance is equal to a specified MaxiCodeExtendedParameters value. - * @param MaxiCodeExtendedParameters $obj An System.Object value to compare to this instance. - * @return bool true if obj has the same value as this instance; otherwise, false. - */ - public function equals(MaxiCodeExtendedParameters $obj): bool - { - $thriftConnection = new ThriftConnection(); - $client = $thriftConnection->openConnection(); - $isEquals = $client->MaxiCodeExtendedParameters_equals($this->getMaxiCodeExtendedParametersDTO(), $obj->getMaxiCodeExtendedParametersDTO()); - $thriftConnection->closeConnection(); - - return $isEquals; - } - - /** - * Returns a human-readable string representation of this MaxiCodeExtendedParameters. - * @return string A string that represents this MaxiCodeExtendedParameters. - */ - public function toString(): string - { - return $this->getMaxiCodeExtendedParametersDTO()->toString; - } -} - -/** - *- * Stores special data of DotCode recognized barcode - *
- */ -class DotCodeExtendedParameters implements Communicator -{ - private DotCodeExtendedParametersDTO $dotCodeExtendedParametersDTO; - - /** - * @return DotCodeExtendedParametersDTO instance - */ - private function getDotCodeExtendedParametersDTO() : DotCodeExtendedParametersDTO - { - return $this->dotCodeExtendedParametersDTO; - } - - /** - * @param $dotCodeExtendedParametersDTO - */ - private function setDotCodeExtendedParametersDTO($dotCodeExtendedParametersDTO): void - { - $this->dotCodeExtendedParametersDTO = $dotCodeExtendedParametersDTO; - } - - function __construct(DotCodeExtendedParametersDTO $dotCodeExtendedParametersDTO) - { - $this->dotCodeExtendedParametersDTO = $dotCodeExtendedParametersDTO; - $this->obtainDto(); - $this->initFieldsFromDto(); - } - - public function obtainDto(...$args) - { - // TODO: Implement obtainDto() method. - } - - public function initFieldsFromDto(): void - { - // TODO: Implement init() method. - } - - /** - *- * This sample shows how to get DotCode raw values - *- * - * $generator = new BarcodeGenerator(EncodeTypes::DOT_CODE, "12345"); - * { - * $generator->save("c:\\test.png", BarCodeImageFormat::PNG); - * } - * $reader = new BarCodeReader("c:\\test.png", null, DecodeType::DOT_CODE); - * { - * foreach($reader->readBarCodes() as $result) - * { - * print("BarCode type: " . $result->getCodeTypeName()); - * print("BarCode codetext: " . $result->getCodeText()); - * print("DotCode barcode ID: " . $result->getExtended()->getDotCode()->getDotCodeStructuredAppendModeBarcodeId()); - * print("DotCode barcodes count: " . $result->getExtended()->getDotCode()->getDotCodeStructuredAppendModeBarcodesCount()); - * } - * } - *- *Gets the DotCode structured append mode barcodes count. Default value is -1. Count must be a value from 1 to 35.
Value: The count of the DotCode structured append mode barcode. - */ - public function getDotCodeStructuredAppendModeBarcodesCount(): int - { - return $this->getDotCodeExtendedParametersDTO()->dotCodeStructuredAppendModeBarcodesCount; - } - - /** - *Gets the ID of the DotCode structured append mode barcode. ID starts from 1 and must be less or equal to barcodes count. Default value is -1.
Value: The ID of the DotCode structured append mode barcode. - */ - public function getDotCodeStructuredAppendModeBarcodeId(): int - { - return $this->getDotCodeExtendedParametersDTO()->dotCodeStructuredAppendModeBarcodeId; - } - - /** - *- * Indicates whether code is used for instruct reader to interpret the following data as instructions for initialization or reprogramming of the bar code reader. - * Default value is false. - *
- */ - public function getDotCodeIsReaderInitialization(): bool - { - return $this->getDotCodeExtendedParametersDTO()->dotCodeIsReaderInitialization; - } - - /** - *- * Returns a value indicating whether this instance is equal to a specified {@code DotCodeExtendedParameters} value. - *
- * @param DotCodeExtendedParameters $obj - * @return bool ```php - */ - public function equals(DotCodeExtendedParameters $obj): bool - { - $thriftConnection = new ThriftConnection(); - $client = $thriftConnection->openConnection(); - $isEquals = $client->DotCodeExtendedParameters_equals($this->getDotCodeExtendedParametersDTO(), $obj->getDotCodeExtendedParametersDTO()); - $thriftConnection->closeConnection(); - - return $isEquals; - } - - /** - *- * Returns a human-readable string representation of this {@code DotCodeExtendedParameters}. - *
- * @return string that represents this {@code DotCodeExtendedParameters}. - */ - public function toString(): string - { - return $this->getDotCodeExtendedParametersDTO()->toString; - } -} - -/** - *- * Stores special data of DataMatrix recognized barcode - *
- */ -class DataMatrixExtendedParameters implements Communicator -{ - private DataMatrixExtendedParametersDTO $dataMatrixExtendedParametersDTO; - - /** - * @return DataMatrixExtendedParametersDTO instance - */ - private function getDataMatrixExtendedParametersDTO() : DataMatrixExtendedParametersDTO - { - return $this->dataMatrixExtendedParametersDTO; - } - - /** - * @param $dataMatrixExtendedParametersDTO - */ - private function setDataMatrixExtendedParametersDTO($dataMatrixExtendedParametersDTO): void - { - $this->dataMatrixExtendedParametersDTO = $dataMatrixExtendedParametersDTO; - } - - function __construct(DataMatrixExtendedParametersDTO $dataMatrixExtendedParametersDTO) - { - $this->dataMatrixExtendedParametersDTO = $dataMatrixExtendedParametersDTO; - $this->obtainDto(); - $this->initFieldsFromDto(); - } - - public function obtainDto(...$args) - { - // TODO: Implement obtainDto() method. - } - - public function initFieldsFromDto(): void - { - // TODO: Implement init() method. - } - - /** - *- * This sample shows how to get DataMatrix raw values - *- * $generator = new BarcodeGenerator(EncodeTypes.DATA_MATRIX, "12345")) - * $generator->save("c:\\test.png", BarcodeImageFormat::PNG); - * - * $reader = new BarCodeReader("c:\\test.png", null, DecodeType::DATA_MATRIX)) - * foreach($reader->readBarCodes() as $result) - * { - * echo("BarCode type: " . $result->getCodeTypeName()); - * echo("BarCode codetext: " . $result->getCodeText()); - * echo("DataMatrix barcode ID: " . $result->getExtended()->getDataMatrix()->getStructuredAppendBarcodeId()); - * echo("DataMatrix barcodes count: " . $result->getExtended()->getDataMatrix()->getStructuredAppendBarcodesCount()); - * echo("DataMatrix file ID: " . $result->getExtended()->getDataMatrix()->getStructuredAppendFileId()); - * echo("DataMatrix is reader programming: " . $result->getExtended()->getDataMatrix()->isReaderProgramming()); - * } - *- *Gets the DataMatrix structured append mode barcodes count. Default value is -1. Count must be a value from 1 to 35.
Value: The count of the DataMatrix structured append mode barcode. - */ - public function getStructuredAppendBarcodesCount(): int - { - return $this->getDataMatrixExtendedParametersDTO()->structuredAppendBarcodesCount; - } - - /** - *Gets the ID of the DataMatrix structured append mode barcode. ID starts from 1 and must be less or equal to barcodes count. Default value is -1.
Value: The ID of the DataMatrix structured append mode barcode. - */ - public function getStructuredAppendBarcodeId(): int - { - return $this->getDataMatrixExtendedParametersDTO()->structuredAppendBarcodeId; - } - - /** - *Gets the ID of the DataMatrix structured append mode barcode. ID starts from 1 and must be less or equal to barcodes count. Default value is -1.
Value: The ID of the DataMatrix structured append mode barcode. - */ - public function getStructuredAppendFileId(): int - { - return $this->getDataMatrixExtendedParametersDTO()->structuredAppendFileId; - } - - /** - *- * Indicates whether code is used for instruct reader to interpret the following data as instructions for initialization or reprogramming of the bar code reader. - * Default value is false. - *
- */ - public function isReaderProgramming(): bool - { - return $this->getDataMatrixExtendedParametersDTO()->readerProgramming; - } - - /** - *- * Returns a value indicating whether this instance is equal to a specified {@code DataMatrixExtendedParameters} value. - *
- * @param DataMatrixExtendedParameters $obj - * @return bool ```php - */ - public function equals(DataMatrixExtendedParameters $obj): bool - { - $thriftConnection = new ThriftConnection(); - $client = $thriftConnection->openConnection(); - $isEquals = $client->DataMatrixExtendedParameters_equals($this->getDataMatrixExtendedParametersDTO(), $obj->getDataMatrixExtendedParametersDTO()); - $thriftConnection->closeConnection(); - - return $isEquals; - } - - /** - *- * Returns a human-readable string representation of this {@code DataMatrixExtendedParameters}. - *
- * @return string that represents this {@code DataMatrixExtendedParameters}. - */ - public function toString(): string - { - return $this->getDataMatrixExtendedParametersDTO()->toString; - } -} - - -/** - * Stores special data of Aztec recognized barcode * - * This sample shows how to get Aztec raw values - * - * @code - * $generator = new BarcodeGenerator(EncodeTypes::AZTEC, "12345"); - * $generator->save("test.png", BarcodeImageFormat::PNG); - * - * $reader = new BarCodeReader("test.png", null, DecodeType::AZTEC); - * foreach($reader->readBarCodes() as $result) - * { - * echo("BarCode type: " . $result->getCodeTypeName()); - * echo("BarCode codetext: " . $result->getCodeText()); - * echo("Aztec barcode ID: " . $result->getExtended()->getAztec()->getStructuredAppendBarcodeId()); - * echo("Aztec barcodes count: " . $result->getExtended()->getAztec()->getStructuredAppendBarcodesCount()); - * echo("Aztec file ID: " . $result->getExtended()->getAztec()->getStructuredAppendFileId()); - * echo("Aztec is reader initialization: " . $result->getExtended()->getAztec()->isReaderInitialization()); - * } - * @endcode - */ -class AztecExtendedParameters implements Communicator -{ - private AztecExtendedParametersDTO $aztecExtendedParametersDTO; - - /** - * @return AztecExtendedParametersDTO instance - */ - private function getAztecExtendedParametersDTO() : AztecExtendedParametersDTO - { - return $this->aztecExtendedParametersDTO; - } - - /** - * @param $aztecExtendedParametersDTO - */ - private function setAztecExtendedParametersDTO($aztecExtendedParametersDTO): void - { - $this->aztecExtendedParametersDTO = $aztecExtendedParametersDTO; - } - - function __construct(AztecExtendedParametersDTO $aztecExtendedParametersDTO) - { - $this->aztecExtendedParametersDTO = $aztecExtendedParametersDTO; - $this->obtainDto(); - $this->initFieldsFromDto(); - } - - public function obtainDto(...$args) - { - // TODO: Implement obtainDto() method. - } - - public function initFieldsFromDto(): void - { - // TODO: Implement init() method. - } - - /** - *Gets the Aztec structured append mode barcodes count. Default value is 0. Count must be a value from 1 to 26.
Value: The barcodes count of the Aztec structured append mode. - */ - public function getStructuredAppendBarcodesCount(): int - { - return $this->getAztecExtendedParametersDTO()->structuredAppendBarcodesCount; - } - - /** - *Gets the ID of the Aztec structured append mode barcode. ID starts from 1 and must be less or equal to barcodes count. Default value is 0.
Value: The barcode ID of the Aztec structured append mode. - */ - public function getStructuredAppendBarcodeId(): int - { - return $this->getAztecExtendedParametersDTO()->structuredAppendBarcodeId; - } - - /** - *Gets the File ID of the Aztec structured append mode. Default value is empty string
Value: The File ID of the Aztec structured append mode. - */ - public function getStructuredAppendFileId(): string - { - return $this->getAztecExtendedParametersDTO()->structuredAppendFileId; - } - - /** - *- * Indicates whether code is used for instruct reader to interpret the following data as instructions for initialization or reprogramming of the bar code reader. - * Default value is false. - *
- */ - public function isReaderInitialization(): bool - { - return $this->getAztecExtendedParametersDTO()->readerInitialization; - } - - /** - *- * Returns a value indicating whether this instance is equal to a specified {@code AztecExtendedParameters} value. - *
- * @param AztecExtendedParameters $obj - * @return bool ```php - */ - public function equals(AztecExtendedParameters $obj): bool - { - $thriftConnection = new ThriftConnection(); - $client = $thriftConnection->openConnection(); - $isEquals = $client->AztecExtendedParameters_equals($this->getAztecExtendedParametersDTO(), $obj->getAztecExtendedParametersDTO()); - $thriftConnection->closeConnection(); - - return $isEquals; - } - - /** - *- * Returns a human-readable string representation of this {@code AztecExtendedParameters}. - *
- * @return string that represents this {@code AztecExtendedParameters}. - */ - public function toString(): string - { - return $this->getAztecExtendedParametersDTO()->toString; - } -} - -/** - *- * Stores a Codabar additional information of recognized barcode - *
- */ -class CodabarExtendedParameters implements Communicator -{ - private CodabarExtendedParametersDTO $codabarExtendedParametersDTO; - - /** - * @return CodabarExtendedParametersDTO instance - */ - private function getCodabarExtendedParametersDTO() : CodabarExtendedParametersDTO - { - return $this->codabarExtendedParametersDTO; - } - - /** - * @param $codabarExtendedParametersDTO - */ - private function setCodabarExtendedParametersDTO($codabarExtendedParametersDTO): void - { - $this->codabarExtendedParametersDTO = $codabarExtendedParametersDTO; - } - - function __construct(CodabarExtendedParametersDTO $codabarExtendedParametersDTO) - { - $this->codabarExtendedParametersDTO = $codabarExtendedParametersDTO; - $this->obtainDto(); - $this->initFieldsFromDto(); - } - - public function obtainDto(...$args) - { - // TODO: Implement obtainDto() method. - } - - public function initFieldsFromDto(): void - { - // TODO: Implement init() method. - } - - /** - *- * Gets or sets a Codabar start symbol. - * Default value: CodabarSymbol.A - *
- */ - public function getCodabarStartSymbol() :int - { - return $this->getCodabarExtendedParametersDTO()->codabarStartSymbol; - } - - /** - *- * Gets or sets a Codabar start symbol. - * Default value: CodabarSymbol.A - *
- */ - public function setCodabarStartSymbol(int $value) : void - { - $this->getCodabarExtendedParametersDTO()->codabarStartSymbol = $value; - } - - /** - *- * Gets or sets a Codabar stop symbol. - * Default value: CodabarSymbol.A - *
- */ - public function getCodabarStopSymbol() : int - { - return $this->getCodabarExtendedParametersDTO()->codabarStopSymbol; - } - - /** - *- * Gets or sets a Codabar stop symbol. - * Default value: CodabarSymbol.A - *
- */ - public function setCodabarStopSymbol(int $value) : void - { - $this->getCodabarExtendedParametersDTO()->codabarStopSymbol = $value; - } - - /** - *- * Returns a value indicating whether this instance is equal to a specified {@code AztecExtendedParameters} value. - *
- * @param CodabarExtendedParameters $obj - * @return bool ```php - */ - public function equals(CodabarExtendedParameters $obj): bool - { - $thriftConnection = new ThriftConnection(); - $client = $thriftConnection->openConnection(); - $isEquals = $client->CodabarExtendedParameters_equals($this->getCodabarExtendedParametersDTO(), $obj->getCodabarExtendedParametersDTO()); - $thriftConnection->closeConnection(); - - return $isEquals; - } - - /** - *- * Returns a human-readable string representation of this {@code AztecExtendedParameters}. - *
- * @return string that represents this {@code AztecExtendedParameters}. - */ - public function toString(): string - { - return $this->getCodabarExtendedParametersDTO()->toString; - } -} - - -/** - *- * Stores special data of {@code GS1 Composite Bar} recognized barcode - *
- */ -class GS1CompositeBarExtendedParameters implements Communicator -{ - private GS1CompositeBarExtendedParametersDTO $gs1CompositeBarExtendedParameters; - - /** - * @return GS1CompositeBarExtendedParametersDTO instance - */ - private function getGS1CompositeBarExtendedParametersDTO() : GS1CompositeBarExtendedParametersDTO - { - return $this->gs1CompositeBarExtendedParameters; - } - - /** - * @param $gs1CompositeBarExtendedParameters - */ - private function setGS1CompositeBarExtendedParametersDTO($gs1CompositeBarExtendedParameters): void - { - $this->gs1CompositeBarExtendedParameters = $gs1CompositeBarExtendedParameters; - } - - function __construct(GS1CompositeBarExtendedParametersDTO $gs1CompositeBarExtendedParameters) - { - $this->gs1CompositeBarExtendedParameters = $gs1CompositeBarExtendedParameters; - $this->obtainDto(); - $this->initFieldsFromDto(); - } - - public function obtainDto(...$args) - { - // TODO: Implement obtainDto() method. - } - - public function initFieldsFromDto(): void - { - // TODO: Implement init() method. - } - - /** - *Gets the 1D (linear) barcode type of GS1 Composite
Value: 2D barcode type - */ - public function getOneDType(): int - { - return $this->getGS1CompositeBarExtendedParametersDTO()->oneDType; - } - - /** - *Gets the 1D (linear) barcode value of GS1 Composite
Value: 1D barcode value - */ - public function getOneDCodeText(): string - { - return $this->getGS1CompositeBarExtendedParametersDTO()->oneDCodeText; - } - - /** - *Gets the 2D barcode type of GS1 Composite
Value: 2D barcode type - */ - public function getTwoDType(): int - { - return $this->getGS1CompositeBarExtendedParametersDTO()->twoDType; - } - - /** - *Gets the 2D barcode value of GS1 Composite
Value: 2D barcode value - */ - public function getTwoDCodeText(): string - { - return $this->getGS1CompositeBarExtendedParametersDTO()->twoDCodeText; - } - - /** - *- * Returns a value indicating whether this instance is equal to a specified {@code GS1CompositeBarExtendedParameters} value. - *
- * @param GS1CompositeBarExtendedParameters $obj - * @return bool ```php - */ - public function equals(GS1CompositeBarExtendedParameters $obj): bool - { - $thriftConnection = new ThriftConnection(); - $client = $thriftConnection->openConnection(); - $isEquals = $client->GS1CompositeBarExtendedParameters_equals($this->getGS1CompositeBarExtendedParametersDTO(), $obj->getGS1CompositeBarExtendedParametersDTO()); - $thriftConnection->closeConnection(); - - return $isEquals; - } - - /** - *- * Returns a human-readable string representation of this {@code GS1CompositeBarExtendedParameters}. - *
- * @return string that represents this {@code GS1CompositeBarExtendedParameters}. - */ - public function toString(): string - { - return $this->getGS1CompositeBarExtendedParametersDTO()->toString; - } -} - - -/** - * Contains the data of subtype for Code128 type barcode - */ -class Code128DataPortion implements Communicator -{ - private Code128DataPortionDTO $code128DataPortionDTO; - - /** - * @return Code128DataPortionDTO instance - */ - private function getCode128DataPortionDTO() : Code128DataPortionDTO - { - return $this->code128DataPortionDTO; - } - - /** - * @param $code128DataPortionDTO - */ - private function setCode128DataPortionDTO($code128DataPortionDTO): void - { - $this->code128DataPortionDTO = $code128DataPortionDTO; - } - - function __construct(Code128DataPortionDTO $code128DataPortionDTO) - { - $this->code128DataPortionDTO = $code128DataPortionDTO; - $this->obtainDto(); - $this->initFieldsFromDto(); - } - - public function obtainDto(...$args) - { - // TODO: Implement obtainDto() method. - } - - public function initFieldsFromDto(): void - { - // TODO: Implement init() method. - } - - /** - * Gets the part of code text related to subtype. - * - * @return string The part of code text related to subtype - */ - public final function getData(): string - { - try { - return $this->getCode128DataPortionDTO()->data; - } catch (Exception $ex) { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - /** - * Gets the type of Code128 subset - * - * @return int The type of Code128 subset - */ - public final function getCode128SubType(): int - { - try { - return $this->getCode128DataPortionDTO()->code128SubType; - } catch (Exception $ex) { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - /** - * Returns a human-readable string representation of this {Code128DataPortion}. - * @return string A string that represents this {Code128DataPortion}. - */ - public function toString(): string - { - $thriftConnection = new ThriftConnection(); - $client = $thriftConnection->openConnection(); - $str = $client->Code128DataPortion_toString($this->getCode128DataPortionDTO()); - $thriftConnection->closeConnection(); - - return $str; - } -} - -class RecognitionAbortedException extends Exception -{ - private ?int $executionTime; - - /** - * Gets the execution time of current recognition session - * @return int The execution time of current recognition session - */ - public function getExecutionTime(): int - { - return $this->executionTime; - } - - /** - * Sets the execution time of current recognition session - * @param int $value The execution time of current recognition session - */ - public function setExecutionTime(int $value): void - { - $this->executionTime = $value; - } - - /** - * Initializes a new instance of theclass with specified recognition abort message. - * @param $message null|string The error message of the exception. - * @param $executionTime null|int The execution time of current recognition session. - */ - public function __construct(?string $message, ?int $executionTime) - { - parent::__construct($message); - $this->executionTime = $executionTime; - } -} - -/** - * Specify the type of barcode to read. - * - * This sample shows how to detect Code39 and Code128 barcodes. - * @code - * $reader = new BarCodeReader("test.png", null, array(DecodeType::CODE_39, DecodeType::CODE_128)); - * foreach($reader->readBarCodes() as $result) - * { - * print("BarCode Type: ".$result->getCodeTypeName()); - * print("BarCode CodeText: ".$result->getCodeText()); - * } - * @endcode - */ -class DecodeType -{ - /** - * Unspecified decode type. - */ - const NONE = -1; - - /** - * Specifies that the data should be decoded with { CODABAR} barcode specification - */ - const CODABAR = 0; - - /** - * Specifies that the data should be decoded with { CODE 11} barcode specification - */ - const CODE_11 = 1; - - /** - * - * Specifies that the data should be decoded with {@code Code 39} basic charset barcode specification: ISO/IEC 16388 - *
- */ - const CODE_39 = 2; - - /** - *- * Specifies that the data should be decoded with {@code Code 39} full ASCII charset barcode specification: ISO/IEC 16388 - *
- */ - const CODE_39_FULL_ASCII = 3; - - /** - *- * Specifies that the data should be decoded with {@code CODE 93} barcode specification - *
- */ - const CODE_93 = 5; - - /** - * Specifies that the data should be decoded with { CODE 128} barcode specification - */ - const CODE_128 = 6; - - /** - * Specifies that the data should be decoded with { GS1 CODE 128} barcode specification - */ - const GS_1_CODE_128 = 7; - - /** - * Specifies that the data should be decoded with { EAN-8} barcode specification - */ - const EAN_8 = 8; - - /** - * Specifies that the data should be decoded with { EAN-13} barcode specification - */ - const EAN_13 = 9; - - /** - * Specifies that the data should be decoded with { EAN14} barcode specification - */ - const EAN_14 = 10; - - /** - * Specifies that the data should be decoded with { SCC14} barcode specification - */ - const SCC_14 = 11; - - /** - * Specifies that the data should be decoded with { SSCC18} barcode specification - */ - const SSCC_18 = 12; - - /** - * Specifies that the data should be decoded with { UPC-A} barcode specification - */ - const UPCA = 13; - - /** - * Specifies that the data should be decoded with { UPC-E} barcode specification - */ - const UPCE = 14; - - /** - * Specifies that the data should be decoded with { ISBN} barcode specification - */ - const ISBN = 15; - - /** - * Specifies that the data should be decoded with { Standard 2 of 5} barcode specification - */ - const STANDARD_2_OF_5 = 16; - - /** - * Specifies that the data should be decoded with { INTERLEAVED 2 of 5} barcode specification - */ - const INTERLEAVED_2_OF_5 = 17; - - /** - * Specifies that the data should be decoded with { Matrix 2 of 5} barcode specification - */ - const MATRIX_2_OF_5 = 18; - - /** - * Specifies that the data should be decoded with { Italian Post 25} barcode specification - */ - const ITALIAN_POST_25 = 19; - - /** - * Specifies that the data should be decoded with { IATA 2 of 5} barcode specification. IATA (International Air Transport Association) uses this barcode for the management of air cargo. - */ - const IATA_2_OF_5 = 20; - - /** - * Specifies that the data should be decoded with { ITF14} barcode specification - */ - const ITF_14 = 21; - - /** - * Specifies that the data should be decoded with { ITF6} barcode specification - */ - const ITF_6 = 22; - - /** - * Specifies that the data should be decoded with { MSI Plessey} barcode specification - */ - const MSI = 23; - - /** - * Specifies that the data should be decoded with { VIN} (Vehicle Identification Number) barcode specification - */ - const VIN = 24; - - /** - * Specifies that the data should be decoded with { DeutschePost Ident code} barcode specification - */ - const DEUTSCHE_POST_IDENTCODE = 25; - - /** - * Specifies that the data should be decoded with { DeutschePost Leit code} barcode specification - */ - const DEUTSCHE_POST_LEITCODE = 26; - - /** - * Specifies that the data should be decoded with { OPC} barcode specification - */ - const OPC = 27; - - /** - * Specifies that the data should be decoded with { PZN} barcode specification. This symbology is also known as Pharma Zentral Nummer - */ - const PZN = 28; - - /** - * Specifies that the data should be decoded with { Pharmacode} barcode. This symbology is also known as Pharmaceutical BINARY Code - */ - const PHARMACODE = 29; - - /** - * Specifies that the data should be decoded with { DataMatrix} barcode symbology - */ - const DATA_MATRIX = 30; - - /** - * Specifies that the data should be decoded with { GS1DataMatrix} barcode symbology - */ - const GS_1_DATA_MATRIX = 31; - - /** - * Specifies that the data should be decoded with { QR Code} barcode specification - */ - const QR = 32; - - /** - * Specifies that the data should be decoded with { Aztec} barcode specification - */ - const AZTEC = 33; - - /** - *- * Specifies that the data should be decoded with {@code GS1 Aztec} barcode specification - *
- */ - const GS_1_AZTEC = 81; - - /** - * Specifies that the data should be decoded with { Pdf417} barcode symbology - */ - const PDF_417 = 34; - - /** - * Specifies that the data should be decoded with { MacroPdf417} barcode specification - */ - const MACRO_PDF_417 = 35; - - /** - * Specifies that the data should be decoded with { MicroPdf417} barcode specification - */ - const MICRO_PDF_417 = 36; - - /** - * Specifies that the data should be decoded with MicroPdf417 barcode specification - */ - const GS_1_MICRO_PDF_417 = 82; - - /** - * Specifies that the data should be decoded with { CodablockF} barcode specification - */ - const CODABLOCK_F = 65; - /** - * Specifies that the data should be decoded with Royal Mail Mailmark barcode specification. - */ - const MAILMARK = 66; - - /** - * Specifies that the data should be decoded with { Australia Post} barcode specification - */ - const AUSTRALIA_POST = 37; - - /** - * Specifies that the data should be decoded with { Postnet} barcode specification - */ - const POSTNET = 38; - - /** - * Specifies that the data should be decoded with { Planet} barcode specification - */ - const PLANET = 39; - - /** - * Specifies that the data should be decoded with USPS { OneCode} barcode specification - */ - const ONE_CODE = 40; - - /** - * Specifies that the data should be decoded with { RM4SCC} barcode specification. RM4SCC (Royal Mail 4-state Customer Code) is used for automated mail sort process in UK. - */ - const RM_4_SCC = 41; - - /** - * Specifies that the data should be decoded with { GS1 DATABAR omni-directional} barcode specification - */ - const DATABAR_OMNI_DIRECTIONAL = 42; - - /** - * Specifies that the data should be decoded with { GS1 DATABAR truncated} barcode specification - */ - const DATABAR_TRUNCATED = 43; - - /** - * Specifies that the data should be decoded with { GS1 DATABAR limited} barcode specification - */ - const DATABAR_LIMITED = 44; - - /** - * Specifies that the data should be decoded with { GS1 DATABAR expanded} barcode specification - */ - const DATABAR_EXPANDED = 45; - - /** - * Specifies that the data should be decoded with { GS1 DATABAR stacked omni-directional} barcode specification - */ - const DATABAR_STACKED_OMNI_DIRECTIONAL = 53; - - /** - * Specifies that the data should be decoded with { GS1 DATABAR stacked} barcode specification - */ - const DATABAR_STACKED = 54; - - /** - * Specifies that the data should be decoded with { GS1 DATABAR expanded stacked} barcode specification - */ - const DATABAR_EXPANDED_STACKED = 55; - - /** - * Specifies that the data should be decoded with { Patch code} barcode specification. Barcode symbology is used for automated scanning - */ - const PATCH_CODE = 46; - - /** - * Specifies that the data should be decoded with { ISSN} barcode specification - */ - const ISSN = 47; - - /** - * Specifies that the data should be decoded with { ISMN} barcode specification - */ - const ISMN = 48; - - /** - * Specifies that the data should be decoded with { Supplement(EAN2, EAN5)} barcode specification - */ - const SUPPLEMENT = 49; - - /** - * Specifies that the data should be decoded with { Australian Post Domestic eParcel Barcode} barcode specification - */ - const AUSTRALIAN_POSTE_PARCEL = 50; - - /** - * Specifies that the data should be decoded with { Swiss Post Parcel Barcode} barcode specification - */ - const SWISS_POST_PARCEL = 51; - - /** - * Specifies that the data should be decoded with { SCode16K} barcode specification - */ - const CODE_16_K = 52; - - /** - * Specifies that the data should be decoded with { MicroQR Code} barcode specification - */ - const MICRO_QR = 56; - - /** - * Specifies that the data should be decoded with RectMicroQR (rMQR) Code barcode specification - */ - const RECT_MICRO_QR = 83; - - /** - * Specifies that the data should be decoded with { CompactPdf417} (Pdf417Truncated) barcode specification - */ - const COMPACT_PDF_417 = 57; - - /** - * Specifies that the data should be decoded with { GS1 QR} barcode specification - */ - const GS_1_QR = 58; - - /** - * Specifies that the data should be decoded with { MaxiCode} barcode specification - */ - const MAXI_CODE = 59; - - /** - * Specifies that the data should be decoded with { MICR E-13B} blank specification - */ - const MICR_E_13_B = 60; - - /** - * Specifies that the data should be decoded with { Code32} blank specification - */ - const CODE_32 = 61; - - /** - * Specifies that the data should be decoded with { DataLogic 2 of 5} blank specification - */ - const DATA_LOGIC_2_OF_5 = 62; - - /** - * Specifies that the data should be decoded with { DotCode} blank specification - */ - const DOT_CODE = 63; - - /** - *- * Specifies that the data should be decoded with {@code GS1 DotCode} blank specification - *
- */ - const GS_1_DOT_CODE = 77; - - /** - * Specifies that the data should be decoded with { DotCode} blank specification - */ - const DUTCH_KIX = 64; - - /** - *- * Specifies that the data should be decoded with {@code HIBC LIC Code39} blank specification - *
- */ - const HIBC_CODE_39_LIC = 67; - - /** - *- * Specifies that the data should be decoded with {@code HIBC LIC Code128} blank specification - *
- */ - const HIBC_CODE_128_LIC = 68; - - /** - *- * Specifies that the data should be decoded with {@code HIBC LIC Aztec} blank specification - *
- */ - const HIBC_AZTEC_LIC = 69; - - /** - *- * Specifies that the data should be decoded with {@code HIBC LIC DataMatrix} blank specification - *
- */ - const HIBC_DATA_MATRIX_LIC = 70; - - /** - *- * Specifies that the data should be decoded with {@code HIBC LIC QR} blank specification - *
- */ - const HIBCQRLIC = 71; - - /** - *- * Specifies that the data should be decoded with {@code HIBC PAS Code39} blank specification - *
- */ - const HIBC_CODE_39_PAS = 72; - - /** - *- * Specifies that the data should be decoded with {@code HIBC PAS Code128} blank specification - *
- */ - const HIBC_CODE_128_PAS = 73; - - /** - *- * Specifies that the data should be decoded with {@code HIBC PAS Aztec} blank specification - *
- */ - const HIBC_AZTEC_PAS = 74; - - /** - *- * Specifies that the data should be decoded with {@code HIBC PAS DataMatrix} blank specification - *
- */ - const HIBC_DATA_MATRIX_PAS = 75; - - /** - *- * Specifies that the data should be decoded with {@code HIBC PAS QR} blank specification - *
- */ - const HIBCQRPAS = 76; - - /** - * Specifies that the data should be decoded with Han Xin Code blank specification - */ - const HAN_XIN = 78; - - /** - * Specifies that the data should be decoded with Han Xin Code blank specification - */ - const GS_1_HAN_XIN = 79; - - /** - *- * Specifies that the data should be decoded with {@code GS1 Composite Bar} barcode specification - *
- */ - const GS_1_COMPOSITE_BAR = 80; - - /** - * Specifies that data will be checked with all of 1D barcode symbologies - */ - const TYPES_1D = 97; - - /** - * Specifies that data will be checked with all of 1.5D POSTAL barcode symbologies, like Planet, Postnet, AustraliaPost, OneCode, RM4SCC, DutchKIX - */ - const POSTAL_TYPES = 95; - - /** - * Specifies that data will be checked with most commonly used symbologies - */ - const MOST_COMMON_TYPES = 96; - - /** - * Specifies that data will be checked with all of 2D barcode symbologies - */ - const TYPES_2D = 98; - - /** - * Specifies that data will be checked with all available symbologies - */ - const ALL_SUPPORTED_TYPES = 99; - - /** - * Determines if the specified BaseDecodeType contains any 1D barcode symbology - * @param int $symbology barcode symbology - * @return bool true if BaseDecodeType contains any 1D barcode symbology; otherwise, returns false. - */ - public static function is1D(int $symbology): bool - { - try { - $thriftConnection = new ThriftConnection(); - $client = $thriftConnection->openConnection(); - $isEquals = $client->DecodeType_is1D($symbology); - $thriftConnection->closeConnection(); - return $isEquals; - } catch (Exception $ex) { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - /** - * Determines if the specified BaseDecodeType contains any Postal barcode symbology - * @param int symbology The BaseDecodeType to test - * @return bool Returns true if BaseDecodeType contains any Postal barcode symbology; otherwise, returns false. - */ - public static function isPostal(int $symbology): bool - { - try { - $thriftConnection = new ThriftConnection(); - $client = $thriftConnection->openConnection(); - $isEquals = $client->DecodeType_isPostal($symbology); - $thriftConnection->closeConnection(); - return $isEquals; - } catch (Exception $ex) { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - /** - * Determines if the specified BaseDecodeType contains any 2D barcode symbology - * @param int symbology The BaseDecodeType to test. - * @return bool Returns true if BaseDecodeType contains any 2D barcode symbology; otherwise, returns false. - */ - public static function is2D(int $symbology): bool - { - try { - $thriftConnection = new ThriftConnection(); - $client = $thriftConnection->openConnection(); - $isEquals = $client->DecodeType_is2D($symbology); - $thriftConnection->closeConnection(); - return $isEquals; - } catch (Exception $ex) { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } - - /** - * Determines if the BaseDecodeType array contains specified barcode symbology - * @param int $expectedDecodeType - * @param array $decodeTypes the BaseDecodeType array - * @return bool - * @throws BarcodeException - */ - public static function containsAny(int $expectedDecodeType, array $decodeTypes): bool - { - try { - if (in_array($expectedDecodeType, $decodeTypes, true)) { - return true; - } - return false; - } catch (Exception $ex) { - throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); - } - } -} - - -/** - * Contains types of Code128 subset - */ -class Code128SubType -{ - /** - * ASCII characters 00 to 95 (0–9, A–Z and control codes), special characters, and FNC 1–4 /// - */ - const CODE_SET_A = 1; - - /** - * ASCII characters 32 to 127 (0–9, A–Z, a–z), special characters, and FNC 1–4 /// - */ - const CODE_SET_B = 2; - - /** - * 00–99 (encodes two digits with a single code point) and FNC1 /// - */ - const CODE_SET_C = 3; -} - -/** - * Defines the interpreting type(C_TABLE or N_TABLE) of customer information for AustralianPost BarCode. - */ -class CustomerInformationInterpretingType -{ - - /** - * Use C_TABLE to interpret the customer information. Allows A..Z, a..z, 1..9, space and # sing. - * - * @code - * $generator = new BarcodeGenerator(EncodeTypes::AUSTRALIA_POST, "5912345678ABCde"); - * $generator->getParameters()->getBarcode()->getAustralianPost()->setAustralianPostEncodingTable(CustomerInformationInterpretingType::C_TABLE); - * $image = $generator->generateBarcodeImage(BarcodeImageFormat::PNG); - * $reader = new BarCodeReader($image, DecodeType::AUSTRALIA_POST); - * $reader->setCustomerInformationInterpretingType(CustomerInformationInterpretingType::C_TABLE); - * foreach($reader->readBarCodes() as $result) - * { - * print("BarCode Type: ".$result->getCodeType()); - * print("BarCode CodeText: ".$result->getCodeText()); - * } - * @endcode - */ - const C_TABLE = 0; - - /** - * Use N_TABLE to interpret the customer information. Allows digits. - * - * @code - * $generator = new BarcodeGenerator(EncodeTypes::AUSTRALIA_POST, "59123456781234567"); - * $generator->getParameters()->getBarcode()->getAustralianPost()->setAustralianPostEncodingTable(CustomerInformationInterpretingType::N_TABLE); - * $image = $generator->generateBarcodeImage(BarcodeImageFormat::PNG); - * $reader = new BarCodeReader($image, DecodeType::AUSTRALIA_POST); - * $reader->setCustomerInformationInterpretingType(CustomerInformationInterpretingType::N_TABLE); - * foreach($reader->readBarCodes() as $result) - * { - * print("BarCode Type: ".$result->getCodeType()); - * print("BarCode CodeText: ".$result->getCodeText()); - * } - * @endcode - */ - const N_TABLE = 1; - - /** - * Do not interpret the customer information. Allows 0, 1, 2 or 3 symbol only. - * - * @code - * $generator = new BarcodeGenerator(EncodeTypes::AUSTRALIA_POST, "59123456780123012301230123"); - * $generator->getParameters()->getBarcode()->getAustralianPost()->setAustralianPostEncodingTable(CustomerInformationInterpretingType::OTHER); - * $image = $generator->generateBarcodeImage(BarcodeImageFormat::PNG); - * $reader = new BarCodeReader($image, DecodeType::AUSTRALIA_POST); - * $reader->setCustomerInformationInterpretingType(CustomerInformationInterpretingType::OTHER)); - * foreach($reader->readBarCodes() as $result) - * { - * print("BarCode Type: ".$result->getCodeType()); - * print("BarCode CodeText: ".$result->getCodeText()); - * } - * @endcode - */ - const OTHER = 2; -} - -/** - * Contains recognition confidence level - * - * This sample shows how BarCodeConfidence changed, depending on barcode type - * - * Moderate confidence - * @code - * $generator = new BarcodeGenerator(EncodeTypes::CODE_128, "12345"); - * $generator->save("test.png"); - * $reader = new BarCodeReader("test.png", null, array(DecodeType::CODE_39, DecodeType::CODE_128)); - * foreach($reader->readBarCodes() as $result) - * { - * print("BarCode Type: ".$result->getCodeTypeName()); - * print("BarCode CodeText: ".$result->getCodeText()); - * print("BarCode Confidence: ".$result->getConfidence()); - * print("BarCode ReadingQuality: ".$result->getReadingQuality()); - * } - * @endcode - * - * Strong confidence - * @code - * $generator = new BarcodeGenerator(EncodeTypes::QR, "12345"); - * $generator->save("test.png"); - * $reader = new BarCodeReader("test.png", null, array(DecodeType::CODE_39, DecodeType::QR)); - * foreach($reader->readBarCodes() as $result) - * { - * print("BarCode Type: ".$result->getCodeTypeName()); - * print("BarCode CodeText: ".$result->getCodeText()); - * print("BarCode Confidence: ".$result->getConfidence()); - * print("BarCode ReadingQuality: ".$result->getReadingQuality()); - * } - * @endcode - */ -class BarCodeConfidence -{ - /** - * Recognition confidence of barcode where codetext was not recognized correctly or barcode was detected as posible fake - * - */ - const NONE = 0; - - /** - * Recognition confidence of barcode (mostly 1D barcodes) with weak checksumm or even without it. Could contains some misrecognitions in codetext - * or even fake recognitions if is low - * - * @see BarCodeResult.ReadingQuality - */ - const MODERATE = 80; - - /** - * Recognition confidence which was confirmed with BCH codes like Reed–Solomon. There must not be errors in read codetext or fake recognitions - */ - const STRONG = 100; -} - -/** - *- *
- * Deconvolution (image restorations) mode which defines level of image degradation. Originally deconvolution is a function which can restore image degraded - * (convoluted) by any natural function like blur, during obtaining image by camera. Because we cannot detect image function which corrupt the image, - * we have to check most well know functions like sharp or mathematical morphology. - *
- *- */ -class DeconvolutionMode -{ - /** - *- * This sample shows how to use Deconvolution mode - *- * @code - * $reader = new BarCodeReader("test.png", null, array(DecodeType::CODE_39_FULL_ASCII, DecodeType::CODE_128)); - * $reader->getQualitySettings()->setDeconvolution(DeconvolutionMode::SLOW); - * foreach($reader->readBarCodes() as $result) - * { - * print("BarCode CodeText: " . $result->getCodeText()); - * } - * @endcode - *- *Enables fast deconvolution methods for high quality images.
- */ - const FAST = 0; - /** - *Enables normal deconvolution methods for common images.
- */ - const NORMAL = 1; - /** - *Enables slow deconvolution methods for low quality images.
- */ - const SLOW = 2; -} - -/** - *- *
- * Mode which enables or disables additional recognition of barcodes on images with inverted colors (luminance). - *
- *- */ -class InverseImageMode -{ - /** - *- * This sample shows how to use InverseImage mode - *- * - * @code - * $reader = new BarCodeReader("test.png", null, array(DecodeType::CODE_39_FULL_ASCII, DecodeType::CODE_128)); - * $reader->getQualitySettings()->setInverseImage(InverseImageMode::ENABLED); - * foreach($reader->readBarCodes() as $result) - * { - * print("BarCode CodeText: " . $result->getCodeText()); - * } - * @endcode - *- *At this time the same as Disabled. Disables additional recognition of barcodes on inverse images.
- */ - const AUTO = 0; - /** - *Disables additional recognition of barcodes on inverse images.
- */ - const DISABLED = 1; - /** - *Enables additional recognition of barcodes on inverse images
- */ - const ENABLED = 2; -} - -/** - *- *
- * Recognition mode which sets size (from 1 to infinity) of barcode minimal element: matrix cell or bar. - *
- *- */ -class XDimensionMode -{ - /** - *- * This sample shows how to use XDimension mode - *- * @code - * $reader = new BarCodeReader("test.png", null, array(DecodeType::CODE_39_FULL_ASCII, DecodeType::CODE_128)); - * $reader->getQualitySettings()->setXDimension(XDimensionMode::SMALL); - * foreach($reader->readBarCodes() as $result) - * { - * print("BarCode CodeText: " . $result->getCodeText()); - * } - * @endcode - *- *Value of XDimension is detected by AI (SVM). At this time the same as Normal
- */ - const AUTO = 0; - /** - *Detects barcodes with small XDimension in 1 pixel or more with quality from BarcodeQuality
- */ - const SMALL = 1; - /** - *Detects barcodes with classic XDimension in 2 pixels or more with quality from BarcodeQuality or high quality barcodes.
- */ - const NORMAL = 2; - /** - *Detects barcodes with large XDimension with quality from BarcodeQuality captured with high-resolution cameras.
- */ - const LARGE = 3; - /** - *Detects barcodes from size set in MinimalXDimension with quality from BarcodeQuality
- */ - const USE_MINIMAL_X_DIMENSION = 4; -} - -/** - *- *
- * Mode which enables or disables additional recognition of color barcodes on color images. - *
- *- */ -class ComplexBackgroundMode -{ - /** - *- * This sample shows how to use ComplexBackground mode - *- * @code - * $reader = new BarCodeReader("test.png", null, array(DecodeType::CODE_39_FULL_ASCII, DecodeType::CODE_128)); - * $reader->getQualitySettings()->setComplexBackground(ComplexBackgroundMode::ENABLED); - * foreach($reader->readBarCodes() as $result) - * { - * print("BarCode CodeText: " . $result->getCodeText()); - * } - * @endcode - *- *At this time the same as Disabled. Disables additional recognition of color barcodes on color images.
- */ - const AUTO = 0; - /** - *Disables additional recognition of color barcodes on color images.
- */ - const DISABLED = 1; - /** - *Enables additional recognition of color barcodes on color images.
- */ - const ENABLED = 2; - -} - -/** - *- *
- * Mode which enables methods to recognize barcode elements with the selected quality. Barcode element with lower quality requires more hard methods which slows the recognition. - *
- *- */ -class BarcodeQualityMode -{ - /** - *- * This sample shows how to use BarcodeQuality mode - *- * @code - * $reader = new BarCodeReader("test.png", null, array(DecodeType::CODE_39_FULL_ASCII, DecodeType::CODE_128)); - * $reader->getQualitySettings()->setBarcodeQuality(BarcodeQualityMode::LOW); - * foreach($reader->readBarCodes() as $result) - * { - * print("BarCode CodeText: " . $result->getCodeText()); - * } - * @endcode - *- *Enables recognition methods for High quality barcodes.
- */ - const HIGH = 0; - /** - *Enables recognition methods for Common(Normal) quality barcodes.
- */ - const NORMAL = 1; - /** - *Enables recognition methods for Low quality barcodes.
- */ - const LOW = 2; -} - - -/** - * Enable checksum validation during recognition for 1D barcodes. - * Default is treated as Yes for symbologies which must contain checksum, as No where checksum only possible. - * Checksum never used: Codabar - * Checksum is possible: Code39 Standard/Extended, Standard2of5, Interleaved2of5, Matrix2of5, ItalianPost25, DeutschePostIdentcode, DeutschePostLeitcode, VIN - * Checksum always used: Rest symbologies - * - * This sample shows influence of ChecksumValidation on recognition quality and results - * @code - * $generator = new BarcodeGenerator(EncodeTypes::EAN_13, "1234567890128"); - * $generator->save("test.png", BarcodeImageFormat::PNG); - * $reader = new BarCodeReader("test.png", null, DecodeType::EAN_13); - * //checksum disabled - * $reader->setChecksumValidation(ChecksumValidation::OFF); - * foreach($reader->readBarCodes() as $result) - * { - * print("BarCode CodeText: ".$result->getCodeText()); - * print("BarCode Value: ".$result->getExtended()->getOneD()->getValue()); - * print("BarCode Checksum: ".$result->getExtended()->getOneD()->getCheckSum()); - * } - * $reader = new BarCodeReader("test.png", null, DecodeType::EAN_13); - * //checksum enabled - * $reader->setChecksumValidation(ChecksumValidation::ON); - * foreach($reader->readBarCodes() as $result) - * { - * print("BarCode CodeText: ".$result->getCodeText()); - * print("BarCode Value: ".$result->getExtended()->getOneD()->getValue()); - * print("BarCode Checksum: ".$result->getExtended()->getOneD()->getCheckSum()); - * } - * @endcode - */ -class ChecksumValidation -{ - /** - * If checksum is required by the specification - it will be validated. - */ - const DEFAULT = 0; - - /** - * Always validate checksum if possible. - */ - const ON = 1; - - /** - * Do not validate checksum. - */ - const OFF = 2; -} \ No newline at end of file diff --git a/lib/Recognition/AustraliaPostSettings.php b/lib/Recognition/AustraliaPostSettings.php new file mode 100644 index 00000000..0dc8f839 --- /dev/null +++ b/lib/Recognition/AustraliaPostSettings.php @@ -0,0 +1,111 @@ +australiaPostSettingsDto; + } + + private function setAustraliaPostSettingsDto(AustraliaPostSettingsDTO $australiaPostSettingsDto): void + { + $this->australiaPostSettingsDto = $australiaPostSettingsDto; + } + + /** + * AustraliaPostSettings constructor + */ + function __construct(AustraliaPostSettingsDTO $australiaPostSettingsDto) + { + $this->australiaPostSettingsDto = $australiaPostSettingsDto; + $this->obtainDto(); + $this->initFieldsFromDto(); + } + + public function initFieldsFromDto(): void + { + } + + public function obtainDto(...$args) + { + } + + /** + * Gets or sets the Interpreting Type for the Customer Information of AustralianPost BarCode.DEFAULT is CustomerInformationInterpretingType.OTHER. + * @return int The interpreting type (CTable, NTable or Other) of customer information for AustralianPost BarCode + */ + public function getCustomerInformationInterpretingType(): int + { + return $this->getAustraliaPostSettingsDto()->customerInformationInterpretingType; + } + + /** + * Gets or sets the Interpreting Type for the Customer Information of AustralianPost BarCode.DEFAULT is CustomerInformationInterpretingType.OTHER. + * @param int $value The interpreting type (CTable, NTable or Other) of customer information for AustralianPost BarCode + */ + public function setCustomerInformationInterpretingType(int $value): void + { + $this->getAustraliaPostSettingsDto()->customerInformationInterpretingType = $value; + } + + /** + * The flag which force AustraliaPost decoder to ignore last filling patterns in Customer Information Field during decoding as CTable method. + * CTable encoding method does not have any gaps in encoding table and sequnce "333" of filling paterns is decoded as letter "z". + * + * @code + * + * $generator = new BarcodeGenerator(EncodeTypes::AUSTRALIA_POST, "5912345678AB"); + * $generator->getParameters()->getBarcode()->getAustralianPost()->setAustralianPostEncodingTable(CustomerInformationInterpretingType::C_TABLE); + * $image = generator->generateBarCodeImage(BarcodeImageFormat::PNG); + * $reader = new BarCodeReader($image, null, DecodeType::AUSTRALIA_POST); + * $reader->getBarcodeSettings()->getAustraliaPost()->setCustomerInformationInterpretingType(CustomerInformationInterpretingType::C_TABLE); + * $reader->getBarcodeSettings()->getAustraliaPost()->setIgnoreEndingFillingPatternsForCTable(true); + * foreach($reader->readBarCodes() as $result) + * echo("BarCode Type: ".$result->getCodeType()); + * echo("BarCode CodeText: ".$result->getCodeText()); + * } + * @endcode + * + * @return bool The flag which force AustraliaPost decoder to ignore last filling patterns during CTable method decoding + */ + public function getIgnoreEndingFillingPatternsForCTable(): bool + { + return $this->getAustraliaPostSettingsDto()->ignoreEndingFillingPatternsForCTable; + } + + /** + * The flag which force AustraliaPost decoder to ignore last filling patterns in Customer Information Field during decoding as CTable method. + * CTable encoding method does not have any gaps in encoding table and sequnce "333" of filling paterns is decoded as letter "z". + * + * @code + * + * $generator = new BarcodeGenerator(EncodeTypes::AUSTRALIA_POST, "5912345678AB"); + * $generator->getParameters()->getBarcode()->getAustralianPost()->setAustralianPostEncodingTable(CustomerInformationInterpretingType::C_TABLE); + * $image = generator->generateBarCodeImage(BarcodeImageFormat::PNG); + * $reader = new BarCodeReader($image, null, DecodeType::AUSTRALIA_POST); + * $reader->getBarcodeSettings()->getAustraliaPost()->setCustomerInformationInterpretingType(CustomerInformationInterpretingType::C_TABLE); + * $reader->getBarcodeSettings()->getAustraliaPost()->setIgnoreEndingFillingPatternsForCTable(true); + * foreach($reader->readBarCodes() as $result) + * echo("BarCode Type: ".$result->getCodeType()); + * echo("BarCode CodeText: ".$result->getCodeText()); + * } + * @endcode + * + * @param bool $value The flag which force AustraliaPost decoder to ignore last filling patterns during CTable method decoding + */ + public function setIgnoreEndingFillingPatternsForCTable(bool $value): void + { + $this->getAustraliaPostSettingsDto()->ignoreEndingFillingPatternsForCTable = $value; + } +} \ No newline at end of file diff --git a/lib/Recognition/AztecExtendedParameters.php b/lib/Recognition/AztecExtendedParameters.php new file mode 100644 index 00000000..b8cd7211 --- /dev/null +++ b/lib/Recognition/AztecExtendedParameters.php @@ -0,0 +1,128 @@ +save("test.png", BarcodeImageFormat::PNG); + * + * $reader = new BarCodeReader("test.png", null, DecodeType::AZTEC); + * foreach($reader->readBarCodes() as $result) + * { + * echo("BarCode type: " . $result->getCodeTypeName()); + * echo("BarCode codetext: " . $result->getCodeText()); + * echo("Aztec barcode ID: " . $result->getExtended()->getAztec()->getStructuredAppendBarcodeId()); + * echo("Aztec barcodes count: " . $result->getExtended()->getAztec()->getStructuredAppendBarcodesCount()); + * echo("Aztec file ID: " . $result->getExtended()->getAztec()->getStructuredAppendFileId()); + * echo("Aztec is reader initialization: " . $result->getExtended()->getAztec()->isReaderInitialization()); + * } + * @endcode + */ +class AztecExtendedParameters implements Communicator +{ + private AztecExtendedParametersDTO $aztecExtendedParametersDTO; + + /** + * @return AztecExtendedParametersDTO instance + */ + private function getAztecExtendedParametersDTO(): AztecExtendedParametersDTO + { + return $this->aztecExtendedParametersDTO; + } + + /** + * @param $aztecExtendedParametersDTO + */ + private function setAztecExtendedParametersDTO($aztecExtendedParametersDTO): void + { + $this->aztecExtendedParametersDTO = $aztecExtendedParametersDTO; + } + + function __construct(AztecExtendedParametersDTO $aztecExtendedParametersDTO) + { + $this->aztecExtendedParametersDTO = $aztecExtendedParametersDTO; + $this->obtainDto(); + $this->initFieldsFromDto(); + } + + public function obtainDto(...$args) + { + // TODO: Implement obtainDto() method. + } + + public function initFieldsFromDto(): void + { + // TODO: Implement init() method. + } + + /** + *Gets the Aztec structured append mode barcodes count. Default value is 0. Count must be a value from 1 to 26.
Value: The barcodes count of the Aztec structured append mode. + */ + public function getStructuredAppendBarcodesCount(): int + { + return $this->getAztecExtendedParametersDTO()->structuredAppendBarcodesCount; + } + + /** + *Gets the ID of the Aztec structured append mode barcode. ID starts from 1 and must be less or equal to barcodes count. Default value is 0.
Value: The barcode ID of the Aztec structured append mode. + */ + public function getStructuredAppendBarcodeId(): int + { + return $this->getAztecExtendedParametersDTO()->structuredAppendBarcodeId; + } + + /** + *Gets the File ID of the Aztec structured append mode. Default value is empty string
Value: The File ID of the Aztec structured append mode. + */ + public function getStructuredAppendFileId(): string + { + return $this->getAztecExtendedParametersDTO()->structuredAppendFileId; + } + + /** + *+ * Indicates whether code is used for instruct reader to interpret the following data as instructions for initialization or reprogramming of the bar code reader. + * Default value is false. + *
+ */ + public function isReaderInitialization(): bool + { + return $this->getAztecExtendedParametersDTO()->readerInitialization; + } + + /** + *+ * Returns a value indicating whether this instance is equal to a specified {@code AztecExtendedParameters} value. + *
+ * @param AztecExtendedParameters $obj + * @return bool ```php + */ + public function equals(AztecExtendedParameters $obj): bool + { + $thriftConnection = new ThriftConnection(); + $client = $thriftConnection->openConnection(); + $isEquals = $client->AztecExtendedParameters_equals($this->getAztecExtendedParametersDTO(), $obj->getAztecExtendedParametersDTO()); + $thriftConnection->closeConnection(); + + return $isEquals; + } + + /** + *+ * Returns a human-readable string representation of this {@code AztecExtendedParameters}. + *
+ * @return string that represents this {@code AztecExtendedParameters}. + */ + public function toString(): string + { + return $this->getAztecExtendedParametersDTO()->toString; + } +} \ No newline at end of file diff --git a/lib/Recognition/BarCodeConfidence.php b/lib/Recognition/BarCodeConfidence.php new file mode 100644 index 00000000..839f1f55 --- /dev/null +++ b/lib/Recognition/BarCodeConfidence.php @@ -0,0 +1,58 @@ +save("test.png"); + * $reader = new BarCodeReader("test.png", null, array(DecodeType::CODE_39, DecodeType::CODE_128)); + * foreach($reader->readBarCodes() as $result) + * { + * print("BarCode Type: ".$result->getCodeTypeName()); + * print("BarCode CodeText: ".$result->getCodeText()); + * print("BarCode Confidence: ".$result->getConfidence()); + * print("BarCode ReadingQuality: ".$result->getReadingQuality()); + * } + * @endcode + * + * Strong confidence + * @code + * $generator = new BarcodeGenerator(EncodeTypes::QR, "12345"); + * $generator->save("test.png"); + * $reader = new BarCodeReader("test.png", null, array(DecodeType::CODE_39, DecodeType::QR)); + * foreach($reader->readBarCodes() as $result) + * { + * print("BarCode Type: ".$result->getCodeTypeName()); + * print("BarCode CodeText: ".$result->getCodeText()); + * print("BarCode Confidence: ".$result->getConfidence()); + * print("BarCode ReadingQuality: ".$result->getReadingQuality()); + * } + * @endcode + */ +class BarCodeConfidence +{ + /** + * Recognition confidence of barcode where codetext was not recognized correctly or barcode was detected as posible fake + * + */ + const NONE = 0; + + /** + * Recognition confidence of barcode (mostly 1D barcodes) with weak checksumm or even without it. Could contains some misrecognitions in codetext + * or even fake recognitions if is low + * + * @see BarCodeResult.ReadingQuality + */ + const MODERATE = 80; + + /** + * Recognition confidence which was confirmed with BCH codes like Reed–Solomon. There must not be errors in read codetext or fake recognitions + */ + const STRONG = 100; +} \ No newline at end of file diff --git a/lib/Recognition/BarCodeExtendedParameters.php b/lib/Recognition/BarCodeExtendedParameters.php new file mode 100644 index 00000000..74faf6d8 --- /dev/null +++ b/lib/Recognition/BarCodeExtendedParameters.php @@ -0,0 +1,215 @@ + + * Stores extended parameters of recognized barcode + * + */ +class BarCodeExtendedParameters implements Communicator +{ + private $_oneDParameters; + private $_code128Parameters; + private $_qrParameters; + private $_pdf417Parameters; + private $_dataBarParameters; + private $_maxiCodeParameters; + private $_dotCodeExtendedParameters; + private $_dataMatrixExtendedParameters; + private $_aztecExtendedParameters; + private $_gs1CompositeBarExtendedParameters; + private BarCodeExtendedParametersDTO $barCodeExtendedParametersDTO; + private $_codabarExtendedParameters; + + /** + * @return BarCodeExtendedParametersDTO instance + */ + private function getBarCodeExtendedParametersDTO(): BarCodeExtendedParametersDTO + { + return $this->barCodeExtendedParametersDTO; + } + + /** + * @param BarCodeExtendedParametersDTO $barCodeExtendedParametersDTO + */ + private function setBarCodeExtendedParametersDTO(BarCodeExtendedParametersDTO $barCodeExtendedParametersDTO): void + { + $this->barCodeExtendedParametersDTO = $barCodeExtendedParametersDTO; + } + + function __construct(BarCodeExtendedParametersDTO $barCodeExtendedParametersDTO) + { + $this->barCodeExtendedParametersDTO = $barCodeExtendedParametersDTO; + $this->obtainDto(); + $this->initFieldsFromDto(); + } + + public function obtainDto(...$args) + { + // TODO: Implement obtainDto() method. + } + + public function initFieldsFromDto(): void + { + try + { + $this->_oneDParameters = new OneDExtendedParameters($this->getBarCodeExtendedParametersDTO()->oneDParameters); + $this->_code128Parameters = new Code128ExtendedParameters($this->getBarCodeExtendedParametersDTO()->code128Parameters); + $this->_qrParameters = new QRExtendedParameters($this->getBarCodeExtendedParametersDTO()->qrParameters); + $this->_pdf417Parameters = new Pdf417ExtendedParameters($this->getBarCodeExtendedParametersDTO()->pdf417Parameters); + $this->_dataBarParameters = new DataBarExtendedParameters($this->getBarCodeExtendedParametersDTO()->dataBarParameters); + $this->_maxiCodeParameters = new MaxiCodeExtendedParameters($this->getBarCodeExtendedParametersDTO()->maxiCodeParameters); + $this->_dotCodeExtendedParameters = new DotCodeExtendedParameters($this->getBarCodeExtendedParametersDTO()->dotCodeExtendedParameters); + $this->_dataMatrixExtendedParameters = new DataMatrixExtendedParameters($this->getBarCodeExtendedParametersDTO()->dataMatrixExtendedParameters); + $this->_aztecExtendedParameters = new AztecExtendedParameters($this->getBarCodeExtendedParametersDTO()->aztecExtendedParameters); + $this->_gs1CompositeBarExtendedParameters = new GS1CompositeBarExtendedParameters($this->getBarCodeExtendedParametersDTO()->gs1CompositeBarExtendedParameters); + $this->_codabarExtendedParameters = new CodabarExtendedParameters($this->getBarCodeExtendedParametersDTO()->codabarExtendedParameters); + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** Gets a DataBar additional information DataBarExtendedParameters of recognized barcode + * @return DataBarExtendedParameters A DataBar additional information DataBarExtendedParameters of recognized barcode + */ + public function getDataBar(): DataBarExtendedParameters + { + return $this->_dataBarParameters; + } + + /** + * Gets a MaxiCode additional informationof recognized barcode + * + * @return MaxiCodeExtendedParameters A MaxiCode additional information of recognized barcode + */ + public function getMaxiCode(): MaxiCodeExtendedParameters + { + return $this->_maxiCodeParameters; + } + + /** + * Gets a DotCode additional information{@code DotCodeExtendedParameters} of recognized barcode
Value: A DotCode additional information{@code DotCodeExtendedParameters} of recognized barcode + */ + public function getDotCode(): DotCodeExtendedParameters + { + return $this->_dotCodeExtendedParameters; + } + + /** + *Gets a DotCode additional information{@code DotCodeExtendedParameters} of recognized barcode
Value: A DotCode additional information{@code DotCodeExtendedParameters} of recognized barcode + */ + public function getDataMatrix(): DataMatrixExtendedParameters + { + return $this->_dataMatrixExtendedParameters; + } + + /** + *Gets a Aztec additional information{@code AztecExtendedParameters} of recognized barcode
Value: A Aztec additional information{@code AztecExtendedParameters} of recognized barcode + */ + public function getAztec(): AztecExtendedParameters + { + return $this->_aztecExtendedParameters; + } + + /** + *Gets a GS1CompositeBar additional information{@code GS1CompositeBarExtendedParameters} of recognized barcode
Value: A GS1CompositeBar additional information{@code GS1CompositeBarExtendedParameters} of recognized barcode + */ + public function getGS1CompositeBar(): GS1CompositeBarExtendedParameters + { + return $this->_gs1CompositeBarExtendedParameters; + } + + /** + * Gets a Codabar additional information{@code CodabarExtendedParameters} of recognized barcode + * @return CodabarExtendedParameters additional information + */ + public function getCodabar(): CodabarExtendedParameters + { + return $this->_codabarExtendedParameters; + } + + /** + * @return OneDExtendedParameters Gets a special data OneDExtendedParameters of 1D recognized barcode Value: A special data OneDExtendedParameters of 1D recognized barcode + */ + public function getOneD(): OneDExtendedParameters + { + return $this->_oneDParameters; + } + + /** + * @return Code128ExtendedParameters Gets a special data Code128ExtendedParameters of Code128 recognized barcode Value: A special data Code128ExtendedParameters of Code128 recognized barcode + */ + public function getCode128(): Code128ExtendedParameters + { + return $this->_code128Parameters; + } + + /** + * @return QRExtendedParameters Gets a QR Structured Append information QRExtendedParameters of recognized barcode Value: A QR Structured Append information QRExtendedParameters of recognized barcode + */ + public function getQR(): QRExtendedParameters + { + return $this->_qrParameters; + } + + /** + * @return Pdf417ExtendedParameters Gets a MacroPdf417 metadata information Pdf417ExtendedParameters of recognized barcode Value: A MacroPdf417 metadata information Pdf417ExtendedParameters of recognized barcode + */ + public function getPdf417(): Pdf417ExtendedParameters + { + return $this->_pdf417Parameters; + } + + /** + * Returns a value indicating whether this instance is equal to a specified BarCodeExtendedParameters value. + * + * @param BarCodeExtendedParameters $obj An System.Object value to compare to this instance. + * @return bool true if obj has the same value as this instance; otherwise, false. + */ + public function equals(BarCodeExtendedParameters $obj): bool + { + $thriftConnection = new ThriftConnection(); + $client = $thriftConnection->openConnection(); + $isEquals = $client->BarCodeExtendedParameters_equals($this->getBarCodeExtendedParametersDTO(), $obj->getBarCodeExtendedParametersDTO()); + $thriftConnection->closeConnection(); + + return $isEquals; + } + + /** + * Returns a human-readable string representation of this BarCodeExtendedParameters. + * + * @return string A string that represents this BarCodeExtendedParameters. + */ + public function toString(): string + { + try + { + return $this->getBarCodeExtendedParametersDTO()->toString; // TODO need to implement + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } +} \ No newline at end of file diff --git a/lib/Recognition/BarCodeReader.php b/lib/Recognition/BarCodeReader.php new file mode 100644 index 00000000..48817369 --- /dev/null +++ b/lib/Recognition/BarCodeReader.php @@ -0,0 +1,486 @@ +readBarCodes() as $result) + * { + * print("BarCode Type: ".$result->getCodeTypeName()); + * print("BarCode CodeText: ".$result->getCodeText()); + * } + * @endcode + */ +class BarCodeReader implements Communicator +{ + private $barCodeReaderDto; + + private function getBarCodeReaderDto(): BarcodeReaderDTO + { + return $this->barCodeReaderDto; + } + + private function setBarCodeReaderDto(BarcodeReaderDTO $barCodeReaderDto): void + { + $this->barCodeReaderDto = $barCodeReaderDto; +// $this->initFieldsFromDto(); + } + + private QualitySettings $qualitySettings; + private BarcodeSettings $barcodeSettings; + private $imageResource; + private $areas; + private $decodeTypes; + + function __construct($imageResource, $areas, $decodeTypes) + { + $this->imageResource = $imageResource; + $this->areas = $areas; + $this->decodeTypes = $decodeTypes; + $this->setBarCodeReaderDto($this->obtainDto()); //TODO redundant ? + $this->initFieldsFromDto(); + } + + public function obtainDto(...$args): BarcodeReaderDTO + { + $thriftConnection = new ThriftConnection(); + $client = $thriftConnection->openConnection(); + $barcodeReaderDTO = $client->BarcodeReader_ctor(); + $thriftConnection->closeConnection(); + return $barcodeReaderDTO; + } + + public function initFieldsFromDto() + { + $this->qualitySettings = new QualitySettings($this->barCodeReaderDto->qualitySettings); + $this->barcodeSettings = new BarcodeSettings($this->barCodeReaderDto->barcodeSettings); + + if ($this->imageResource !== null) + { + $this->initializeImageRelatedFields(); + $this->processDecodeTypes(); + } else + { + $this->validateNullState(); + } + } + + /** + * Process Image Related Parameters + */ + private function initializeImageRelatedFields(): void + { + $this->barCodeReaderDto->base64Image = CommonUtility::convertImageResourceToBase64($this->imageResource); + $this->barCodeReaderDto->areas = CommonUtility::convertAreasToStringFormattedAreas($this->areas); + } + + /** + * Detect Decode Types + */ + private function processDecodeTypes(): void + { + $decodeTypes = $this->decodeTypes; + if (is_null($decodeTypes)) + { + $decodeTypes = [DecodeType::ALL_SUPPORTED_TYPES]; + } elseif (is_int($decodeTypes)) + { + $decodeTypes = [$decodeTypes]; + $this->decodeTypes = $decodeTypes; + } elseif (!is_array($decodeTypes)) + { + throw new InvalidArgumentException("Invalid type for decodeTypes. Expected int, array, or null, got " . gettype($decodeTypes)); + } + + if (CommonUtility::isClassContainsConstantValueFromArray(DecodeType::class, $decodeTypes)) + { + $this->barCodeReaderDto->barCodeDecodeTypes = $decodeTypes; + } + } + + /** + * Ensures that when an image is missing, other parameters are also absent. + * + * @throws BarcodeException + */ + private function validateNullState(): void + { + if ($this->areas !== null || $this->decodeTypes !== null) + { + throw new BarcodeException('Illegal arguments. If $imageResource = null then $areas and $decodeTypes should be null'); + } + } + + + /** + * Determines whether any of the given decode types is included into + * @param array $decodeTypes Types to verify. + * @return bool Value is a true if any types are included into. + */ + public function containsAny(...$decodeTypes): bool + { + try + { + foreach ($decodeTypes as $decodeType) + { + if (DecodeType::containsAny($decodeType, $this->getBarCodeReaderDto()->barCodeDecodeTypes)) + return true; + } + return false; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + + protected function init(): void + { + $this->qualitySettings = new QualitySettings($this->barCodeReaderDto->qualitySettings); + $this->barcodeSettings = new BarcodeSettings($this->barCodeReaderDto->qualitySettings); + } + + /** + * Reads BarCodeResult from the image. + * + * @code + * This sample shows how to read barcodes with BarCodeReader + * $reader = new BarCodeReader("test.png", null, array(DecodeType::CODE_39, DecodeType::CODE_128)); + * foreach($reader->readBarCodes() as $result) + * print("BarCode CodeText: ".$result->getCodeText()); + * $reader = new BarCodeReader("test.png", null, array(DecodeType::CODE_39, DecodeType::CODE_128)); + * $reader->readBarCodes(); + * for($i = 0; $reader->getFoundCount() > $i; ++$i) + * print("BarCode CodeText: ".$reader->getFoundBarCodes()[i]->getCodeText()); + * + * @return array of recognized {@code BarCodeResult}s on the image. If nothing is recognized, zero array is returned. + * @throws BarcodeException + */ + public function readBarCodes(bool $passLicense = false): array + { + try + { + $thriftConnection = new ThriftConnection(); + $client = $thriftConnection->openConnection(); + // Deciding if the license should be used + $licenseContent = $passLicense ? License::getLicenseContent() : null; + // Passing the license or null + $barcodeReaderDTO = $client->BarcodeReader_readBarCodes($this->barCodeReaderDto, $licenseContent); + $this->setBarCodeReaderDto($barcodeReaderDTO); + $thriftConnection->closeConnection(); + } + catch (Exception $exc) + { + CommonUtility::println($exc->getMessage()); + CommonUtility::println("Stack trace: " . $exc->getTraceAsString()); + //TODO BARCODEPHP-919 Make fixes and improvements in exception handling on the Java and PHP sides + throw CommonUtility::convertBarcodeExceptionDto($exc); + } + return $this->getFoundBarCodes(); + } + + /** + * Gets recognized BarCodeResult array + * + * This sample shows how to read barcodes with BarCodeReader + * @code + * $reader = new BarCodeReader("test.png", DecodeType::CODE_39, DecodeType::CODE_128); + * $reader->readBarCodes(); + * for($i = 0; $reader->getFoundCount() > $i; ++$i) + * { + * print("BarCode CodeText: ". $reader->getFoundBarCodes()[$i]->getCodeText()); + * } + * @endcode + * Value: The recognized BarCodeResult array + */ + function getFoundBarCodes(): array + { + // TODO Implement not recognized behavior + $recognizedResults = array(); + $dtoRef = $this->barCodeReaderDto; + foreach ($dtoRef->foundBarCodes as $foundBarcode) + { + $recognizedResults[] = new BarCodeResult($foundBarcode); + } + + return $recognizedResults; + } + + /** + * Gets the timeout of recognition process in milliseconds. + * + * @code + * $reader = new BarCodeReader("test.png"); + * $reader->setTimeout(5000); + * foreach($reader->readBarCodes() as $result) + * print("BarCode CodeText: ".$result->getCodeText()); + * @endcode + * @return int timeout. + */ + public function getTimeout(): int + { + return $this->barCodeReaderDto->timeout; + } + + /** + * Sets the timeout of recognition process in milliseconds. + * + * @code + * $reader = new BarCodeReader("test.png"); + * $reader->setTimeout(5000); + * foreach($reader->readBarCodes() as $result) + * print("BarCode CodeText: ".$result->getCodeText()); + * @endcode + * @param int $value The timeout. + */ + public function setTimeout(int $value): void + { + $this->barCodeReaderDto->timeout = $value; + } + + /** + * Gets recognized barcodes count + * + * This sample shows how to read barcodes with BarCodeReader + * @code + * $reader = new BarCodeReader("test.png", null, DecodeType::CODE_39, DecodeType::CODE_128); + * $reader->readBarCodes(); + * for($i = 0; $reader->getFoundCount() > $i; ++$i) + * print("BarCode CodeText: ".$reader->getFoundBarCodes()[i]->getCodeText()); + * @endcode + * Value: The recognized barcodes count + */ + public function getFoundCount(): int + { + return sizeof($this->getFoundBarCodes()); + } + + /** + * QualitySettings allows to configure recognition quality and speed manually. + * You can quickly set up QualitySettings by embedded presets: HighPerformance, NormalQuality, + * HighQuality, MaxBarCodes or you can manually configure separate options. + * Default value of QualitySettings is NormalQuality. + * @code + * This sample shows how to use QualitySettings with BarCodeReader + * + * $reader = new BarCodeReader("test.png"); + * //set high performance mode + * $reader->setQualitySettings(QualitySettings::getHighPerformance()); + * foreach($reader->readBarCodes() as $result) + * print("BarCode CodeText: ".$result->getCodeText()); + * $reader = new BarCodeReader("test.png", null, array(DecodeType::CODE_39, DecodeType::CODE_128)); + * //normal quality mode is set by default + * foreach($reader->readBarCodes() as $result) + * print("BarCode CodeText: ".$result->getCodeText()); + * $reader = new BarCodeReader("test.png", null, array(DecodeType::CODE_39, DecodeType::CODE_128)); + * //set high performance mode + * $reader->setQualitySettings(QualitySettings::getHighPerformance()); + * //set separate options + * foreach($reader->readBarCodes() as $result) + * print("BarCode CodeText: ".$result->getCodeText()); + * + * @return QualitySettings to configure recognition quality and speed. + */ + public final function getQualitySettings(): QualitySettings + { + return $this->qualitySettings; + } + + /** + * QualitySettings allows to configure recognition quality and speed manually. + * You can quickly set up QualitySettings by embedded presets: HighPerformance, NormalQuality, + * HighQuality, MaxBarCodes or you can manually configure separate options. + * Default value of QualitySettings is NormalQuality. + * @code + * This sample shows how to use QualitySettings with BarCodeReader + * + * $reader = new BarCodeReader("test.png"); + * //set high performance mode + * $reader->setQualitySettings(QualitySettings::getHighPerformance()); + * foreach($reader->readBarCodes() as $result) + * print("BarCode CodeText: ".$result->getCodeText()); + * $reader = new BarCodeReader("test.png", null, array(DecodeType::CODE_39, DecodeType::CODE_128)); + * //normal quality mode is set by default + * foreach($reader->readBarCodes() as $result) + * print("BarCode CodeText: ".$result->getCodeText()); + * $reader = new BarCodeReader("test.png", null, array(DecodeType::CODE_39, DecodeType::CODE_128)); + * //set high performance mode + * $reader->setQualitySettings(QualitySettings::getHighPerformance()); + * //set separate options + * foreach($reader->readBarCodes() as $result) + * print("BarCode CodeText: ".$result->getCodeText()); + * + * @param QualitySettings $qualitySettings + */ + public function setQualitySettings(QualitySettings $qualitySettings): void + { + $this->barCodeReaderDto->qualitySettings = $qualitySettings->getQualitySettingsDTO(); + $this->qualitySettings = new QualitySettings($this->barCodeReaderDto->qualitySettings); + } + + /** + * The main BarCode decoding parameters. Contains parameters which make influence on recognized data. + * @return BarcodeSettings BarCode decoding parameters + */ + public function getBarcodeSettings(): BarcodeSettings + { + return $this->barcodeSettings; + } + + /** + * Sets bitmap image and areas for recognition. + * Must be called before ReadBarCodes() method. + * + * This sample shows how to detect Code39 and Code128 barcodes. + * @code + * $bmp = "test.png"; + * $reader = new BarCodeReader(); + * $reader->setBarCodeReadType(array(DecodeType::CODE_39, DecodeType::CODE_128)); + * $width, $height; + * list($width, $height) = getimagesize('path_to_image') + * $reader->setBarCodeImage($bmp, new Rectangle[] { new Rectangle(0, 0, $width, $height) }); + * foreach($reader->readBarCodes() as $result) + * { + * print("BarCode Type: ".$result->getCodeTypeName()); + * print("BarCode CodeText: ".$result->getCodeText()); + * } + * @endcode + * @param $imageResource + * @param Rectangle|null ...$areas areas list for recognition + * @throws BarcodeException + */ + public final function setBarCodeImage($imageResource, ?Rectangle ...$areas): void + { + try + { + $this->barCodeReaderDto->base64Image = CommonUtility::convertImageResourceToBase64($imageResource); + $this->barCodeReaderDto->areas = CommonUtility::convertAreasToStringFormattedAreas($areas); + if (is_null($this->barCodeReaderDto->barCodeDecodeTypes) || sizeof($this->barCodeReaderDto->barCodeDecodeTypes) == 0) + $this->barCodeReaderDto->barCodeDecodeTypes = array(DecodeType::ALL_SUPPORTED_TYPES); + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Sets SingleDecodeType type array for recognition. + * Must be called before readBarCodes() method. + * + * This sample shows how to detect Code39 and Code128 barcodes. + * + * @code + * $reader = new BarCodeReader(); + * $reader->setBarCodeReadType(DecodeType::CODE_39_STANDARD, DecodeType::CODE_128); + * $reader->setBarCodeImage("test.png"); + * foreach($reader->readBarCodes() as $result) + * { + * print("BarCode Type: ".$result->getCodeTypeName()); + * print("BarCode CodeText: ".$result->getCodeText()); + * } + * @endcode + * + * @param array $types The SingleDecodeType type array to read. + */ + public function setBarCodeReadType(int ...$types): void + { + foreach ($types as $type) + if (!is_int($type)) + { + throw new TypeError("Argument 1 passed to BarCodeReader::setBarCodeReadType() must be of the type int"); + } + $this->barCodeReaderDto->barCodeDecodeTypes = $types; + } + + public function getBarCodeDecodeType(): array + { + return $this->decodeTypes; + } + + /** + * Exports BarCode properties to the xml-file specified + * @param string $xmlFile The path to xml file + * @return bool Whether or not export completed successfully. + * Returns True in case of success; False Otherwise + */ + public function exportToXml(string $xmlFile): bool + { + try + { + $thriftConnection = new ThriftConnection(); + $client = $thriftConnection->openConnection(); + //TODO BARCODEPHP-677 Implement the passing of license file content from PHP to Java + $xmlData = $client->BarcodeReader_exportToXml($this->barCodeReaderDto); + $thriftConnection->closeConnection(); + $isContentExported = $xmlData != null; + if ($isContentExported) + { + file_put_contents($xmlFile, $xmlData); + } + return $isContentExported; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Import BarCode properties from xml file + * @param string $resource The name of the xml file or path to http resource + * @return BarCodeReader + * @throws BarcodeException + */ + public static function importFromXml(string $resource): BarCodeReader + { + try + { + if (CommonUtility::isPath($resource)) + { + $resource = fopen($resource, "r"); + } + $xmlData = (stream_get_contents($resource)); + $offset = 6; + $xmlData = substr($xmlData, $offset, strlen($xmlData) - $offset); + $thriftConnection = new ThriftConnection(); + $client = $thriftConnection->openConnection(); + + $barCodeReaderDto = $client->BarcodeReader_importFromXml($xmlData); + $thriftConnection->closeConnection(); + + return BarCodeReader::construct($barCodeReaderDto); + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + private static function construct(BarcodeReaderDTO $barCodeReaderDto): BarCodeReader + { + $barcodeReader = new BarCodeReader(null, null, null); + $barcodeReader->setBarCodeReaderDto($barCodeReaderDto); + return $barcodeReader; + } +} \ No newline at end of file diff --git a/lib/Recognition/BarCodeRegionParameters.php b/lib/Recognition/BarCodeRegionParameters.php new file mode 100644 index 00000000..4c095b64 --- /dev/null +++ b/lib/Recognition/BarCodeRegionParameters.php @@ -0,0 +1,165 @@ +save("test.png"); + * $reader = new BarCodeReader("test.png", null, array( DecodeType::CODE_39, DecodeType::CODE_128)); + * foreach($reader->readBarCodes() as $result) + * { + * print("BarCode CodeText: ".$result->getCodeText()); + * print("BarCode Angle: ".$result->getRegion()->getAngle()); + * print("BarCode Quadrangle: ".$result->getRegion()->getQuadrangle()); + * } + * @endcode + */ +final class BarCodeRegionParameters implements Communicator +{ + private $quad; + private $rect; + private array $points; + private BarCodeRegionParametersDTO $barCodeRegionParametersDTO; + + /** + * @return BarCodeRegionParametersDTO instance + */ + private function getBarCodeRegionParametersDTO(): BarCodeRegionParametersDTO + { + return $this->barCodeRegionParametersDTO; + } + + /** + * @param $barCodeRegionParametersDTO + */ + private function setBarCodeRegionParametersDTO($barCodeRegionParametersDTO): void + { + $this->barCodeRegionParametersDTO = $barCodeRegionParametersDTO; + } + + function __construct(BarCodeRegionParametersDTO $barCodeRegionParametersDTO) + { + $this->barCodeRegionParametersDTO = $barCodeRegionParametersDTO; + $this->obtainDto(); + $this->initFieldsFromDto(); + } + + public function obtainDto(...$args) + { + // TODO: Implement obtainDto() method. + } + + public function initFieldsFromDto(): void + { + try + { + $this->quad = Quadrangle::construct($this->getBarCodeRegionParametersDTO()->quad); + $this->rect = Rectangle::construct($this->getBarCodeRegionParametersDTO()->rectangle); + $this->points = self::convertJavaPoints($this->getBarCodeRegionParametersDTO()->points); + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + private static function convertJavaPoints($javaPoints): array + { + $points = array(); + for ($i = 0; $i < sizeof($javaPoints); $i++) + { + $points[$i] = Point::construct($javaPoints[$i]); + } + + return $points; + } + + /** + * @return Quadrangle Gets Quadrangle bounding barcode region Value: Returns Quadrangle bounding barcode region + */ + public function getQuadrangle(): Quadrangle + { + return $this->quad; + } + + /** + * @return float Gets the angle of the barcode (0-360). Value: The angle for barcode (0-360). + * @throws BarcodeException + */ + public function getAngle(): float + { + try + { + return $this->getBarCodeRegionParametersDTO()->angle; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * + */ + /** + * @return array Gets Points array bounding barcode region Value: Returns Points array bounding barcode region + */ + public function getPoints(): array + { + return $this->points; + } + + /** + * @return Rectangle Gets Rectangle bounding barcode region Value: Returns Rectangle bounding barcode region + */ + public function getRectangle(): Rectangle + { + return $this->rect; + } + + /** + * Returns a value indicating whether this instance is equal to a specified BarCodeRegionParameters value. + * + * @param BarCodeRegionParameters $obj An System.Object value to compare to this instance. + * @return bool true if obj has the same value as this instance; otherwise, false. + */ + public function equals(BarCodeRegionParameters $obj): bool + { + $thriftConnection = new ThriftConnection(); + $client = $thriftConnection->openConnection(); + $isEquals = $client->BarCodeRegionParameters_equals($this->getBarCodeRegionParametersDTO(), $obj->getBarCodeRegionParametersDTO()); + $thriftConnection->closeConnection(); + + return $isEquals; + } + + /** + * Returns a human-readable string representation of this BarCodeRegionParameters. + * + * @return string A string that represents this BarCodeRegionParameters. + */ + public function toString(): string + { + try + { + return $this->getBarCodeRegionParametersDTO()->toString; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } +} \ No newline at end of file diff --git a/lib/Recognition/BarCodeResult.php b/lib/Recognition/BarCodeResult.php new file mode 100644 index 00000000..95199922 --- /dev/null +++ b/lib/Recognition/BarCodeResult.php @@ -0,0 +1,163 @@ +save("test.png"); + * $reader = new BarCodeReader("test.png", DecodeType::CODE_39, DecodeType::CODE_128); + * foreach($reader->readBarCodes() as $result) + * { + * print("BarCode Type: ".$result->getCodeTypeName()); + * print("BarCode CodeText: ".$result->getCodeText()); + * print("BarCode Confidence: ".$result->getConfidence()); + * print("BarCode ReadingQuality: ".$result->getReadingQuality()); + * print("BarCode Angle: ".$result->getRegion()->getAngle()); + * } + * @endcode + */ +class BarCodeResult implements Communicator +{ + private BarCodeRegionParameters $region; + private BarCodeExtendedParameters $extended; + private BarCodeResultDTO $barCodeResultDTO; + + /** + * @return BarCodeResultDTO instance + */ + private function getBarCodeResultDTO(): BarCodeResultDTO + { + return $this->barCodeResultDTO; + } + + /** + * @param $barCodeResultDTO + */ + private function setBarCodeResultDTO($barCodeResultDTO): void + { + $this->barCodeResultDTO = $barCodeResultDTO; + } + + function __construct(BarCodeResultDTO $barCodeResultDTO) + { + $this->barCodeResultDTO = $barCodeResultDTO; + $this->obtainDto(); + $this->initFieldsFromDto(); + } + + public function obtainDto(...$args) + { + // TODO: Implement obtainDto() method. + } + + public function initFieldsFromDto(): void + { + $this->region = new BarCodeRegionParameters($this->getBarCodeResultDTO()->region); + $this->extended = new BarCodeExtendedParameters($this->getBarCodeResultDTO()->extended); + } + + /** + * @return float Gets the reading quality. Works for 1D and postal barcodes. Value: The reading quality percent + * @throws BarcodeException + */ + public function getReadingQuality(): float + { + try + { + return $this->getBarCodeResultDTO()->readingQuality; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + *+ * Gets the code text with encoding. + *
+ * @param encoding The encoding for codetext. + * @return A string containing recognized code text. + */ + function getCodeText(?string $encoding): string + { + if ($encoding == null || $encoding == "") + { + return $this->getBarCodeResultDTO()->codeText; + } else + { + try + { + $thriftConnection = new ThriftConnection(); + $client = $thriftConnection->openConnection(); + $codeText = $client->BarcodeResult_getCodeTextWithEncoding($this->getBarCodeResultDTO()->codeBytes, $encoding); + $thriftConnection->closeConnection(); + return $codeText; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + } + + function getCodeType() + { + return $this->getBarCodeResultDTO()->codeType; + } + + function getCodeBytes() + { + return explode(",", $this->getBarCodeResultDTO()->codeBytes); + } + + function getCodeTypeName() + { + return $this->getBarCodeResultDTO()->codeTypeName; + } + + function getConfidence() + { + return $this->getBarCodeResultDTO()->confidence; + } + + function getExtended(): BarCodeExtendedParameters + { + return $this->extended; + } + + function getRegion(): BarCodeRegionParameters + { + return $this->region; + } +} \ No newline at end of file diff --git a/lib/Recognition/BarcodeQualityMode.php b/lib/Recognition/BarcodeQualityMode.php new file mode 100644 index 00000000..73b8ac85 --- /dev/null +++ b/lib/Recognition/BarcodeQualityMode.php @@ -0,0 +1,38 @@ + + *+ *This example shows how to use {@code GetCodeText}:
+ *+ * $gen = new BarcodeGenerator(EncodeTypes::DATA_MATRIX, null); + * $gen->setCodeText("車種名", "932"); + * $gen->save("barcode.png", BarCodeImageFormat::PNG); + * + * $reader = new BarCodeReader("barcode.png", null, DecodeType::DATA_MATRIX); + * $results = $reader->readBarCodes(); + * for($i = 0; i < sizeof($results); $i++) + * { + * $result = $results[$i]; + * echo("BarCode CodeText: " . $result->getCodeText("932")); + * } + *+ *+ * Mode which enables methods to recognize barcode elements with the selected quality. Barcode element with lower quality requires more hard methods which slows the recognition. + *
+ *+ */ +class BarcodeQualityMode +{ + /** + *+ * This sample shows how to use BarcodeQuality mode + *+ * @code + * $reader = new BarCodeReader("test.png", null, array(DecodeType::CODE_39_FULL_ASCII, DecodeType::CODE_128)); + * $reader->getQualitySettings()->setBarcodeQuality(BarcodeQualityMode::LOW); + * foreach($reader->readBarCodes() as $result) + * { + * print("BarCode CodeText: " . $result->getCodeText()); + * } + * @endcode + *+ *Enables recognition methods for High quality barcodes.
+ */ + const HIGH = 0; + /** + *Enables recognition methods for Common(Normal) quality barcodes.
+ */ + const NORMAL = 1; + /** + *Enables recognition methods for Low quality barcodes.
+ */ + const LOW = 2; +} \ No newline at end of file diff --git a/lib/Recognition/BarcodeSettings.php b/lib/Recognition/BarcodeSettings.php new file mode 100644 index 00000000..6b57d4d1 --- /dev/null +++ b/lib/Recognition/BarcodeSettings.php @@ -0,0 +1,231 @@ +barcodeSettingsDto; + } + + private function setBarcodeSettingsDto(BarcodeSettingsDTO $barcodeSettingsDto): void + { + $this->barcodeSettingsDto = $barcodeSettingsDto; + $this->initFieldsFromDto(); + } + + private AustraliaPostSettings $_australiaPost; + + /** + * BarcodeSettings copy constructor + * @param BarcodeSettingsDTO $barcodeSettingsDto + */ + function __construct(BarcodeSettingsDTO $barcodeSettingsDto) + { + $this->barcodeSettingsDto = $barcodeSettingsDto; + $this->obtainDto(); + $this->initFieldsFromDto(); + } + + public function obtainDto(...$args) + { + } + + public function initFieldsFromDto(): void + { + $this->_australiaPost = new AustraliaPostSettings($this->getBarcodeSettingsDto()->australiaPost); + } + + /** + * Enable checksum validation during recognition for 1D and Postal barcodes. + * Default is treated as Yes for symbologies which must contain checksum, as No where checksum only possible. + * Checksum never used: Codabar, PatchCode, Pharmacode, DataLogic2of5 + * Checksum is possible: Code39 Standard/Extended, Standard2of5, Interleaved2of5, ItalianPost25, Matrix2of5, MSI, ItalianPost25, DeutschePostIdentcode, DeutschePostLeitcode, VIN + * Checksum always used: Rest symbologies + * + * @code + * + * $generator = new BarcodeGenerator(EncodeTypes::EAN_13, "1234567890128"); + * $generator->save("c:/test.png", BarcodeImageFormat::PNG); + * $reader = new BarCodeReader("c:/test.png", null, DecodeType::EAN_13); + * //checksum disabled + * $reader->getBarcodeSettings()->setChecksumValidation(ChecksumValidation::OFF); + * foreach($reader->readBarCodes() as $result) + * { + * echo ("BarCode CodeText: ".$result->getCodeText()); + * echo ("BarCode Value: " . $result->getExtended()->getOneD()->getValue()); + * echo ("BarCode Checksum: " . $result->getExtended()->getOneD()->getCheckSum()); + * } + * $reader = new BarCodeReader("c:\\test.png", null, DecodeType::EAN_13); + * //checksum enabled + * $reader->getBarcodeSettings()->setChecksumValidation(ChecksumValidation::ON); + * foreach($reader->readBarCodes() as $result) + * { + * echo ("BarCode CodeText: " . $result->CodeText); + * echo ("BarCode Value: " . $result->getExtended()->getOneD()->getValue()); + * echo ("BarCode Checksum: " . $result->getExtended()->getOneD()->getCheckSum()); + * } + * @endcode + * @return int Enable checksum validation during recognition for 1D and Postal barcodes. + */ + public function getChecksumValidation(): int + { + return $this->getBarcodeSettingsDto()->checksumValidation; + } + + /** + * Enable checksum validation during recognition for 1D and Postal barcodes. + * Default is treated as Yes for symbologies which must contain checksum, as No where checksum only possible. + * Checksum never used: Codabar, PatchCode, Pharmacode, DataLogic2of5 + * Checksum is possible: Code39 Standard/Extended, Standard2of5, Interleaved2of5, ItalianPost25, Matrix2of5, MSI, ItalianPost25, DeutschePostIdentcode, DeutschePostLeitcode, VIN + * Checksum always used: Rest symbologies + * + * @code + * + * $generator = new BarcodeGenerator(EncodeTypes::EAN_13, "1234567890128"); + * $generator->save("c:/test.png", BarcodeImageFormat::PNG); + * $reader = new BarCodeReader("c:/test.png", DecodeType::EAN_13); + * //checksum disabled + * $reader->getBarcodeSettings()->setChecksumValidation(ChecksumValidation::OFF); + * foreach($reader->readBarCodes() as $result) + * { + * echo ("BarCode CodeText: ".$result->getCodeText()); + * echo ("BarCode Value: " . $result->getExtended()->getOneD()->getValue()); + * echo ("BarCode Checksum: " . $result->getExtended()->getOneD()->getCheckSum()); + * } + * $reader = new BarCodeReader(@"c:\test.png", DecodeType::EAN_13); + * //checksum enabled + * $reader->getBarcodeSettings()->setChecksumValidation(ChecksumValidation::ON); + * foreach($reader->readBarCodes() as $result) + * { + * echo ("BarCode CodeText: " . $result->CodeText); + * echo ("BarCode Value: " . $result->getExtended()->getOneD()->getValue()); + * echo ("BarCode Checksum: " . $result->getExtended()->getOneD()->getCheckSum()); + * } + * @endcode + * @param int $value Enable checksum validation during recognition for 1D and Postal barcodes. + */ + public function setChecksumValidation(int $value): void + { + $this->getBarcodeSettingsDto()->checksumValidation = ($value); + } + + /** + * Strip FNC1, FNC2, FNC3 characters from codetext. Default value is false. + * + * @code + * + * $generator = new BarcodeGenerator(EncodeTypes::GS_1_CODE_128, "(02)04006664241007(37)1(400)7019590754"); + * $generator->save("c:/test.png", BarcodeImageFormat::PNG); + * $reader = new BarCodeReader("c:/test.png", DecodeType::CODE_128); + * + * //StripFNC disabled + * $reader->getBarcodeSettings()->setStripFNC(false); + * foreach($reader->readBarCodes() as $result) + * { + * echo ("BarCode CodeText: ".$result->getCodeText()); + * } + * + * $reader = new BarCodeReader("c:/test.png", DecodeType::CODE_128); + * + * //StripFNC enabled + * $reader->getBarcodeSettings()->setStripFNC(true); + * foreach($reader->readBarCodes() as $result) + * { + * echo ("BarCode CodeText: ".$result->getCodeText()); + * } + * @endcode + * + * @return bool Strip FNC1, FNC2, FNC3 characters from codetext. Default value is false. + */ + public function getStripFNC(): bool + { + return $this->getBarcodeSettingsDto()->stripFNC; + } + + /** + * Strip FNC1, FNC2, FNC3 characters from codetext. Default value is false. + * + * @code + * + * $generator = new BarcodeGenerator(EncodeTypes::GS_1_CODE_128, "(02)04006664241007(37)1(400)7019590754"); + * $generator->save("c:/test.png", BarcodeImageFormat::PNG); + * $reader = new BarCodeReader("c:/test.png", DecodeType::CODE_128); + * + * //StripFNC disabled + * $reader->getBarcodeSettings()->setStripFNC(false); + * foreach($reader->readBarCodes() as $result) + * { + * echo ("BarCode CodeText: ".$result->getCodeText()); + * } + * + * $reader = new BarCodeReader("c:/test.png", DecodeType::CODE_128); + * + * //StripFNC enabled + * $reader->getBarcodeSettings()->setStripFNC(true); + * foreach($reader->readBarCodes() as $result) + * { + * echo ("BarCode CodeText: ".$result->getCodeText()); + * } + * @endcode + * + * @param bool $value Strip FNC1, FNC2, FNC3 characters from codetext. Default value is false. + */ + public function setStripFNC(bool $value): void + { + $this->getBarcodeSettingsDto()->stripFNC = $value; + } + + /** + * The flag which force engine to detect codetext encoding for Unicode codesets. Default value is true. + * + * @code + * + * $generator = new BarcodeGenerator(EncodeTypes::QR, "Слово")) + * $im = $generator->generateBarcodeImage(BarcodeImageFormat::PNG); + * + * //detects encoding for Unicode codesets is enabled + * $reader = new BarCodeReader($im, DecodeType::QR); + * $reader->getBarcodeSettings()->setDetectEncoding(true); + * foreach($reader->readBarCodes() as $result) + * echo ("BarCode CodeText: ".$result->getCodeText()); + * + * //detect encoding is disabled + * $reader = new BarCodeReader($im, DecodeType::QR); + * $reader->getBarcodeSettings()->setDetectEncoding(false); + * foreach($reader->readBarCodes() as $result) + * echo ("BarCode CodeText: ".$result->getCodeText()); + * @endcode + * + * @return bool The flag which force engine to detect codetext encoding for Unicode codesets + */ + public function getDetectEncoding(): bool + { + return $this->getBarcodeSettingsDto()->detectEncoding; + } + + public function setDetectEncoding(bool $value): void + { + $this->getBarcodeSettingsDto()->detectEncoding = $value; + } + + /** + * Gets AustraliaPost decoding parameters + * @return AustraliaPostSettings The AustraliaPost decoding parameters which make influence on recognized data of AustraliaPost symbology + */ + public function getAustraliaPost(): AustraliaPostSettings + { + return $this->_australiaPost; + } +} \ No newline at end of file diff --git a/lib/Recognition/ChecksumValidation.php b/lib/Recognition/ChecksumValidation.php new file mode 100644 index 00000000..eb372fb9 --- /dev/null +++ b/lib/Recognition/ChecksumValidation.php @@ -0,0 +1,85 @@ +save("test.png", BarcodeImageFormat::PNG); + * $reader = new BarCodeReader("test.png", null, DecodeType::EAN_13); + * //checksum disabled + * $reader->setChecksumValidation(ChecksumValidation::OFF); + * foreach($reader->readBarCodes() as $result) + * { + * print("BarCode CodeText: ".$result->getCodeText()); + * print("BarCode Value: ".$result->getExtended()->getOneD()->getValue()); + * print("BarCode Checksum: ".$result->getExtended()->getOneD()->getCheckSum()); + * } + * $reader = new BarCodeReader("test.png", null, DecodeType::EAN_13); + * //checksum enabled + * $reader->setChecksumValidation(ChecksumValidation::ON); + * foreach($reader->readBarCodes() as $result) + * { + * print("BarCode CodeText: ".$result->getCodeText()); + * print("BarCode Value: ".$result->getExtended()->getOneD()->getValue()); + * print("BarCode Checksum: ".$result->getExtended()->getOneD()->getCheckSum()); + * } + * @endcode + */ +class ChecksumValidation +{ + /** + * If checksum is required by the specification - it will be validated. + */ + const DEFAULT = 0; + + /** + * Always validate checksum if possible. + */ + const ON = 1; + + /** + * Do not validate checksum. + */ + const OFF = 2; +} \ No newline at end of file diff --git a/lib/Recognition/CodabarExtendedParameters.php b/lib/Recognition/CodabarExtendedParameters.php new file mode 100644 index 00000000..e22f88b3 --- /dev/null +++ b/lib/Recognition/CodabarExtendedParameters.php @@ -0,0 +1,122 @@ + + * Stores a Codabar additional information of recognized barcode + * + */ +class CodabarExtendedParameters implements Communicator +{ + private CodabarExtendedParametersDTO $codabarExtendedParametersDTO; + + /** + * @return CodabarExtendedParametersDTO instance + */ + private function getCodabarExtendedParametersDTO(): CodabarExtendedParametersDTO + { + return $this->codabarExtendedParametersDTO; + } + + /** + * @param $codabarExtendedParametersDTO + */ + private function setCodabarExtendedParametersDTO($codabarExtendedParametersDTO): void + { + $this->codabarExtendedParametersDTO = $codabarExtendedParametersDTO; + } + + function __construct(CodabarExtendedParametersDTO $codabarExtendedParametersDTO) + { + $this->codabarExtendedParametersDTO = $codabarExtendedParametersDTO; + $this->obtainDto(); + $this->initFieldsFromDto(); + } + + public function obtainDto(...$args) + { + // TODO: Implement obtainDto() method. + } + + public function initFieldsFromDto(): void + { + // TODO: Implement init() method. + } + + /** + *+ * Gets or sets a Codabar start symbol. + * Default value: CodabarSymbol.A + *
+ */ + public function getCodabarStartSymbol(): int + { + return $this->getCodabarExtendedParametersDTO()->codabarStartSymbol; + } + + /** + *+ * Gets or sets a Codabar start symbol. + * Default value: CodabarSymbol.A + *
+ */ + public function setCodabarStartSymbol(int $value): void + { + $this->getCodabarExtendedParametersDTO()->codabarStartSymbol = $value; + } + + /** + *+ * Gets or sets a Codabar stop symbol. + * Default value: CodabarSymbol.A + *
+ */ + public function getCodabarStopSymbol(): int + { + return $this->getCodabarExtendedParametersDTO()->codabarStopSymbol; + } + + /** + *+ * Gets or sets a Codabar stop symbol. + * Default value: CodabarSymbol.A + *
+ */ + public function setCodabarStopSymbol(int $value): void + { + $this->getCodabarExtendedParametersDTO()->codabarStopSymbol = $value; + } + + /** + *+ * Returns a value indicating whether this instance is equal to a specified {@code AztecExtendedParameters} value. + *
+ * @param CodabarExtendedParameters $obj + * @return bool ```php + */ + public function equals(CodabarExtendedParameters $obj): bool + { + $thriftConnection = new ThriftConnection(); + $client = $thriftConnection->openConnection(); + $isEquals = $client->CodabarExtendedParameters_equals($this->getCodabarExtendedParametersDTO(), $obj->getCodabarExtendedParametersDTO()); + $thriftConnection->closeConnection(); + + return $isEquals; + } + + /** + *+ * Returns a human-readable string representation of this {@code AztecExtendedParameters}. + *
+ * @return string that represents this {@code AztecExtendedParameters}. + */ + public function toString(): string + { + return $this->getCodabarExtendedParametersDTO()->toString; + } +} \ No newline at end of file diff --git a/lib/Recognition/Code128DataPortion.php b/lib/Recognition/Code128DataPortion.php new file mode 100644 index 00000000..9aae4f49 --- /dev/null +++ b/lib/Recognition/Code128DataPortion.php @@ -0,0 +1,98 @@ +code128DataPortionDTO; + } + + /** + * @param $code128DataPortionDTO + */ + private function setCode128DataPortionDTO($code128DataPortionDTO): void + { + $this->code128DataPortionDTO = $code128DataPortionDTO; + } + + function __construct(Code128DataPortionDTO $code128DataPortionDTO) + { + $this->code128DataPortionDTO = $code128DataPortionDTO; + $this->obtainDto(); + $this->initFieldsFromDto(); + } + + public function obtainDto(...$args) + { + // TODO: Implement obtainDto() method. + } + + public function initFieldsFromDto(): void + { + // TODO: Implement init() method. + } + + /** + * Gets the part of code text related to subtype. + * + * @return string The part of code text related to subtype + */ + public final function getData(): string + { + try + { + return $this->getCode128DataPortionDTO()->data; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Gets the type of Code128 subset + * + * @return int The type of Code128 subset + */ + public final function getCode128SubType(): int + { + try + { + return $this->getCode128DataPortionDTO()->code128SubType; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Returns a human-readable string representation of this {Code128DataPortion}. + * @return string A string that represents this {Code128DataPortion}. + */ + public function toString(): string + { + $thriftConnection = new ThriftConnection(); + $client = $thriftConnection->openConnection(); + $str = $client->Code128DataPortion_toString($this->getCode128DataPortionDTO()); + $thriftConnection->closeConnection(); + + return $str; + } +} \ No newline at end of file diff --git a/lib/Recognition/Code128ExtendedParameters.php b/lib/Recognition/Code128ExtendedParameters.php new file mode 100644 index 00000000..11a24eb3 --- /dev/null +++ b/lib/Recognition/Code128ExtendedParameters.php @@ -0,0 +1,137 @@ +save("test.png"); + * $reader = new BarCodeReader("test.png", DecodeType::CODE_128); + * foreach($reader->readBarCodes() as $result) + * { + * print("BarCode Type: ".$result->getCodeTypeName()); + * print("BarCode CodeText: ".$result->getCodeText()); + * print("Code128 Data Portions: ".$result->getExtended()->getCode128()); + * } + * @endcode + */ +final class Code128ExtendedParameters implements Communicator +{ + private array $code128DataPortions; + private Code128ExtendedParametersDTO $code128ExtendedParametersDTO; + + /** + * @return Code128ExtendedParametersDTO instance + */ + private function getCode128ExtendedParametersDTO(): Code128ExtendedParametersDTO + { + return $this->code128ExtendedParametersDTO; + } + + /** + * @param Code128ExtendedParametersDTO $code128ExtendedParametersDTO + */ + private function setCode128ExtendedParametersDTO(Code128ExtendedParametersDTO $code128ExtendedParametersDTO): void + { + $this->code128ExtendedParametersDTO = $code128ExtendedParametersDTO; + } + + function __construct(Code128ExtendedParametersDTO $code128ExtendedParametersDTO) + { + $this->code128ExtendedParametersDTO = $code128ExtendedParametersDTO; + $this->obtainDto(); + $this->initFieldsFromDto(); + } + + public function obtainDto(...$args) + { + // TODO: Implement obtainDto() method. + } + + public function initFieldsFromDto(): void + { + try + { + $this->code128DataPortions = self::convertCode128DataPortions($this->getCode128ExtendedParametersDTO()->code128DataPortions); + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + private static function convertCode128DataPortions($javaCode128DataPortions): array + { + $code128DataPortions = array(); + for ($i = 0; $i < sizeof($javaCode128DataPortions); $i++) + { + $code128DataPortions[] = new Code128DataPortion($javaCode128DataPortions[$i]); + } + return $code128DataPortions; + } + + /** + * Gets Code128DataPortion array of recognized Code128 barcode Value: Array of the Code128DataPortion. + */ + public function getCode128DataPortions(): array + { + return $this->code128DataPortions; + } + + public function isEmpty(): bool + { + try + { + return $this->getCode128ExtendedParametersDTO()->empty; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Returns a value indicating whether this instance is equal to a specified Code128ExtendedParameters value. + * + * @param Code128ExtendedParameters obj An System.Object value to compare to this instance. + * @return bool true if obj has the same value as this instance; otherwise, false. + */ + public function equals(Code128ExtendedParameters $obj): bool + { + $thriftConnection = new ThriftConnection(); + $client = $thriftConnection->openConnection(); + $isEquals = $client->Code128ExtendedParameters_equals($this->getCode128ExtendedParametersDTO(), $obj->getCode128ExtendedParametersDTO()); + $thriftConnection->closeConnection(); + + return $isEquals; + } + + /** + * Returns a human-readable string representation of this Code128ExtendedParameters. + * + * @return string A string that represents this Code128ExtendedParameters. + */ + public function toString(): string + { + try + { + return $this->getCode128ExtendedParametersDTO()->toString;// TODO need to implement + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } +} \ No newline at end of file diff --git a/lib/Recognition/Code128SubType.php b/lib/Recognition/Code128SubType.php new file mode 100644 index 00000000..ec4a0153 --- /dev/null +++ b/lib/Recognition/Code128SubType.php @@ -0,0 +1,24 @@ + + *+ * Mode which enables or disables additional recognition of color barcodes on color images. + *
+ *+ */ +class ComplexBackgroundMode +{ + /** + *+ * This sample shows how to use ComplexBackground mode + *+ * @code + * $reader = new BarCodeReader("test.png", null, array(DecodeType::CODE_39_FULL_ASCII, DecodeType::CODE_128)); + * $reader->getQualitySettings()->setComplexBackground(ComplexBackgroundMode::ENABLED); + * foreach($reader->readBarCodes() as $result) + * { + * print("BarCode CodeText: " . $result->getCodeText()); + * } + * @endcode + *+ *At this time the same as Disabled. Disables additional recognition of color barcodes on color images.
+ */ + const AUTO = 0; + /** + *Disables additional recognition of color barcodes on color images.
+ */ + const DISABLED = 1; + /** + *Enables additional recognition of color barcodes on color images.
+ */ + const ENABLED = 2; + +} \ No newline at end of file diff --git a/lib/Recognition/CustomerInformationInterpretingType.php b/lib/Recognition/CustomerInformationInterpretingType.php new file mode 100644 index 00000000..4a1be54a --- /dev/null +++ b/lib/Recognition/CustomerInformationInterpretingType.php @@ -0,0 +1,64 @@ +getParameters()->getBarcode()->getAustralianPost()->setAustralianPostEncodingTable(CustomerInformationInterpretingType::C_TABLE); + * $image = $generator->generateBarcodeImage(BarcodeImageFormat::PNG); + * $reader = new BarCodeReader($image, DecodeType::AUSTRALIA_POST); + * $reader->setCustomerInformationInterpretingType(CustomerInformationInterpretingType::C_TABLE); + * foreach($reader->readBarCodes() as $result) + * { + * print("BarCode Type: ".$result->getCodeType()); + * print("BarCode CodeText: ".$result->getCodeText()); + * } + * @endcode + */ + const C_TABLE = 0; + + /** + * Use N_TABLE to interpret the customer information. Allows digits. + * + * @code + * $generator = new BarcodeGenerator(EncodeTypes::AUSTRALIA_POST, "59123456781234567"); + * $generator->getParameters()->getBarcode()->getAustralianPost()->setAustralianPostEncodingTable(CustomerInformationInterpretingType::N_TABLE); + * $image = $generator->generateBarcodeImage(BarcodeImageFormat::PNG); + * $reader = new BarCodeReader($image, DecodeType::AUSTRALIA_POST); + * $reader->setCustomerInformationInterpretingType(CustomerInformationInterpretingType::N_TABLE); + * foreach($reader->readBarCodes() as $result) + * { + * print("BarCode Type: ".$result->getCodeType()); + * print("BarCode CodeText: ".$result->getCodeText()); + * } + * @endcode + */ + const N_TABLE = 1; + + /** + * Do not interpret the customer information. Allows 0, 1, 2 or 3 symbol only. + * + * @code + * $generator = new BarcodeGenerator(EncodeTypes::AUSTRALIA_POST, "59123456780123012301230123"); + * $generator->getParameters()->getBarcode()->getAustralianPost()->setAustralianPostEncodingTable(CustomerInformationInterpretingType::OTHER); + * $image = $generator->generateBarcodeImage(BarcodeImageFormat::PNG); + * $reader = new BarCodeReader($image, DecodeType::AUSTRALIA_POST); + * $reader->setCustomerInformationInterpretingType(CustomerInformationInterpretingType::OTHER)); + * foreach($reader->readBarCodes() as $result) + * { + * print("BarCode Type: ".$result->getCodeType()); + * print("BarCode CodeText: ".$result->getCodeText()); + * } + * @endcode + */ + const OTHER = 2; +} \ No newline at end of file diff --git a/lib/Recognition/DataBarExtendedParameters.php b/lib/Recognition/DataBarExtendedParameters.php new file mode 100644 index 00000000..89d01ba4 --- /dev/null +++ b/lib/Recognition/DataBarExtendedParameters.php @@ -0,0 +1,108 @@ +readBarCodes() as $result) + * { + * print("BarCode Type: ".result->getCodeTypeName()); + * print("BarCode CodeText: ".result->getCodeText()); + * print("QR Structured Append Quantity: ".result->getExtended()->getQR()->getQRStructuredAppendModeBarCodesQuantity()); + * } + * @endcode + */ +class DataBarExtendedParameters implements Communicator +{ + private DataBarExtendedParametersDTO $dataBarExtendedParametersDTO; + + /** + * @return DataBarExtendedParametersDTO instance + */ + private function getDataBarExtendedParametersDTO(): DataBarExtendedParametersDTO + { + return $this->dataBarExtendedParametersDTO; + } + + /** + * @param $dataBarExtendedParametersDTO + */ + private function setQRExtendedParametersDTO($dataBarExtendedParametersDTO): void + { + $this->dataBarExtendedParametersDTO = $dataBarExtendedParametersDTO; + } + + function __construct(DataBarExtendedParametersDTO $dataBarExtendedParametersDTO) + { + $this->dataBarExtendedParametersDTO = $dataBarExtendedParametersDTO; + $this->obtainDto(); + $this->initFieldsFromDto(); + } + + public function obtainDto(...$args) + { + // TODO: Implement obtainDto() method. + } + + public function initFieldsFromDto(): void + { + // TODO: Implement init() method. + } + + /** + * Gets the DataBar 2D composite component flag. Default value is false. + * @return bool The DataBar 2D composite component flag. + */ + public function is2DCompositeComponent(): bool + { + try + { + return $this->getDataBarExtendedParametersDTO()->is2DCompositeComponent; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Returns a value indicating whether this instance is equal to a specified DataBarExtendedParameters value. + * @param DataBarExtendedParameters $obj An System.Object value to compare to this instance. + * @return bool true if obj has the same value as this instance; otherwise, false. + */ + public function equals(DataBarExtendedParameters $obj): bool + { + $thriftConnection = new ThriftConnection(); + $client = $thriftConnection->openConnection(); + $isEquals = $client->DataBarExtendedParameters_equals($this->getDataBarExtendedParametersDTO(), $obj->getDataBarExtendedParametersDTO()); + $thriftConnection->closeConnection(); + + return $isEquals; + } + + /** + * Returns a human-readable string representation of this DataBarExtendedParameters. + * @return string A string that represents this DataBarExtendedParameters. + */ + public function toString(): string + { + try + { + return $this->getDataBarExtendedParametersDTO()->toString; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } +} \ No newline at end of file diff --git a/lib/Recognition/DataMatrixExtendedParameters.php b/lib/Recognition/DataMatrixExtendedParameters.php new file mode 100644 index 00000000..90fe899a --- /dev/null +++ b/lib/Recognition/DataMatrixExtendedParameters.php @@ -0,0 +1,130 @@ + + * Stores special data of DataMatrix recognized barcode + *+ */ +class DataMatrixExtendedParameters implements Communicator +{ + private DataMatrixExtendedParametersDTO $dataMatrixExtendedParametersDTO; + + /** + * @return DataMatrixExtendedParametersDTO instance + */ + private function getDataMatrixExtendedParametersDTO(): DataMatrixExtendedParametersDTO + { + return $this->dataMatrixExtendedParametersDTO; + } + + /** + * @param $dataMatrixExtendedParametersDTO + */ + private function setDataMatrixExtendedParametersDTO($dataMatrixExtendedParametersDTO): void + { + $this->dataMatrixExtendedParametersDTO = $dataMatrixExtendedParametersDTO; + } + + function __construct(DataMatrixExtendedParametersDTO $dataMatrixExtendedParametersDTO) + { + $this->dataMatrixExtendedParametersDTO = $dataMatrixExtendedParametersDTO; + $this->obtainDto(); + $this->initFieldsFromDto(); + } + + public function obtainDto(...$args) + { + // TODO: Implement obtainDto() method. + } + + public function initFieldsFromDto(): void + { + // TODO: Implement init() method. + } + + /** + *+ * This sample shows how to get DataMatrix raw values + *+ * $generator = new BarcodeGenerator(EncodeTypes.DATA_MATRIX, "12345")) + * $generator->save("c:\\test.png", BarcodeImageFormat::PNG); + * + * $reader = new BarCodeReader("c:\\test.png", null, DecodeType::DATA_MATRIX)) + * foreach($reader->readBarCodes() as $result) + * { + * echo("BarCode type: " . $result->getCodeTypeName()); + * echo("BarCode codetext: " . $result->getCodeText()); + * echo("DataMatrix barcode ID: " . $result->getExtended()->getDataMatrix()->getStructuredAppendBarcodeId()); + * echo("DataMatrix barcodes count: " . $result->getExtended()->getDataMatrix()->getStructuredAppendBarcodesCount()); + * echo("DataMatrix file ID: " . $result->getExtended()->getDataMatrix()->getStructuredAppendFileId()); + * echo("DataMatrix is reader programming: " . $result->getExtended()->getDataMatrix()->isReaderProgramming()); + * } + *+ *Gets the DataMatrix structured append mode barcodes count. Default value is -1. Count must be a value from 1 to 35.
Value: The count of the DataMatrix structured append mode barcode. + */ + public function getStructuredAppendBarcodesCount(): int + { + return $this->getDataMatrixExtendedParametersDTO()->structuredAppendBarcodesCount; + } + + /** + *Gets the ID of the DataMatrix structured append mode barcode. ID starts from 1 and must be less or equal to barcodes count. Default value is -1.
Value: The ID of the DataMatrix structured append mode barcode. + */ + public function getStructuredAppendBarcodeId(): int + { + return $this->getDataMatrixExtendedParametersDTO()->structuredAppendBarcodeId; + } + + /** + *Gets the ID of the DataMatrix structured append mode barcode. ID starts from 1 and must be less or equal to barcodes count. Default value is -1.
Value: The ID of the DataMatrix structured append mode barcode. + */ + public function getStructuredAppendFileId(): int + { + return $this->getDataMatrixExtendedParametersDTO()->structuredAppendFileId; + } + + /** + *+ * Indicates whether code is used for instruct reader to interpret the following data as instructions for initialization or reprogramming of the bar code reader. + * Default value is false. + *
+ */ + public function isReaderProgramming(): bool + { + return $this->getDataMatrixExtendedParametersDTO()->readerProgramming; + } + + /** + *+ * Returns a value indicating whether this instance is equal to a specified {@code DataMatrixExtendedParameters} value. + *
+ * @param DataMatrixExtendedParameters $obj + * @return bool ```php + */ + public function equals(DataMatrixExtendedParameters $obj): bool + { + $thriftConnection = new ThriftConnection(); + $client = $thriftConnection->openConnection(); + $isEquals = $client->DataMatrixExtendedParameters_equals($this->getDataMatrixExtendedParametersDTO(), $obj->getDataMatrixExtendedParametersDTO()); + $thriftConnection->closeConnection(); + + return $isEquals; + } + + /** + *+ * Returns a human-readable string representation of this {@code DataMatrixExtendedParameters}. + *
+ * @return string that represents this {@code DataMatrixExtendedParameters}. + */ + public function toString(): string + { + return $this->getDataMatrixExtendedParametersDTO()->toString; + } +} \ No newline at end of file diff --git a/lib/Recognition/DecodeType.php b/lib/Recognition/DecodeType.php new file mode 100644 index 00000000..fc37183d --- /dev/null +++ b/lib/Recognition/DecodeType.php @@ -0,0 +1,585 @@ +readBarCodes() as $result) + * { + * print("BarCode Type: ".$result->getCodeTypeName()); + * print("BarCode CodeText: ".$result->getCodeText()); + * } + * @endcode + */ +class DecodeType +{ + /** + * Unspecified decode type. + */ + const NONE = -1; + + /** + * Specifies that the data should be decoded with { CODABAR} barcode specification + */ + const CODABAR = 0; + + /** + * Specifies that the data should be decoded with { CODE 11} barcode specification + */ + const CODE_11 = 1; + + /** + *+ * Specifies that the data should be decoded with {@code Code 39} basic charset barcode specification: ISO/IEC 16388 + *
+ */ + const CODE_39 = 2; + + /** + *+ * Specifies that the data should be decoded with {@code Code 39} full ASCII charset barcode specification: ISO/IEC 16388 + *
+ */ + const CODE_39_FULL_ASCII = 3; + + /** + *+ * Specifies that the data should be decoded with {@code CODE 93} barcode specification + *
+ */ + const CODE_93 = 5; + + /** + * Specifies that the data should be decoded with { CODE 128} barcode specification + */ + const CODE_128 = 6; + + /** + * Specifies that the data should be decoded with { GS1 CODE 128} barcode specification + */ + const GS_1_CODE_128 = 7; + + /** + * Specifies that the data should be decoded with { EAN-8} barcode specification + */ + const EAN_8 = 8; + + /** + * Specifies that the data should be decoded with { EAN-13} barcode specification + */ + const EAN_13 = 9; + + /** + * Specifies that the data should be decoded with { EAN14} barcode specification + */ + const EAN_14 = 10; + + /** + * Specifies that the data should be decoded with { SCC14} barcode specification + */ + const SCC_14 = 11; + + /** + * Specifies that the data should be decoded with { SSCC18} barcode specification + */ + const SSCC_18 = 12; + + /** + * Specifies that the data should be decoded with { UPC-A} barcode specification + */ + const UPCA = 13; + + /** + * Specifies that the data should be decoded with { UPC-E} barcode specification + */ + const UPCE = 14; + + /** + * Specifies that the data should be decoded with { ISBN} barcode specification + */ + const ISBN = 15; + + /** + * Specifies that the data should be decoded with { Standard 2 of 5} barcode specification + */ + const STANDARD_2_OF_5 = 16; + + /** + * Specifies that the data should be decoded with { INTERLEAVED 2 of 5} barcode specification + */ + const INTERLEAVED_2_OF_5 = 17; + + /** + * Specifies that the data should be decoded with { Matrix 2 of 5} barcode specification + */ + const MATRIX_2_OF_5 = 18; + + /** + * Specifies that the data should be decoded with { Italian Post 25} barcode specification + */ + const ITALIAN_POST_25 = 19; + + /** + * Specifies that the data should be decoded with { IATA 2 of 5} barcode specification. IATA (International Air Transport Association) uses this barcode for the management of air cargo. + */ + const IATA_2_OF_5 = 20; + + /** + * Specifies that the data should be decoded with { ITF14} barcode specification + */ + const ITF_14 = 21; + + /** + * Specifies that the data should be decoded with { ITF6} barcode specification + */ + const ITF_6 = 22; + + /** + * Specifies that the data should be decoded with { MSI Plessey} barcode specification + */ + const MSI = 23; + + /** + * Specifies that the data should be decoded with { VIN} (Vehicle Identification Number) barcode specification + */ + const VIN = 24; + + /** + * Specifies that the data should be decoded with { DeutschePost Ident code} barcode specification + */ + const DEUTSCHE_POST_IDENTCODE = 25; + + /** + * Specifies that the data should be decoded with { DeutschePost Leit code} barcode specification + */ + const DEUTSCHE_POST_LEITCODE = 26; + + /** + * Specifies that the data should be decoded with { OPC} barcode specification + */ + const OPC = 27; + + /** + * Specifies that the data should be decoded with { PZN} barcode specification. This symbology is also known as Pharma Zentral Nummer + */ + const PZN = 28; + + /** + * Specifies that the data should be decoded with { Pharmacode} barcode. This symbology is also known as Pharmaceutical BINARY Code + */ + const PHARMACODE = 29; + + /** + * Specifies that the data should be decoded with { DataMatrix} barcode symbology + */ + const DATA_MATRIX = 30; + + /** + * Specifies that the data should be decoded with { GS1DataMatrix} barcode symbology + */ + const GS_1_DATA_MATRIX = 31; + + /** + * Specifies that the data should be decoded with { QR Code} barcode specification + */ + const QR = 32; + + /** + * Specifies that the data should be decoded with { Aztec} barcode specification + */ + const AZTEC = 33; + + /** + *+ * Specifies that the data should be decoded with {@code GS1 Aztec} barcode specification + *
+ */ + const GS_1_AZTEC = 81; + + /** + * Specifies that the data should be decoded with { Pdf417} barcode symbology + */ + const PDF_417 = 34; + + /** + * Specifies that the data should be decoded with { MacroPdf417} barcode specification + */ + const MACRO_PDF_417 = 35; + + /** + * Specifies that the data should be decoded with { MicroPdf417} barcode specification + */ + const MICRO_PDF_417 = 36; + + /** + * Specifies that the data should be decoded with MicroPdf417 barcode specification + */ + const GS_1_MICRO_PDF_417 = 82; + + /** + * Specifies that the data should be decoded with { CodablockF} barcode specification + */ + const CODABLOCK_F = 65; + /** + * Specifies that the data should be decoded with Royal Mail Mailmark barcode specification. + */ + const MAILMARK = 66; + + /** + * Specifies that the data should be decoded with { Australia Post} barcode specification + */ + const AUSTRALIA_POST = 37; + + /** + * Specifies that the data should be decoded with { Postnet} barcode specification + */ + const POSTNET = 38; + + /** + * Specifies that the data should be decoded with { Planet} barcode specification + */ + const PLANET = 39; + + /** + * Specifies that the data should be decoded with USPS { OneCode} barcode specification + */ + const ONE_CODE = 40; + + /** + * Specifies that the data should be decoded with { RM4SCC} barcode specification. RM4SCC (Royal Mail 4-state Customer Code) is used for automated mail sort process in UK. + */ + const RM_4_SCC = 41; + + /** + * Specifies that the data should be decoded with { GS1 DATABAR omni-directional} barcode specification + */ + const DATABAR_OMNI_DIRECTIONAL = 42; + + /** + * Specifies that the data should be decoded with { GS1 DATABAR truncated} barcode specification + */ + const DATABAR_TRUNCATED = 43; + + /** + * Specifies that the data should be decoded with { GS1 DATABAR limited} barcode specification + */ + const DATABAR_LIMITED = 44; + + /** + * Specifies that the data should be decoded with { GS1 DATABAR expanded} barcode specification + */ + const DATABAR_EXPANDED = 45; + + /** + * Specifies that the data should be decoded with { GS1 DATABAR stacked omni-directional} barcode specification + */ + const DATABAR_STACKED_OMNI_DIRECTIONAL = 53; + + /** + * Specifies that the data should be decoded with { GS1 DATABAR stacked} barcode specification + */ + const DATABAR_STACKED = 54; + + /** + * Specifies that the data should be decoded with { GS1 DATABAR expanded stacked} barcode specification + */ + const DATABAR_EXPANDED_STACKED = 55; + + /** + * Specifies that the data should be decoded with { Patch code} barcode specification. Barcode symbology is used for automated scanning + */ + const PATCH_CODE = 46; + + /** + * Specifies that the data should be decoded with { ISSN} barcode specification + */ + const ISSN = 47; + + /** + * Specifies that the data should be decoded with { ISMN} barcode specification + */ + const ISMN = 48; + + /** + * Specifies that the data should be decoded with { Supplement(EAN2, EAN5)} barcode specification + */ + const SUPPLEMENT = 49; + + /** + * Specifies that the data should be decoded with { Australian Post Domestic eParcel Barcode} barcode specification + */ + const AUSTRALIAN_POSTE_PARCEL = 50; + + /** + * Specifies that the data should be decoded with { Swiss Post Parcel Barcode} barcode specification + */ + const SWISS_POST_PARCEL = 51; + + /** + * Specifies that the data should be decoded with { SCode16K} barcode specification + */ + const CODE_16_K = 52; + + /** + * Specifies that the data should be decoded with { MicroQR Code} barcode specification + */ + const MICRO_QR = 56; + + /** + * Specifies that the data should be decoded with RectMicroQR (rMQR) Code barcode specification + */ + const RECT_MICRO_QR = 83; + + /** + * Specifies that the data should be decoded with { CompactPdf417} (Pdf417Truncated) barcode specification + */ + const COMPACT_PDF_417 = 57; + + /** + * Specifies that the data should be decoded with { GS1 QR} barcode specification + */ + const GS_1_QR = 58; + + /** + * Specifies that the data should be decoded with { MaxiCode} barcode specification + */ + const MAXI_CODE = 59; + + /** + * Specifies that the data should be decoded with { MICR E-13B} blank specification + */ + const MICR_E_13_B = 60; + + /** + * Specifies that the data should be decoded with { Code32} blank specification + */ + const CODE_32 = 61; + + /** + * Specifies that the data should be decoded with { DataLogic 2 of 5} blank specification + */ + const DATA_LOGIC_2_OF_5 = 62; + + /** + * Specifies that the data should be decoded with { DotCode} blank specification + */ + const DOT_CODE = 63; + + /** + *+ * Specifies that the data should be decoded with {@code GS1 DotCode} blank specification + *
+ */ + const GS_1_DOT_CODE = 77; + + /** + * Specifies that the data should be decoded with { DotCode} blank specification + */ + const DUTCH_KIX = 64; + + /** + *+ * Specifies that the data should be decoded with {@code HIBC LIC Code39} blank specification + *
+ */ + const HIBC_CODE_39_LIC = 67; + + /** + *+ * Specifies that the data should be decoded with {@code HIBC LIC Code128} blank specification + *
+ */ + const HIBC_CODE_128_LIC = 68; + + /** + *+ * Specifies that the data should be decoded with {@code HIBC LIC Aztec} blank specification + *
+ */ + const HIBC_AZTEC_LIC = 69; + + /** + *+ * Specifies that the data should be decoded with {@code HIBC LIC DataMatrix} blank specification + *
+ */ + const HIBC_DATA_MATRIX_LIC = 70; + + /** + *+ * Specifies that the data should be decoded with {@code HIBC LIC QR} blank specification + *
+ */ + const HIBCQRLIC = 71; + + /** + *+ * Specifies that the data should be decoded with {@code HIBC PAS Code39} blank specification + *
+ */ + const HIBC_CODE_39_PAS = 72; + + /** + *+ * Specifies that the data should be decoded with {@code HIBC PAS Code128} blank specification + *
+ */ + const HIBC_CODE_128_PAS = 73; + + /** + *+ * Specifies that the data should be decoded with {@code HIBC PAS Aztec} blank specification + *
+ */ + const HIBC_AZTEC_PAS = 74; + + /** + *+ * Specifies that the data should be decoded with {@code HIBC PAS DataMatrix} blank specification + *
+ */ + const HIBC_DATA_MATRIX_PAS = 75; + + /** + *+ * Specifies that the data should be decoded with {@code HIBC PAS QR} blank specification + *
+ */ + const HIBCQRPAS = 76; + + /** + * Specifies that the data should be decoded with Han Xin Code blank specification + */ + const HAN_XIN = 78; + + /** + * Specifies that the data should be decoded with Han Xin Code blank specification + */ + const GS_1_HAN_XIN = 79; + + /** + *+ * Specifies that the data should be decoded with {@code GS1 Composite Bar} barcode specification + *
+ */ + const GS_1_COMPOSITE_BAR = 80; + + /** + * Specifies that data will be checked with all of 1D barcode symbologies + */ + const TYPES_1D = 97; + + /** + * Specifies that data will be checked with all of 1.5D POSTAL barcode symbologies, like Planet, Postnet, AustraliaPost, OneCode, RM4SCC, DutchKIX + */ + const POSTAL_TYPES = 95; + + /** + * Specifies that data will be checked with most commonly used symbologies + */ + const MOST_COMMON_TYPES = 96; + + /** + * Specifies that data will be checked with all of 2D barcode symbologies + */ + const TYPES_2D = 98; + + /** + * Specifies that data will be checked with all available symbologies + */ + const ALL_SUPPORTED_TYPES = 99; + + /** + * Determines if the specified BaseDecodeType contains any 1D barcode symbology + * @param int $symbology barcode symbology + * @return bool true if BaseDecodeType contains any 1D barcode symbology; otherwise, returns false. + */ + public static function is1D(int $symbology): bool + { + try + { + $thriftConnection = new ThriftConnection(); + $client = $thriftConnection->openConnection(); + $isEquals = $client->DecodeType_is1D($symbology); + $thriftConnection->closeConnection(); + return $isEquals; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Determines if the specified BaseDecodeType contains any Postal barcode symbology + * @param int symbology The BaseDecodeType to test + * @return bool Returns true if BaseDecodeType contains any Postal barcode symbology; otherwise, returns false. + */ + public static function isPostal(int $symbology): bool + { + try + { + $thriftConnection = new ThriftConnection(); + $client = $thriftConnection->openConnection(); + $isEquals = $client->DecodeType_isPostal($symbology); + $thriftConnection->closeConnection(); + return $isEquals; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Determines if the specified BaseDecodeType contains any 2D barcode symbology + * @param int symbology The BaseDecodeType to test. + * @return bool Returns true if BaseDecodeType contains any 2D barcode symbology; otherwise, returns false. + */ + public static function is2D(int $symbology): bool + { + try + { + $thriftConnection = new ThriftConnection(); + $client = $thriftConnection->openConnection(); + $isEquals = $client->DecodeType_is2D($symbology); + $thriftConnection->closeConnection(); + return $isEquals; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Determines if the BaseDecodeType array contains specified barcode symbology + * @param int $expectedDecodeType + * @param array $decodeTypes the BaseDecodeType array + * @return bool + * @throws BarcodeException + */ + public static function containsAny(int $expectedDecodeType, array $decodeTypes): bool + { + try + { + if (in_array($expectedDecodeType, $decodeTypes, true)) + { + return true; + } + return false; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } +} \ No newline at end of file diff --git a/lib/Recognition/DeconvolutionMode.php b/lib/Recognition/DeconvolutionMode.php new file mode 100644 index 00000000..1990e32f --- /dev/null +++ b/lib/Recognition/DeconvolutionMode.php @@ -0,0 +1,40 @@ + + *+ * Deconvolution (image restorations) mode which defines level of image degradation. Originally deconvolution is a function which can restore image degraded + * (convoluted) by any natural function like blur, during obtaining image by camera. Because we cannot detect image function which corrupt the image, + * we have to check most well know functions like sharp or mathematical morphology. + *
+ *+ */ +class DeconvolutionMode +{ + /** + *+ * This sample shows how to use Deconvolution mode + *+ * @code + * $reader = new BarCodeReader("test.png", null, array(DecodeType::CODE_39_FULL_ASCII, DecodeType::CODE_128)); + * $reader->getQualitySettings()->setDeconvolution(DeconvolutionMode::SLOW); + * foreach($reader->readBarCodes() as $result) + * { + * print("BarCode CodeText: " . $result->getCodeText()); + * } + * @endcode + *+ *Enables fast deconvolution methods for high quality images.
+ */ + const FAST = 0; + /** + *Enables normal deconvolution methods for common images.
+ */ + const NORMAL = 1; + /** + *Enables slow deconvolution methods for low quality images.
+ */ + const SLOW = 2; +} \ No newline at end of file diff --git a/lib/Recognition/DotCodeExtendedParameters.php b/lib/Recognition/DotCodeExtendedParameters.php new file mode 100644 index 00000000..cf73a58a --- /dev/null +++ b/lib/Recognition/DotCodeExtendedParameters.php @@ -0,0 +1,124 @@ + + * Stores special data of DotCode recognized barcode + *+ */ +class DotCodeExtendedParameters implements Communicator +{ + private DotCodeExtendedParametersDTO $dotCodeExtendedParametersDTO; + + /** + * @return DotCodeExtendedParametersDTO instance + */ + private function getDotCodeExtendedParametersDTO(): DotCodeExtendedParametersDTO + { + return $this->dotCodeExtendedParametersDTO; + } + + /** + * @param $dotCodeExtendedParametersDTO + */ + private function setDotCodeExtendedParametersDTO($dotCodeExtendedParametersDTO): void + { + $this->dotCodeExtendedParametersDTO = $dotCodeExtendedParametersDTO; + } + + function __construct(DotCodeExtendedParametersDTO $dotCodeExtendedParametersDTO) + { + $this->dotCodeExtendedParametersDTO = $dotCodeExtendedParametersDTO; + $this->obtainDto(); + $this->initFieldsFromDto(); + } + + public function obtainDto(...$args) + { + // TODO: Implement obtainDto() method. + } + + public function initFieldsFromDto(): void + { + // TODO: Implement init() method. + } + + /** + *+ * This sample shows how to get DotCode raw values + *+ * + * $generator = new BarcodeGenerator(EncodeTypes::DOT_CODE, "12345"); + * { + * $generator->save("c:\\test.png", BarCodeImageFormat::PNG); + * } + * $reader = new BarCodeReader("c:\\test.png", null, DecodeType::DOT_CODE); + * { + * foreach($reader->readBarCodes() as $result) + * { + * print("BarCode type: " . $result->getCodeTypeName()); + * print("BarCode codetext: " . $result->getCodeText()); + * print("DotCode barcode ID: " . $result->getExtended()->getDotCode()->getDotCodeStructuredAppendModeBarcodeId()); + * print("DotCode barcodes count: " . $result->getExtended()->getDotCode()->getDotCodeStructuredAppendModeBarcodesCount()); + * } + * } + *+ *Gets the DotCode structured append mode barcodes count. Default value is -1. Count must be a value from 1 to 35.
Value: The count of the DotCode structured append mode barcode. + */ + public function getDotCodeStructuredAppendModeBarcodesCount(): int + { + return $this->getDotCodeExtendedParametersDTO()->dotCodeStructuredAppendModeBarcodesCount; + } + + /** + *Gets the ID of the DotCode structured append mode barcode. ID starts from 1 and must be less or equal to barcodes count. Default value is -1.
Value: The ID of the DotCode structured append mode barcode. + */ + public function getDotCodeStructuredAppendModeBarcodeId(): int + { + return $this->getDotCodeExtendedParametersDTO()->dotCodeStructuredAppendModeBarcodeId; + } + + /** + *+ * Indicates whether code is used for instruct reader to interpret the following data as instructions for initialization or reprogramming of the bar code reader. + * Default value is false. + *
+ */ + public function getDotCodeIsReaderInitialization(): bool + { + return $this->getDotCodeExtendedParametersDTO()->dotCodeIsReaderInitialization; + } + + /** + *+ * Returns a value indicating whether this instance is equal to a specified {@code DotCodeExtendedParameters} value. + *
+ * @param DotCodeExtendedParameters $obj + * @return bool ```php + */ + public function equals(DotCodeExtendedParameters $obj): bool + { + $thriftConnection = new ThriftConnection(); + $client = $thriftConnection->openConnection(); + $isEquals = $client->DotCodeExtendedParameters_equals($this->getDotCodeExtendedParametersDTO(), $obj->getDotCodeExtendedParametersDTO()); + $thriftConnection->closeConnection(); + + return $isEquals; + } + + /** + *+ * Returns a human-readable string representation of this {@code DotCodeExtendedParameters}. + *
+ * @return string that represents this {@code DotCodeExtendedParameters}. + */ + public function toString(): string + { + return $this->getDotCodeExtendedParametersDTO()->toString; + } +} \ No newline at end of file diff --git a/lib/Recognition/GS1CompositeBarExtendedParameters.php b/lib/Recognition/GS1CompositeBarExtendedParameters.php new file mode 100644 index 00000000..e34c579f --- /dev/null +++ b/lib/Recognition/GS1CompositeBarExtendedParameters.php @@ -0,0 +1,110 @@ + + * Stores special data of {@code GS1 Composite Bar} recognized barcode + * + */ +class GS1CompositeBarExtendedParameters implements Communicator +{ + private GS1CompositeBarExtendedParametersDTO $gs1CompositeBarExtendedParameters; + + /** + * @return GS1CompositeBarExtendedParametersDTO instance + */ + private function getGS1CompositeBarExtendedParametersDTO(): GS1CompositeBarExtendedParametersDTO + { + return $this->gs1CompositeBarExtendedParameters; + } + + /** + * @param $gs1CompositeBarExtendedParameters + */ + private function setGS1CompositeBarExtendedParametersDTO($gs1CompositeBarExtendedParameters): void + { + $this->gs1CompositeBarExtendedParameters = $gs1CompositeBarExtendedParameters; + } + + function __construct(GS1CompositeBarExtendedParametersDTO $gs1CompositeBarExtendedParameters) + { + $this->gs1CompositeBarExtendedParameters = $gs1CompositeBarExtendedParameters; + $this->obtainDto(); + $this->initFieldsFromDto(); + } + + public function obtainDto(...$args) + { + // TODO: Implement obtainDto() method. + } + + public function initFieldsFromDto(): void + { + // TODO: Implement init() method. + } + + /** + *Gets the 1D (linear) barcode type of GS1 Composite
Value: 2D barcode type + */ + public function getOneDType(): int + { + return $this->getGS1CompositeBarExtendedParametersDTO()->oneDType; + } + + /** + *Gets the 1D (linear) barcode value of GS1 Composite
Value: 1D barcode value + */ + public function getOneDCodeText(): string + { + return $this->getGS1CompositeBarExtendedParametersDTO()->oneDCodeText; + } + + /** + *Gets the 2D barcode type of GS1 Composite
Value: 2D barcode type + */ + public function getTwoDType(): int + { + return $this->getGS1CompositeBarExtendedParametersDTO()->twoDType; + } + + /** + *Gets the 2D barcode value of GS1 Composite
Value: 2D barcode value + */ + public function getTwoDCodeText(): string + { + return $this->getGS1CompositeBarExtendedParametersDTO()->twoDCodeText; + } + + /** + *+ * Returns a value indicating whether this instance is equal to a specified {@code GS1CompositeBarExtendedParameters} value. + *
+ * @param GS1CompositeBarExtendedParameters $obj + * @return bool ```php + */ + public function equals(GS1CompositeBarExtendedParameters $obj): bool + { + $thriftConnection = new ThriftConnection(); + $client = $thriftConnection->openConnection(); + $isEquals = $client->GS1CompositeBarExtendedParameters_equals($this->getGS1CompositeBarExtendedParametersDTO(), $obj->getGS1CompositeBarExtendedParametersDTO()); + $thriftConnection->closeConnection(); + + return $isEquals; + } + + /** + *+ * Returns a human-readable string representation of this {@code GS1CompositeBarExtendedParameters}. + *
+ * @return string that represents this {@code GS1CompositeBarExtendedParameters}. + */ + public function toString(): string + { + return $this->getGS1CompositeBarExtendedParametersDTO()->toString; + } +} \ No newline at end of file diff --git a/lib/Recognition/InverseImageMode.php b/lib/Recognition/InverseImageMode.php new file mode 100644 index 00000000..fff9f294 --- /dev/null +++ b/lib/Recognition/InverseImageMode.php @@ -0,0 +1,39 @@ + + *+ * Mode which enables or disables additional recognition of barcodes on images with inverted colors (luminance). + *
+ *+ */ +class InverseImageMode +{ + /** + *+ * This sample shows how to use InverseImage mode + *+ * + * @code + * $reader = new BarCodeReader("test.png", null, array(DecodeType::CODE_39_FULL_ASCII, DecodeType::CODE_128)); + * $reader->getQualitySettings()->setInverseImage(InverseImageMode::ENABLED); + * foreach($reader->readBarCodes() as $result) + * { + * print("BarCode CodeText: " . $result->getCodeText()); + * } + * @endcode + *+ *At this time the same as Disabled. Disables additional recognition of barcodes on inverse images.
+ */ + const AUTO = 0; + /** + *Disables additional recognition of barcodes on inverse images.
+ */ + const DISABLED = 1; + /** + *Enables additional recognition of barcodes on inverse images
+ */ + const ENABLED = 2; +} \ No newline at end of file diff --git a/lib/Recognition/MaxiCodeExtendedParameters.php b/lib/Recognition/MaxiCodeExtendedParameters.php new file mode 100644 index 00000000..6b96ccf0 --- /dev/null +++ b/lib/Recognition/MaxiCodeExtendedParameters.php @@ -0,0 +1,126 @@ +maxiCodeExtendedParametersDTO; + } + + /** + * @param $maxiCodeExtendedParametersDTO + */ + private function setMaxiCodeExtendedParametersDTO($maxiCodeExtendedParametersDTO): void + { + $this->maxiCodeExtendedParametersDTO = $maxiCodeExtendedParametersDTO; + } + + function __construct(MaxiCodeExtendedParametersDTO $maxiCodeExtendedParametersDTO) + { + $this->maxiCodeExtendedParametersDTO = $maxiCodeExtendedParametersDTO; + $this->obtainDto(); + $this->initFieldsFromDto(); + } + + public function obtainDto(...$args) + { + // TODO: Implement obtainDto() method. + } + + public function initFieldsFromDto(): void + { + // TODO: Implement init() method. + } + + /** + * Gets a MaxiCode encode mode. + * Default value: Mode4 + */ + public function getMaxiCodeMode(): int + { + return $this->getMaxiCodeExtendedParametersDTO()->maxiCodeMode; + } + + /** + * Sets a MaxiCode encode mode. + * Default value: Mode4 + */ + public function setMaxiCodeMode(int $maxiCodeMode): void + { + $this->getMaxiCodeExtendedParametersDTO()->maxiCodeMode = $maxiCodeMode; + } + + /** + * Gets a MaxiCode barcode id in structured append mode. + * Default value: 0 + */ + public function getMaxiCodeStructuredAppendModeBarcodeId(): int + { + return $this->getMaxiCodeExtendedParametersDTO()->maxiCodeStructuredAppendModeBarcodeId; + } + + /** + * Sets a MaxiCode barcode id in structured append mode. + * Default value: 0 + */ + public function setMaxiCodeStructuredAppendModeBarcodeId(int $value): void + { + $this->getMaxiCodeExtendedParametersDTO()->maxiCodeStructuredAppendModeBarcodeId = $value; + } + + /** + * Gets a MaxiCode barcodes count in structured append mode. + * Default value: -1 + */ + public function getMaxiCodeStructuredAppendModeBarcodesCount(): int + { + return $this->getMaxiCodeExtendedParametersDTO()->maxiCodeStructuredAppendModeBarcodesCount; + } + + /** + * Sets a MaxiCode barcodes count in structured append mode. + * Default value: -1 + */ + public function setMaxiCodeStructuredAppendModeBarcodesCount(int $value): void + { + $this->getMaxiCodeExtendedParametersDTO()->maxiCodeStructuredAppendModeBarcodesCount = $value; + } + + /** + * Returns a value indicating whether this instance is equal to a specified MaxiCodeExtendedParameters value. + * @param MaxiCodeExtendedParameters $obj An System.Object value to compare to this instance. + * @return bool true if obj has the same value as this instance; otherwise, false. + */ + public function equals(MaxiCodeExtendedParameters $obj): bool + { + $thriftConnection = new ThriftConnection(); + $client = $thriftConnection->openConnection(); + $isEquals = $client->MaxiCodeExtendedParameters_equals($this->getMaxiCodeExtendedParametersDTO(), $obj->getMaxiCodeExtendedParametersDTO()); + $thriftConnection->closeConnection(); + + return $isEquals; + } + + /** + * Returns a human-readable string representation of this MaxiCodeExtendedParameters. + * @return string A string that represents this MaxiCodeExtendedParameters. + */ + public function toString(): string + { + return $this->getMaxiCodeExtendedParametersDTO()->toString; + } +} \ No newline at end of file diff --git a/lib/Recognition/OneDExtendedParameters.php b/lib/Recognition/OneDExtendedParameters.php new file mode 100644 index 00000000..db668aab --- /dev/null +++ b/lib/Recognition/OneDExtendedParameters.php @@ -0,0 +1,144 @@ +save("test.png"); + * $reader = new BarCodeReader("test.png", DecodeType::EAN_13); + * foreach($reader->readBarCodes() as $result) + * { + * print("BarCode Type: ".$result->getCodeTypeName()); + * print("BarCode CodeText: ".$result->getCodeText()); + * print("BarCode Value: ".$result->getExtended()->getOneD()->getValue()); + * print("BarCode Checksum: ".$result->getExtended()->getOneD()->getCheckSum()); + * } + * @endcode + */ +final class OneDExtendedParameters implements Communicator +{ + private OneDExtendedParametersDTO $oneDExtendedParametersDTO; + + /** + * @return OneDExtendedParametersDTO instance + */ + private function getOneDExtendedParametersDTO(): OneDExtendedParametersDTO + { + return $this->oneDExtendedParametersDTO; + } + + /** + * @param $oneDExtendedParametersDTO + */ + private function setOneDExtendedParametersDTO($oneDExtendedParametersDTO): void + { + $this->oneDExtendedParametersDTO = $oneDExtendedParametersDTO; + } + + function __construct(OneDExtendedParametersDTO $oneDExtendedParametersDTO) + { + $this->oneDExtendedParametersDTO = $oneDExtendedParametersDTO; + $this->obtainDto(); + $this->initFieldsFromDto(); + } + + public function obtainDto(...$args) + { + // TODO: Implement obtainDto() method. + } + + public function initFieldsFromDto(): void + { + } + + /** + * Gets the codetext of 1D barcodes without checksum. Value: The codetext of 1D barcodes without checksum. + */ + public function getValue(): string + { + try + { + return $this->getOneDExtendedParametersDTO()->value; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Gets the checksum for 1D barcodes. Value: The checksum for 1D barcode. + */ + public function getCheckSum(): string + { + try + { + return $this->getOneDExtendedParametersDTO()->checkSum; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Tests whether all parameters has only default values + * @return bool Returns { true} if all parameters has only default values; otherwise, { false}. + * @throws BarcodeException + */ + public function isEmpty(): bool + { + try + { + return $this->getOneDExtendedParametersDTO()->empty; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Returns a value indicating whether this instance is equal to a specified OneDExtendedParameters value. + * + * @param OneDExtendedParameters obj An System.Object value to compare to this instance. + * @return bool true if obj has the same value as this instance; otherwise, false. + */ + public function equals(OneDExtendedParameters $obj): bool + { + $thriftConnection = new ThriftConnection(); + $client = $thriftConnection->openConnection(); + $isEquals = $client->OneDExtendedParameters_equals($this->getOneDExtendedParametersDTO(), $obj->getOneDExtendedParametersDTO()); + $thriftConnection->closeConnection(); + + return $isEquals; + } + + /** + * Returns a human-readable string representation of this OneDExtendedParameters. + * + * @return string A string that represents this OneDExtendedParameters. + */ + public function toString(): string + { + try + { + return $this->getOneDExtendedParametersDTO()->toString; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } +} \ No newline at end of file diff --git a/lib/Recognition/Pdf417ExtendedParameters.php b/lib/Recognition/Pdf417ExtendedParameters.php new file mode 100644 index 00000000..bacbf895 --- /dev/null +++ b/lib/Recognition/Pdf417ExtendedParameters.php @@ -0,0 +1,285 @@ +getParameters()->getBarcode()->getPdf417()->setPdf417MacroFileID(10); + * $generator->getParameters()->getBarcode()->getPdf417()->setPdf417MacroSegmentsCount(2); + * $generator->getParameters()->getBarcode()->getPdf417()->setPdf417MacroSegmentID(1); + * $generator->save("test.png"); + * $reader = new BarCodeReader("test.png", DecodeType::MACRO_PDF_417); + * foreach($reader->readBarCodes() as $result) + * { + * print("BarCode Type: ".$result->getCodeTypeName()); + * print("BarCode CodeText: ".$result->getCodeText()); + * print("Macro Pdf417 FileID: ".$result->getExtended()->getPdf417()->getMacroPdf417FileID()); + * print("Macro Pdf417 Segments: ".$result->getExtended()->getPdf417()->getMacroPdf417SegmentsCount()); + * print("Macro Pdf417 SegmentID: ".$result->getExtended()->getPdf417()->getMacroPdf417SegmentID()); + * } + * @endcode + */ +final class Pdf417ExtendedParameters implements Communicator +{ + private Pdf417ExtendedParametersDTO $pdf417ExtendedParametersDTO; + + /** + * @return Pdf417ExtendedParametersDTO instance + */ + private function getPdf417ExtendedParametersDTO(): Pdf417ExtendedParametersDTO + { + return $this->pdf417ExtendedParametersDTO; + } + + /** + * @param $pdf417ExtendedParametersDTO + */ + private function setQRExtendedParametersDTO($pdf417ExtendedParametersDTO): void + { + $this->pdf417ExtendedParametersDTO = $pdf417ExtendedParametersDTO; + } + + function __construct(Pdf417ExtendedParametersDTO $pdf417ExtendedParametersDTO) + { + $this->pdf417ExtendedParametersDTO = $pdf417ExtendedParametersDTO; + $this->obtainDto(); + $this->initFieldsFromDto(); + } + + public function obtainDto(...$args) + { + // TODO: Implement obtainDto() method. + } + + public function initFieldsFromDto(): void + { + // TODO: Implement init() method. + } + + /** + * Gets the file ID of the barcode, only available with MacroPdf417.Value: The file ID for MacroPdf417 + */ + public function getMacroPdf417FileID(): string + { + try + { + return $this->getPdf417ExtendedParametersDTO()->macroPdf417FileID; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Gets the segment ID of the barcode,only available with MacroPdf417.Value: The segment ID of the barcode. + */ + public function getMacroPdf417SegmentID(): int + { + try + { + return $this->getPdf417ExtendedParametersDTO()->macroPdf417SegmentID; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Gets macro pdf417 barcode segments count. Default value is -1.Value: Segments count. + */ + public function getMacroPdf417SegmentsCount(): int + { + try + { + return $this->getPdf417ExtendedParametersDTO()->macroPdf417SegmentsCount; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Macro PDF417 file name (optional). + * @return string File name. + */ + public function getMacroPdf417FileName(): string + { + try + { + return $this->getPdf417ExtendedParametersDTO()->macroPdf417FileName; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Macro PDF417 file size (optional). + * @return int File size. + */ + public function getMacroPdf417FileSize(): int + { + try + { + return $this->getPdf417ExtendedParametersDTO()->macroPdf417FileSize; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Macro PDF417 sender name (optional). + * @return string Sender name + */ + public function getMacroPdf417Sender(): string + { + try + { + return $this->getPdf417ExtendedParametersDTO()->macroPdf417Sender; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Macro PDF417 addressee name (optional). + * @return string Addressee name. + */ + public function getMacroPdf417Addressee(): string + { + try + { + return $this->getPdf417ExtendedParametersDTO()->macroPdf417Addressee; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Macro PDF417 time stamp (optional). + * @return DateTime Time stamp. + */ + public function getMacroPdf417TimeStamp(): DateTime + { + try + { + return new DateTime('@' . $this->getPdf417ExtendedParametersDTO()->macroPdf417TimeStamp); + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Macro PDF417 checksum (optional). + * @return int Checksum. + */ + public function getMacroPdf417Checksum(): int + { + try + { + return $this->getPdf417ExtendedParametersDTO()->macroPdf417Checksum; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Indicates whether the segment is the last segment of a Macro PDF417 file. + */ + public function getMacroPdf417Terminator(): bool + { + try + { + return $this->getPdf417ExtendedParametersDTO()->macroPdf417Terminator; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + *Used to instruct the reader to interpret the data contained within the symbol as programming for reader initialization.
Value: Reader initialization flag + */ + public function isReaderInitialization(): bool + { + return $this->getPdf417ExtendedParametersDTO()->isReaderInitialization; + } + + /** + *Flag that indicates that the barcode must be linked to 1D barcode.
Value: Linkage flag + */ + public function isLinked(): bool + { + return $this->getPdf417ExtendedParametersDTO()->isLinked; + } + + /** + * Flag that indicates that the MicroPdf417 barcode encoded with 908, 909, 910 or 911 Code 128 emulation codewords. + * @return bool 128 emulation flag + */ + public function isCode128Emulation(): bool + { + return $this->getPdf417ExtendedParametersDTO()->isCode128Emulation; + } + + /** + * Returns a value indicating whether this instance is equal to a specified Pdf417ExtendedParameters value. + * + * @param Pdf417ExtendedParameters $obj An System.Object value to compare to this instance. + * @return bool true if obj has the same value as this instance; otherwise, false. + */ + public function equals(Pdf417ExtendedParameters $obj): bool + { + $thriftConnection = new ThriftConnection(); + $client = $thriftConnection->openConnection(); + $isEquals = $client->Pdf417ExtendedParameters_equals($this->getPdf417ExtendedParametersDTO(), $obj->getPdf417ExtendedParametersDTO()); + $thriftConnection->closeConnection(); + + return $isEquals; + } + + /** + * Returns a human-readable string representation of this Pdf417ExtendedParameters. + * @return string A string that represents this Pdf417ExtendedParameters. + * @throws BarcodeException + */ + public function toString(): string + { + try + { + return $this->getPdf417ExtendedParametersDTO()->toString;// TODO implement + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + +} \ No newline at end of file diff --git a/lib/Recognition/QRExtendedParameters.php b/lib/Recognition/QRExtendedParameters.php new file mode 100644 index 00000000..f2d40a3f --- /dev/null +++ b/lib/Recognition/QRExtendedParameters.php @@ -0,0 +1,191 @@ +readBarCodes() as $result) + * { + * print("BarCode Type: ".$result->getCodeTypeName()); + * print("BarCode CodeText: ".$result->getCodeText()); + * print("QR Structured Append Quantity: ".$result->getExtended()->getQR()->getQRStructuredAppendModeBarCodesQuantity()); + * print("QR Structured Append Index: ".$result->getExtended()->getQR()->getQRStructuredAppendModeBarCodeIndex()); + * print("QR Structured Append ParityData: ".$result->getExtended()->getQR()->getQRStructuredAppendModeParityData()); + * } + * @endcode + */ +final class QRExtendedParameters implements Communicator +{ + private QRExtendedParametersDTO $qrExtendedParametersDTO; + + /** + * @return QRExtendedParametersDTO instance + */ + private function getQRExtendedParametersDTO(): QRExtendedParametersDTO + { + return $this->qrExtendedParametersDTO; + } + + /** + * @param $qrExtendedParametersDTO + */ + private function setQRExtendedParametersDTO($qrExtendedParametersDTO): void + { + $this->qrExtendedParametersDTO = $qrExtendedParametersDTO; + } + + function __construct(QRExtendedParametersDTO $qrExtendedParametersDTO) + { + $this->qrExtendedParametersDTO = $qrExtendedParametersDTO; + $this->obtainDto(); + $this->initFieldsFromDto(); + } + + public function obtainDto(...$args) + { + // TODO: Implement obtainDto() method. + } + + public function initFieldsFromDto(): void + { + // TODO: Implement init() method. + } + + /** + * Gets the QR structured append mode barcodes quantity. Default value is -1.Value: The quantity of the QR structured append mode barcode. + */ + public function getQRStructuredAppendModeBarCodesQuantity(): int + { + try + { + return $this->getQRExtendedParametersDTO()->qRStructuredAppendModeBarCodesQuantity; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Gets the index of the QR structured append mode barcode. Index starts from 0. Default value is -1.Value: The quantity of the QR structured append mode barcode. + */ + public function getQRStructuredAppendModeBarCodeIndex(): int + { + try + { + return $this->getQRExtendedParametersDTO()->qRStructuredAppendModeBarCodeIndex; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Version of recognized QR Code. From Version1 to Version40. + * return recognized QR Code + */ + public function getQRVersion(): int + { + return $this->getQRExtendedParametersDTO()->qrVersion; + } + + /** + * Version of recognized MicroQR Code. From M1 to M4. + * return recognized MicroQR Code. From M1 to M4. + */ + public function getMicroQRVersion(): int + { + return $this->getQRExtendedParametersDTO()->microQRVersion; + } + + /** + * Version of recognized RectMicroQR Code. From R7x43 to R17x139. + * @return int of recognized RectMicroQR Code + */ + public function getRectMicroQRVersion(): int + { + return $this->getQRExtendedParametersDTO()->rectMicroQRVersion; + } + + /** + * Reed-Solomon error correction level of recognized barcode. From low to high: LevelL, LevelM, LevelQ, LevelH. + * @return int error correction level of recognized barcode. + */ + public function getQRErrorLevel(): int + { + return $this->getQRExtendedParametersDTO()->qrErrorLevel; + } + + + /** + * Gets the QR structured append mode parity data. Default value is -1.Value: The index of the QR structured append mode barcode. + */ + public function getQRStructuredAppendModeParityData(): int + { + try + { + return $this->getQRExtendedParametersDTO()->qRStructuredAppendModeParityData; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + public function isEmpty(): bool + { + try + { + return $this->getQRExtendedParametersDTO()->empty; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Returns a value indicating whether this instance is equal to a specified QRExtendedParameters value. + * + * @param QRExtendedParameters $obj An object value to compare to this instance. + * @return bool true if obj has the same value as this instance; otherwise, false. + */ + public function equals(QRExtendedParameters $obj): bool + { + $thriftConnection = new ThriftConnection(); + $client = $thriftConnection->openConnection(); + $isEquals = $client->QRExtendedParameters_equals($this->getQRExtendedParametersDTO(), $obj->getQRExtendedParametersDTO()); + $thriftConnection->closeConnection(); + + return $isEquals; + } + + /** + * Returns a human-readable string representation of this QRExtendedParameters. + * + * @return string A string that represents this QRExtendedParameters. + */ + public function toString(): string + { + try + { + return $this->getQRExtendedParametersDTO()->toString; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } +} \ No newline at end of file diff --git a/lib/Recognition/Quadrangle.php b/lib/Recognition/Quadrangle.php new file mode 100644 index 00000000..a87d46af --- /dev/null +++ b/lib/Recognition/Quadrangle.php @@ -0,0 +1,335 @@ +quadrangleDTO; + } + + /** + * @param QuadrangleDTO $quadrangleDTO + */ + private function setQuadrangleDTO(QuadrangleDTO $quadrangleDTO): void + { + $this->quadrangleDTO = $quadrangleDTO; + } + + /** + * Represents a Quadrangle structure with its properties left uninitialized.Value: Quadrangle + */ + public static function EMPTY(): Quadrangle + { + return new Quadrangle(new Point(0, 0), new Point(0, 0), new Point(0, 0), new Point(0, 0)); + } + + static function construct(QuadrangleDTO $quadrangleDTO): Quadrangle + { + $quadrangle = Quadrangle::EMPTY(); + $quadrangle->setQuadrangleDTO($quadrangleDTO); + $quadrangle->initFieldsFromDto(); + return $quadrangle; + } + + /** + * Initializes a new instance of the Quadrangle structure with the describing points. + * + * @param Point $leftTop A Point that represents the left-top corner of the Quadrangle. + * @param Point $rightTop A Point that represents the right-top corner of the Quadrangle. + * @param Point $rightBottom A Point that represents the right-bottom corner of the Quadrangle. + * @param Point $leftBottom A Point that represents the left-bottom corner of the Quadrangle. + */ + public function __construct(Point $leftTop, Point $rightTop, Point $rightBottom, Point $leftBottom) + { + $this->quadrangleDTO = new QuadrangleDTO(); + $this->getQuadrangleDTO()->leftTop = $leftTop->getPointDTO(); + $this->getQuadrangleDTO()->rightTop = $rightTop->getPointDTO(); + $this->getQuadrangleDTO()->rightBottom = $rightBottom->getPointDTO(); + $this->getQuadrangleDTO()->leftBottom = $leftBottom->getPointDTO(); + $this->initFieldsFromDto(); + } + + public function obtainDto(...$args) + { + // TODO: Implement obtainDto() method. + } + + public function initFieldsFromDto(): void + { + $this->leftTop = Point::construct($this->getQuadrangleDTO()->leftTop); + $this->rightTop = Point::construct($this->getQuadrangleDTO()->rightTop); + $this->rightBottom = Point::construct($this->getQuadrangleDTO()->rightBottom); + $this->leftBottom = Point::construct($this->getQuadrangleDTO()->leftBottom); + } + + /** + * Gets left-top corner Point of Quadrangle regionValue: A left-top corner Point of Quadrangle region + */ + public function getLeftTop(): Point + { + return $this->leftTop; + } + + /** + * Gets left-top corner Point of Quadrangle regionValue: A left-top corner Point of Quadrangle region + */ + public function setLeftTop(Point $value): void + { + try + { + $this->leftTop = $value; + $this->getQuadrangleDTO()->leftTop = $value->getPointDTO(); + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Gets right-top corner Point of Quadrangle regionValue: A right-top corner Point of Quadrangle region + */ + public function getRightTop(): Point + { + return $this->rightTop; + } + + /** + * Gets right-top corner Point of Quadrangle regionValue: A right-top corner Point of Quadrangle region + */ + public function setRightTop(Point $value): void + { + try + { + $this->rightTop = $value; + $this->getQuadrangleDTO()->rightTop = $value->getPointDTO(); + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Gets right-bottom corner Point of Quadrangle regionValue: A right-bottom corner Point of Quadrangle region + */ + public function getRightBottom(): Point + { + return $this->rightBottom; + } + + /** + * Gets right-bottom corner Point of Quadrangle regionValue: A right-bottom corner Point of Quadrangle region + */ + public function setRightBottom(Point $value): void + { + try + { + $this->rightBottom = $value; + $this->getQuadrangleDTO()->rightBottom = $value->getPointDTO(); + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Gets left-bottom corner Point of Quadrangle regionValue: A left-bottom corner Point of Quadrangle region + */ + public function getLeftBottom(): Point + { + return $this->leftBottom; + } + + /** + * Gets left-bottom corner Point of Quadrangle regionValue: A left-bottom corner Point of Quadrangle region + */ + public function setLeftBottom(Point $value): void + { + try + { + $this->leftBottom = $value; + $this->getQuadrangleDTO()->leftBottom = $value->getPointDTO(); + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Tests whether all Points of this Quadrangle have values of zero.Value: Returns true if all Points of this Quadrangle have values of zero; otherwise, false. + */ + public function isEmpty(): bool + { + return $this->equals(Quadrangle::EMPTY()); + } + + /** + * Determines if the specified Point is contained within this Quadrangle structure. + * + * @param Point $pt + * @return bool Returns true if Point is contained within this Quadrangle structure; otherwise, false. + * @throws BarcodeException + */ + public function containsPoint(Point $pt): bool + { + try + { + $thriftConnection = new ThriftConnection(); + $client = $thriftConnection->openConnection(); + $containsPointResponse = $client->Quadrangle_containsPoint($this->getQuadrangleDTO(), $pt->getPointDTO()); + $thriftConnection->closeConnection(); + return $containsPointResponse; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Determines if the specified point is contained within this Quadrangle structure. + * + * @param int $x The x point cordinate. + * @param int $y The y point cordinate. + * @return bool Returns true if point is contained within this Quadrangle structure; otherwise, false. + */ + public function containsCoordinates(int $x, int $y): bool + { + try + { + $thriftConnection = new ThriftConnection(); + $client = $thriftConnection->openConnection(); + $containsPointResponse = $client->Quadrangle_containsCoordinates($this->getQuadrangleDTO(), $x, $y); + $thriftConnection->closeConnection(); + return $containsPointResponse; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Determines if the specified Quadrangle is contained or intersect this Quadrangle structure. + * + * @param Quadrangle The Quadrangle to test. + * @return bool Returns true if Quadrangle is contained or intersect this Quadrangle structure; otherwise, false. + */ + public function containsQuadrangle(Quadrangle $quad): bool + { + try + { + $thriftConnection = new ThriftConnection(); + $client = $thriftConnection->openConnection(); + $containsPointResponse = $client->Quadrangle_containsQuadrangle($this->getQuadrangleDTO(), $quad->getQuadrangleDTO()); + $thriftConnection->closeConnection(); + return $containsPointResponse; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Determines if the specified Rectangle is contained or intersect this Quadrangle structure. + * + * @param Rectangle $rect + * @return bool Returns true if Rectangle is contained or intersect this Quadrangle structure; otherwise, false. + * @throws BarcodeException + */ + public function containsRectangle(Rectangle $rect): bool + { + try + { + $thriftConnection = new ThriftConnection(); + $client = $thriftConnection->openConnection(); + $containsPointResponse = $client->Quadrangle_containsRectangle($this->getQuadrangleDTO(), $rect->getRectangleDto()); + $thriftConnection->closeConnection(); + return $containsPointResponse; + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Returns a value indicating whether this instance is equal to a specified Quadrangle value. + * + * @param Quadrangle $obj + * @return bool true if obj has the same value as this instance; otherwise, false. + */ + public function equals(Quadrangle $obj): bool + { + $thriftConnection = new ThriftConnection(); + $client = $thriftConnection->openConnection(); + $isEquals = $client->Quadrangle_equals($this->getQuadrangleDTO(), $obj->getQuadrangleDTO()); + $thriftConnection->closeConnection(); + + return $isEquals; + } + + /** + * Returns a human-readable string representation of this Quadrangle. + * + * @return string A string that represents this Quadrangle. + */ + public function toString(): string + { + $thriftConnection = new ThriftConnection(); + $client = $thriftConnection->openConnection(); + $str = $client->Quadrangle_toString($this->getQuadrangleDTO()); + $thriftConnection->closeConnection(); + + return $str; + } + + /** + * Creates Rectangle bounding this Quadrangle + * + * @return Rectangle returns Rectangle bounding this Quadrangle + */ + public function getBoundingRectangle(): Rectangle + { + try + { + $thriftConnection = new ThriftConnection(); + $client = $thriftConnection->openConnection(); + $boundingRectangleDTO = $client->Quadrangle_getBoundingRectangle($this->getQuadrangleDTO()); + $thriftConnection->closeConnection(); + return Rectangle::construct($boundingRectangleDTO); + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } +} \ No newline at end of file diff --git a/lib/Recognition/QualitySettings.php b/lib/Recognition/QualitySettings.php new file mode 100644 index 00000000..8a4e64ff --- /dev/null +++ b/lib/Recognition/QualitySettings.php @@ -0,0 +1,332 @@ +setQualitySettings(QualitySettings::getHighPerformance()); + * foreach($reader->readBarCodes() as $result) + * print("BarCode CodeText: ".$result->getCodeText()); + * $reader = new BarCodeReader("test.png", null, array(DecodeType::CODE_39, DecodeType::CODE_128)); + * //normal quality mode is set by default + * foreach($reader->readBarCodes() as $result) + * print("BarCode CodeText: ".$result->getCodeText()); + * $reader = new BarCodeReader("test.png", null, array(DecodeType::CODE_39, DecodeType::CODE_128)); + * //set high quality mode with low speed recognition + * $reader->setQualitySettings(QualitySettings::getHighQuality()); + * foreach($reader->readBarCodes() as $result) + * print("BarCode CodeText: ".$result->getCodeText()); + * $reader = new BarCodeReader("test.png", null, array(DecodeType::CODE_39, DecodeType::CODE_128)); + * //set max barcodes mode, which tries to find all possible barcodes, even incorrect. The slowest recognition mode + * $reader->setQualitySettings(QualitySettings::getMaxBarCodes()); + * foreach($reader->readBarCodes() as $result) + * print("BarCode CodeText: ".$result->getCodeText()); + * $reader = new BarCodeReader("test.png", null, array(DecodeType::CODE_39, DecodeType::CODE_128)); + * //set high performance mode + * $reader->setQualitySettings(QualitySettings::getHighPerformance()); + * //set separate options + * foreach($reader->readBarCodes() as $result) + * print("BarCode CodeText: ".$result->getCodeText()); + * $reader = new BarCodeReader("test.png", null, array(DecodeType::CODE_39, DecodeType::CODE_128)); + * //default mode is NormalQuality + * //set separate options + * foreach($reader->readBarCodes() as $result) + * print("BarCode CodeText: ".$result->getCodeText()); + * @endcode + */ +final class QualitySettings implements Communicator +{ + private QualitySettingsDTO $qualitySettingsDTO; + + /** + * @return QualitySettingsDTO instance + */ + function getQualitySettingsDTO(): QualitySettingsDTO + { + return $this->qualitySettingsDTO; + } + + /** + * @param $qualitySettingsDTO QualitySettingsDTO instance + */ + private function setQualitySettingsDTO(QualitySettingsDTO $qualitySettingsDTO): void + { + $this->qualitySettingsDTO = $qualitySettingsDTO; + $this->initFieldsFromDto(); + } + + function __construct(QualitySettingsDTO $qualitySettingsDTO) + { + $this->qualitySettingsDTO = $qualitySettingsDTO; + $this->obtainDto(); + $this->initFieldsFromDto(); + } + + public function obtainDto(...$args) + { + } + + public function initFieldsFromDto() + { + } + + /** + * HighPerformance recognition quality preset. High quality barcodes are recognized well in this mode. + * + * @code + * $reader = new BarCodeReader("test.png"); + * $reader->setQualitySettings(QualitySettings::getHighPerformance()); + * @return QualitySettings HighPerformance recognition quality preset. + * @endcode + * @throws BarcodeException + */ + public static function getHighPerformance(): QualitySettings + { + try + { + $thriftConnection = new ThriftConnection(); + $client = $thriftConnection->openConnection(); + $qualitySettingsDTO = $client->QualitySettings_getHighPerformance(); + $thriftConnection->closeConnection(); + return new QualitySettings($qualitySettingsDTO); + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * NormalQuality recognition quality preset. Suitable for the most of barcodes + * + * @code + * $reader = new BarCodeReader("test.png"); + * $reader->setQualitySettings(QualitySettings::getNormalQuality()); + * @endcode + * + * @return QualitySettings NormalQuality recognition quality preset. + * @throws BarcodeException + */ + public static function getNormalQuality(): QualitySettings + { + try + { + $thriftConnection = new ThriftConnection(); + $client = $thriftConnection->openConnection(); + $qualitySettingsDTO = $client->QualitySettings_getNormalQuality(); + $thriftConnection->closeConnection(); + return new QualitySettings($qualitySettingsDTO); + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * HighQuality recognition quality preset. This preset is developed for low quality barcodes. + * + * @code + * $reader = new BarCodeReader("test.png"); + * $reader->setQualitySettings(QualitySettings::getHighQuality()); + * @endcode + * @return QualitySettings HighQuality recognition quality preset. + * @throws BarcodeException + */ + public static function getHighQuality(): QualitySettings + { + try + { + $thriftConnection = new ThriftConnection(); + $client = $thriftConnection->openConnection(); + $qualitySettingsDTO = $client->QualitySettings_getHighQuality(); + $thriftConnection->closeConnection(); + return new QualitySettings($qualitySettingsDTO); + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + *+ * MaxQuality recognition quality preset. This preset is developed to recognize all possible barcodes, even incorrect barcodes. + *
Value: + * MaxQuality recognition quality preset. + * + */ + public static function getMaxQuality(): QualitySettings + { + try + { + $thriftConnection = new ThriftConnection(); + $client = $thriftConnection->openConnection(); + $qualitySettingsDTO = $client->QualitySettings_getMaxQuality(); + $thriftConnection->closeConnection(); + return new QualitySettings($qualitySettingsDTO); + } + catch (Exception $ex) + { + throw new BarcodeException($ex->getMessage(), __FILE__, __LINE__); + } + } + + /** + * Recognition mode which sets size (from 1 to infinity) of barcode minimal element: matrix cell or bar. + * @return int : size (from 1 to infinity) of barcode minimal element: matrix cell or bar. + */ + public function getXDimension(): int + { + return $this->qualitySettingsDTO->xDimension; + } + + /** + * Recognition mode which sets size (from 1 to infinity) of barcode minimal element: matrix cell or bar. + * @param int : size (from 1 to infinity) of barcode minimal element: matrix cell or bar. + */ + public function setXDimension(int $value): void + { + $this->qualitySettingsDTO->xDimension = $value; + } + + /** + * Minimal size of XDimension in pixels which is used with UseMinimalXDimension. + * @return float : Minimal size of XDimension in pixels which is used with UseMinimalXDimension. + */ + public function getMinimalXDimension(): float + { + return $this->qualitySettingsDTO->minimalXDimension; + } + + /** + * Minimal size of XDimension in pixels which is used with UseMinimalXDimension. + * @param $value : Minimal size of XDimension in pixels which is used with UseMinimalXDimension. + */ + public function setMinimalXDimension(float $value): void + { + $this->qualitySettingsDTO->minimalXDimension = $value; + } + + /** + *+ * This sample shows how to use MaxQuality mode + *+ * + * $reader = new BarCodeReader("test.png"null, null, array(DecodeType::CODE_39_FULL_ASCII, DecodeType::CODE_128)); + * { + * $reader->setQualitySettings(QualitySettings::getMaxQuality()); + * foreach($reader->readBarCodes() as $result) + * echo ($result->getCodeText()); + * } + *+ *+ * Mode which enables methods to recognize barcode elements with the selected quality. Barcode element with lower quality requires more hard methods which slows the recognition. + * @return int : Mode which enables methods to recognize barcode elements with the selected quality. + */ + public function getBarcodeQuality(): int + { + return $this->qualitySettingsDTO->barcodeQuality; + } + + /** + * Mode which enables methods to recognize barcode elements with the selected quality. Barcode element with lower quality requires more hard methods which slows the recognition. + * @param $value : Mode which enables methods to recognize barcode elements with the selected quality. + */ + public function setBarcodeQuality(int $value): void + { + $this->qualitySettingsDTO->barcodeQuality = $value; + } + + /** + *
+ * Deconvolution (image restorations) mode which defines level of image degradation. Originally deconvolution is a function which can restore image degraded + * (convoluted) by any natural function like blur, during obtaining image by camera. Because we cannot detect image function which corrupt the image, + * we have to check most well know functions like sharp or mathematical morphology. + * @return int : Deconvolution mode which defines level of image degradation. + */ + public function getDeconvolution(): int + { + return $this->qualitySettingsDTO->deconvolution; + } + + /** + * Deconvolution (image restorations) mode which defines level of image degradation. Originally deconvolution is a function which can restore image degraded + * (convoluted) by any natural function like blur, during obtaining image by camera. Because we cannot detect image function which corrupt the image, + * we have to check most well know functions like sharp or mathematical morphology. + * @param $value : Deconvolution mode which defines level of image degradation. + */ + public function setDeconvolution(int $value): void + { + $this->qualitySettingsDTO->deconvolution = $value; + } + + /** + * Mode which enables or disables additional recognition of barcodes on images with inverted colors (luminance). + * @return int : Additional recognition of barcodes on images with inverse colors + */ + public function getInverseImage(): int + { + return $this->qualitySettingsDTO->inverseImage; + } + + /** + * Mode which enables or disables additional recognition of barcodes on images with inverted colors (luminance). + * @param $value : Additional recognition of barcodes on images with inverse colors + */ + public function setInverseImage(int $value): void + { + $this->qualitySettingsDTO->inverseImage = $value; + } + + /** + *
+ * Mode which enables or disables additional recognition of color barcodes on color images. + * @return int : Additional recognition of color barcodes on color images. + */ + public function getComplexBackground(): int + { + return $this->qualitySettingsDTO->complexBackground; + } + + /** + * Mode which enables or disables additional recognition of color barcodes on color images. + * @param $value : Additional recognition of color barcodes on color images. + */ + public function setComplexBackground(int $value): void + { + $this->qualitySettingsDTO->complexBackground = $value; + } + + /** + * Allows engine to recognize barcodes which has incorrect checksumm or incorrect values. Mode can be used to recognize damaged barcodes with incorrect text. + * @return bool : Allows engine to recognize incorrect barcodes. + */ + public function getAllowIncorrectBarcodes(): bool + { + return $this->qualitySettingsDTO->allowIncorrectBarcodes; + } + + /** + * Allows engine to recognize barcodes which has incorrect checksumm or incorrect values. Mode can be used to recognize damaged barcodes with incorrect text. + * @param $value : Allows engine to recognize incorrect barcodes. + */ + public function setAllowIncorrectBarcodes(bool $value): void + { + $this->qualitySettingsDTO->allowIncorrectBarcodes = $value; + } +} \ No newline at end of file diff --git a/lib/Recognition/RecognitionAbortedException.php b/lib/Recognition/RecognitionAbortedException.php new file mode 100644 index 00000000..d642528e --- /dev/null +++ b/lib/Recognition/RecognitionAbortedException.php @@ -0,0 +1,39 @@ +executionTime; + } + + /** + * Sets the execution time of current recognition session + * @param int $value The execution time of current recognition session + */ + public function setExecutionTime(int $value): void + { + $this->executionTime = $value; + } + + /** + * Initializes a new instance of the
class with specified recognition abort message. + * @param $message null|string The error message of the exception. + * @param $executionTime null|int The execution time of current recognition session. + */ + public function __construct(?string $message, ?int $executionTime) + { + parent::__construct($message); + $this->executionTime = $executionTime; + } +} \ No newline at end of file diff --git a/lib/Recognition/XDimensionMode.php b/lib/Recognition/XDimensionMode.php new file mode 100644 index 00000000..99eb869b --- /dev/null +++ b/lib/Recognition/XDimensionMode.php @@ -0,0 +1,46 @@ + + * + * Recognition mode which sets size (from 1 to infinity) of barcode minimal element: matrix cell or bar. + *
+ *+ */ +class XDimensionMode +{ + /** + *+ * This sample shows how to use XDimension mode + *+ * @code + * $reader = new BarCodeReader("test.png", null, array(DecodeType::CODE_39_FULL_ASCII, DecodeType::CODE_128)); + * $reader->getQualitySettings()->setXDimension(XDimensionMode::SMALL); + * foreach($reader->readBarCodes() as $result) + * { + * print("BarCode CodeText: " . $result->getCodeText()); + * } + * @endcode + *+ *Value of XDimension is detected by AI (SVM). At this time the same as Normal
+ */ + const AUTO = 0; + /** + *Detects barcodes with small XDimension in 1 pixel or more with quality from BarcodeQuality
+ */ + const SMALL = 1; + /** + *Detects barcodes with classic XDimension in 2 pixels or more with quality from BarcodeQuality or high quality barcodes.
+ */ + const NORMAL = 2; + /** + *Detects barcodes with large XDimension with quality from BarcodeQuality captured with high-resolution cameras.
+ */ + const LARGE = 3; + /** + *Detects barcodes from size set in MinimalXDimension with quality from BarcodeQuality
+ */ + const USE_MINIMAL_X_DIMENSION = 4; +} \ No newline at end of file From afe806fdfb5aae78293213e55b4012982e6ca709 Mon Sep 17 00:00:00 2001 From: Aleksander GrininDate: Tue, 9 Sep 2025 14:10:21 +0300 Subject: [PATCH 2/2] Update .gitattributes --- .gitattributes | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitattributes b/.gitattributes index 10898151..40fe6746 100644 --- a/.gitattributes +++ b/.gitattributes @@ -8,6 +8,7 @@ /docs/ export-ignore /composer_install.cmd export-ignore /composer_update.cmd export-ignore +/composer_dump_autoload.cmd export-ignore /server.log export-ignore /TEMP* export-ignore /*.neon export-ignore \ No newline at end of file