Пример #1
0
        public virtual void Barcode04Test()
        {
            String code             = "0987654321";
            int    expectedChecksum = 7;
            int    checksum         = BarcodeMSI.GetChecksum(code);

            NUnit.Framework.Assert.AreEqual(checksum, expectedChecksum);
        }
Пример #2
0
        public virtual void Barcode03Test()
        {
            byte[] expected = new byte[] { 1, 1, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 0, 0, 1, 1, 0, 1,
                                           0, 0, 1, 0, 0, 1, 0, 0, 1, 1, 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1 };
            byte[] barcodeBytes = BarcodeMSI.GetBarsMSI("1234");
            bool   isEqual      = JavaUtil.ArraysEquals(expected, barcodeBytes);

            NUnit.Framework.Assert.IsTrue(isEqual);
        }
Пример #3
0
        public virtual void Barcode02Test()
        {
            String      filename = "barcodeMSI_02.pdf";
            PdfWriter   writer   = new PdfWriter(destinationFolder + filename);
            PdfReader   reader   = new PdfReader(sourceFolder + "DocumentWithTrueTypeFont1.pdf");
            PdfDocument document = new PdfDocument(reader, writer);
            PdfCanvas   canvas   = new PdfCanvas(document.GetLastPage());
            Barcode1D   barcode  = new BarcodeMSI(document);

            barcode.SetCode("9781935182610");
            barcode.SetTextAlignment(Barcode1D.ALIGN_LEFT);
            barcode.PlaceBarcode(canvas, ColorConstants.BLACK, ColorConstants.WHITE);
            document.Close();
            NUnit.Framework.Assert.IsNull(new CompareTool().CompareByContent(destinationFolder + filename, sourceFolder
                                                                             + "cmp_" + filename, destinationFolder, "diff02_"));
        }
Пример #4
0
        public virtual void BarcodeMSIGetBarcodeSizeWithoutChecksumTest()
        {
            PdfWriter   writer   = new PdfWriter(new ByteArrayOutputStream());
            PdfDocument document = new PdfDocument(writer);

            document.AddNewPage();
            Barcode1D barcode = new BarcodeMSI(document);

            document.Close();
            barcode.SetCode("123456789");
            barcode.SetGenerateChecksum(false);
            Rectangle barcodeSize = barcode.GetBarcodeSize();

            NUnit.Framework.Assert.AreEqual(33.656, barcodeSize.GetHeight(), EPS);
            NUnit.Framework.Assert.AreEqual(92.0, barcodeSize.GetWidth(), EPS);
        }
Пример #5
0
        public virtual void Barcode01Test()
        {
            String      filename = "barcodeMSI_01.pdf";
            PdfWriter   writer   = new PdfWriter(destinationFolder + filename);
            PdfDocument document = new PdfDocument(writer);
            PdfPage     page     = document.AddNewPage();
            PdfCanvas   canvas   = new PdfCanvas(page);
            Barcode1D   barcode  = new BarcodeMSI(document);

            barcode.SetCode("123456789");
            barcode.SetGenerateChecksum(true);
            barcode.SetTextAlignment(Barcode1D.ALIGN_LEFT);
            barcode.PlaceBarcode(canvas, ColorConstants.BLACK, ColorConstants.WHITE);
            document.Close();
            NUnit.Framework.Assert.IsNull(new CompareTool().CompareByContent(destinationFolder + filename, sourceFolder
                                                                             + "cmp_" + filename, destinationFolder, "diff01_"));
        }