1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* This file is part of PhpAidc LabelPrinter package. |
5
|
|
|
* |
6
|
|
|
* © Appwilio (https://appwilio.com) |
7
|
|
|
* © JhaoDa (https://github.com/jhaoda) |
8
|
|
|
* |
9
|
|
|
* For the full copyright and license information, please view the LICENSE |
10
|
|
|
* file that was distributed with this source code. |
11
|
|
|
*/ |
12
|
|
|
|
13
|
|
|
declare(strict_types=1); |
14
|
|
|
|
15
|
|
|
namespace PhpAidc\LabelPrinter\Language\Fingerprint; |
16
|
|
|
|
17
|
|
|
use PhpAidc\LabelPrinter\Command\Barcode; |
18
|
|
|
use PhpAidc\LabelPrinter\Language\Fingerprint; |
19
|
|
|
use PhpAidc\LabelPrinter\Language\Fingerprint\Concerns\Font; |
20
|
|
|
use PhpAidc\LabelPrinter\Language\Fingerprint\Concerns\Align; |
21
|
|
|
use PhpAidc\LabelPrinter\Language\Fingerprint\Concerns\Rotate; |
22
|
|
|
use PhpAidc\LabelPrinter\Language\Fingerprint\Concerns\Position; |
23
|
|
|
|
24
|
|
|
final class FingerprintBarcode |
25
|
|
|
{ |
26
|
|
|
use Font; |
27
|
|
|
use Align; |
28
|
|
|
use Rotate; |
29
|
|
|
use Position; |
30
|
|
|
|
31
|
|
|
public function translate(Barcode $command): iterable |
32
|
|
|
{ |
33
|
|
|
yield from $this->position($command); |
34
|
|
|
|
35
|
|
|
yield from $this->rotate($command); |
36
|
|
|
|
37
|
|
|
yield from $this->align($command); |
38
|
|
|
|
39
|
|
|
yield \sprintf('BT "%s"', $command->getType()); |
40
|
|
|
|
41
|
|
|
// TODO: ratio |
42
|
|
|
//yield \sprintf('BR %d,%d', $ratio['wide'], $ratio['narrow']); |
43
|
|
|
|
44
|
|
|
$magnification = $command->getMagnification(); |
45
|
|
|
|
46
|
|
|
if ($magnification > 0 && $magnification !== Fingerprint::DEFAULT_BARCODE_MAGNIFICATION) { |
47
|
|
|
yield "BM {$command->getMagnification()}"; |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
if ($command->getHeight() > 0) { |
51
|
|
|
yield \sprintf('BH %d', $command->getHeight()); |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
yield 'BF '.($command->isReadable() ? 'ON' : 'OFF'); |
55
|
|
|
|
56
|
|
|
yield \sprintf('PB "%s"', $command->getData()); |
57
|
|
|
|
58
|
|
|
// reset |
59
|
|
|
yield from $this->resetAlign($command); |
60
|
|
|
yield from $this->resetRotate($command); |
61
|
|
|
|
62
|
|
|
if ($command->getHeight() !== Fingerprint::DEFAULT_BARCODE_HEIGHT) { |
63
|
|
|
yield \sprintf('BH %d', Fingerprint::DEFAULT_BARCODE_HEIGHT); |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
if ($magnification > 0 && $magnification !== Fingerprint::DEFAULT_BARCODE_MAGNIFICATION) { |
67
|
|
|
yield \sprintf('BM %d', Fingerprint::DEFAULT_BARCODE_MAGNIFICATION); |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
if (! $command->isReadable()) { |
71
|
|
|
yield 'BF ON'; |
72
|
|
|
} |
73
|
|
|
} |
74
|
|
|
} |
75
|
|
|
|