|  Download Codes"FeaturesInstallationThe preferred way to install this extension is through composer. Either run $ composer require d3yii2/d3codes "*"
 or add "d3yii2/d3codes": "*"
 to the requiresection of yourcomposer.jsonfile. Configurationrecorder and Readers 'components' => [
        'palletCodeRecorder' => [
            'class' => 'd3yii2\d3codes\components\CodeRecorder',
            'codeName' => 'pallets bar code',
            'series' => [
                'p01' => [
                    'prefix' => 'p01',
                    'length' => 5,
                    'from' => 1,
                    'to' => 20000
                ]
            ],
            'modelClass' => 'wood\clasifiers\models\Pallet',
            'componentsSysModel' => 'sysModel'
        ],
        'codeReader' => [
            'class' => 'd3yii2\d3codes\components\CodeReader',
            'modelClassList' => [
                'wood\clasifiers\models\Pallet'
            ],
            'componentsSysModel' => 'sysModel'
        ],
    ]
        
 PrinterFor printing direct from the server.
Use Chrome for converting to PDF and for sending to printer use   PDFtoPrinter http://www.columbia.edu/~em36/pdftoprinter.html To composer add repository https://github.com/uldisn/php-exec.git      "repositories": [
        {
            "type": "vcs",
            "url": "https://github.com/uldisn/php-exec.git"
        },
 # Bar code printer
BOUNCER_PRINTER=BouncerPrinter
PDFtoPrinter=H:\yii2\cewood\PDFtoPrinter.exe
# chrome
CHROME_PATH=C:\Program Files (x86)\Google\Chrome\Application\chrome.exe
  'components' => [
        'bouncerPrinter' => [
            'class' => '\d3yii2\d3codes\components\PrintWindowsPrinter',
            'printerName' => getenv('BOUNCER_PRINTER'),
            'chromeExe' => getenv('CHROME_PATH'),
            'PDFtoPrinter' => getenv('PDFtoPrinter'),
        ],
    ]
        
 Usagecreating new barcode
    $barCode = \Yii::$app->palletCodeRecorder->createNewRecord($palletModel->id);
    $palletModel = \Yii::$app->palletCodeRecorder->codeReader($barcodeReadedByBarCodeScaner);       
 adding code to modelclass BtlinePp extends BaseBtlinePp
{
    public function rules()
    {
        return array_merge(parent::rules(),[
            ['code','safe']
        ]);
    }
    public function attributeLabels()
    {
        return array_merge(parent::attributeLabels(),[
            'code' => 'Code'
        ]);
    }
    /
     * @return string
     * @throws D3ActiveRecordException
     */
    public function getCode(): string
    {
        return Yii::$app->ppCodeRecorder->getCodeOrCreate($this->id);
    }
}
 Print barcode by printeruse d3yii2\d3codes\actions\PrintCode;
class BatchController
{
    public function actions() {
        $OC = $this;
        return [
            'pp-print-barcode' => [
                'class' => PrintCode::class,
                'componentRecorderName' => 'ppCodeRecorder',
                'layout' => '@layout_barcode',
                'view' => 'print_barcode',
                'data' => static function(int $id) use ($OC){
                    return [
                        'model' => $OC->findModel($id),
                    ];
                }
            ],
        ];
    }
}
 reading in Controller and FormFor form use model d3yii2\d3codes\models\CodeReader. Controller use d3yii2\d3codes\models\CodeReader;
        $codeReaderModel = new CodeReader();
        $codeReaderModel->componentCodeReaderName = 'codeReader';
        $post = Yii::$app->request->post();
        if($post && $codeReaderModel->load(Yii::$app->request->post())){
                    / @var CwpalletPallet $palletModel */
                    $palletModel = $codeReaderModel->model;
        }
        if ($codeReaderModel->hasErrors()) {
            FlashHelper::modelErrorSummary($codeReaderModel);
        }        
        return $this->render('manufacturing', [
            'packList' =>  $searchModel
                ->manufacturedPacks(true)
                ->all(),
            'packId' => $packId,
            'codeReaderModel' => $codeReaderModel
        ]);        
 form                 $form = ActiveForm::begin([
                    'id' => 'BauncerCodeReading',
                    'enableClientValidation' => false,
                    'errorSummaryCssClass' => 'error-summary alert alert-error',
                    'fieldConfig' => [
                        'template' => "{label}\n{beginWrapper}\n{input}\n{error}\n{endWrapper}",
                    ],
                ]);
                echo $form
                    ->field(
                        $codeReaderModel,
                        'code',
                        [
                            'inputOptions' => [
                                'autofocus' => 'autofocus',
                                'class' => 'form-control',
                                'tabindex' => '1'
                            ]
                        ])
                    ->textInput()
                    ->label('');
                echo ThButton::widget([
                    'label' => 'Process',
                    'id' => 'saveCode',
                    'icon' => ThButton::ICON_CHECK,
                    'type' => ThButton::TYPE_SUCCESS,
                    'submit' => true,
                    'htmlOptions' => [
                        'name' => 'action',
                        'value' => 'save',
                    ],
                ]);
                ActiveForm::end();
 Print from server        try {
            
            $url = Yii::$app->urlManager->createAbsoluteUrl([
                '/cwstore/pack/print-barcode',
                'id' => $id
            ]);
            if(Yii::$app->bouncerPrinter->print($url)){
                FlashHelper::addSuccess('Eti?ete nos?t?ta uz izsit?ja printera');
            }else{
                FlashHelper::addDanger('Rad?s k??da druk?jot eti?eti');
            }
        } catch (Exception $e) {
            FlashHelper::processException($e);
        }
 |