From 7934fff316d0eac61feb8195fce0acb60e8dfbc5 Mon Sep 17 00:00:00 2001 From: Aaron Louie Date: Mon, 9 Nov 2020 17:21:22 -0500 Subject: [PATCH] Switches DMRE version to 12x64. Fixes failing unit test. --- .../barcode-data-matrix.component.spec.ts | 8 +++++++ .../barcode-data-matrix.component.ts | 24 ++++++++++--------- src/app/config/defaults.ts | 13 +++++----- 3 files changed, 28 insertions(+), 17 deletions(-) diff --git a/src/app/barcode-data-matrix/barcode-data-matrix.component.spec.ts b/src/app/barcode-data-matrix/barcode-data-matrix.component.spec.ts index 4929e0d..7d3104a 100644 --- a/src/app/barcode-data-matrix/barcode-data-matrix.component.spec.ts +++ b/src/app/barcode-data-matrix/barcode-data-matrix.component.spec.ts @@ -1,10 +1,14 @@ import { ComponentFixture, TestBed } from '@angular/core/testing'; +import {defaultOptions, labelLayouts} from '../config/defaults'; +import {AppDefaults} from '../models/appDefaults.interface'; +import {LabelLayout} from '../models/labelLayout.interface'; import { BarcodeDataMatrixComponent } from './barcode-data-matrix.component'; describe('BarcodeDataMatrixComponent', () => { let component: BarcodeDataMatrixComponent; let fixture: ComponentFixture; + const settings = new AppDefaults(defaultOptions); beforeEach(async () => { await TestBed.configureTestingModule({ @@ -16,6 +20,10 @@ describe('BarcodeDataMatrixComponent', () => { beforeEach(() => { fixture = TestBed.createComponent(BarcodeDataMatrixComponent); component = fixture.componentInstance; + settings.labelLayout = labelLayouts.rectangular_lg; + component.settings = settings; + component.format = settings.labelLayout.barcodeType; + component.value = '987654321-202101231122-ABCDE-0123'; fixture.detectChanges(); }); diff --git a/src/app/barcode-data-matrix/barcode-data-matrix.component.ts b/src/app/barcode-data-matrix/barcode-data-matrix.component.ts index 1465f31..5c13f38 100644 --- a/src/app/barcode-data-matrix/barcode-data-matrix.component.ts +++ b/src/app/barcode-data-matrix/barcode-data-matrix.component.ts @@ -20,16 +20,18 @@ export class BarcodeDataMatrixComponent implements OnInit { } renderBarcode(): void { - bwipjs.toCanvas('barcodeCanvas', { - bcid: this.format, - text: this.value, - scale: 2, - width: this.settings.labelLayout.labelWidth, - height: this.settings.labelLayout.labelHeight, - includetext: false, - textalign: 'center', - version: '8x96', - padding: this.settings.labelLayout.marginSize, - }); + if (bwipjs && bwipjs.toCanvas && this.settings && this.format) { + bwipjs.toCanvas('barcodeCanvas', { + bcid: this.format, + text: this.value, + scale: 2, + width: this.settings.labelLayout.labelWidth, + height: this.settings.labelLayout.labelHeight, + includetext: false, + textalign: 'center', + version: '12x64', + padding: this.settings.labelLayout.marginSize, + }); + } } } diff --git a/src/app/config/defaults.ts b/src/app/config/defaults.ts index 9bd0293..d9ea18d 100644 --- a/src/app/config/defaults.ts +++ b/src/app/config/defaults.ts @@ -18,12 +18,13 @@ export const labelLayouts = { }), rectangular_lg: new LabelLayout({ name: '2in x 1.25in Rectangular Label', - barcodeType: 'qrcode', + barcodeType: 'datamatrixrectangularextension', type: 'rectangular_lg', numCols: 1, columnGap: 0, - labelWidth: 38, - labelHeight: 38, + labelWidth: 47, + labelHeight: 8, + marginSize: 3, }), rectangular_sm: new LabelLayout({ name: '96mm x 15mm Rectangular Label', @@ -31,9 +32,9 @@ export const labelLayouts = { type: 'rectangular_sm', numCols: 1, columnGap: 0, - labelWidth: 96, - labelHeight: 8, - marginSize: 4, + labelWidth: 32, + labelHeight: 6, + marginSize: 3, }), };