SupportedBarcodes.vb
- ''
- '' This code is part of Document Solutions for PDF demos.
- '' Copyright (c) MESCIUS inc. All rights reserved.
- ''
- Imports System.IO
- Imports System.Drawing
- Imports System.Collections.Generic
- Imports GrapeCity.Documents.Drawing
- Imports GrapeCity.Documents.Pdf
- Imports GrapeCity.Documents.Text
- Imports GrapeCity.Documents.Barcode
-
- '' Renders samples of all barcode symbologies supported by the DsBarcode library.
- Public Class SupportedBarcodes
- Function CreatePDF(ByVal stream As Stream) As Integer
- Dim doc = New GcPdfDocument()
- Dim page As Page = Nothing
- Dim g As GcGraphics = Nothing
- Const margin = 72.0F / 2
- Const pad = 4.0F
- Const gap = 10.0F
- Dim ip = New PointF(margin, margin)
-
- Dim newPage As Action =
- Sub()
- page = doc.NewPage()
- g = page.Graphics
- ip = New PointF(margin, margin)
- End Sub
-
- newPage()
-
- Dim tfCaption = New TextFormat() With {
- .Font = StandardFonts.Times,
- .FontSize = 12
- }
- Dim tfBarcode = New TextFormat() With {
- .Font = StandardFonts.Helvetica,
- .FontSize = 9
- }
- Dim barcode = New GcBarcode() With {
- .TextFormat = tfBarcode,
- .ScaleFactor = 1.5F
- }
- barcode.Options.CaptionPosition = BarCodeCaptionPosition.Below
- barcode.Options.SizeOptions.NarrowWideRatio = 0
-
- Dim drawBarcode As Action(Of CodeType, String, String) =
- Sub(ct_, txt_, txt2_)
- Dim caption = $"{ct_}:{vbCrLf}{txt_}"
- If String.IsNullOrEmpty(txt2_) Then
- barcode.Options.GS1Composite.Type = GS1CompositeType.None
- Else
- caption += $"{vbCrLf}Dependent CCA: {txt2_}"
- barcode.Options.GS1Composite.Type = GS1CompositeType.CCA
- barcode.Options.GS1Composite.Value = txt2_
- End If
-
- barcode.Options.CheckSumEnabled = ct_ <> CodeType.Code25intlv AndAlso ct_ <> CodeType.Code_2_of_5 AndAlso ct_ <> CodeType.Matrix_2_of_5
- Dim csize = g.MeasureString(caption, tfCaption)
- barcode.CodeType = ct_
- barcode.Text = txt_
- Dim size = g.MeasureBarcode(barcode)
- size.Height = Math.Max(size.Height, csize.Height)
- Dim border = New RectangleF(ip, New SizeF(page.Size.Width - margin * 2, size.Height + pad * 2))
- If ip.Y + border.Height > page.Size.Height - margin Then
- newPage()
- border = New RectangleF(ip, border.Size)
- End If
- g.DrawRectangle(border, Color.Gray)
- g.DrawString(caption, tfCaption, New PointF(border.Left + pad, border.Top + pad))
- g.DrawBarcode(barcode, New RectangleF(border.Right - size.Width - pad, border.Top + pad, size.Width, size.Height))
- ip.Y = border.Bottom + gap
- End Sub
- ''
- drawBarcode(CodeType.Ansi39, "*DSBARCODE*", Nothing)
- drawBarcode(CodeType.Ansi39x, "*DsPdf*", Nothing)
- drawBarcode(CodeType.Codabar, "A12041961D", Nothing)
- drawBarcode(CodeType.Code25intlv, "1234567890", Nothing) '' Interleaved 2 of 5 (ITF)
- drawBarcode(CodeType.Code39, "*GCBARCODE*", Nothing)
- drawBarcode(CodeType.Code39x, "*DsPdf*", Nothing)
- drawBarcode(CodeType.Code49, "DsBarcode+DsPdf", Nothing)
- drawBarcode(CodeType.Code93x, "DsBarcode+DsPdf", Nothing)
- drawBarcode(CodeType.Code_93, "GCBARCODE", Nothing)
- drawBarcode(CodeType.Code_128_A, "DSPDF-2023", Nothing)
- drawBarcode(CodeType.Code_128_B, "DSPdf-2023", Nothing)
- drawBarcode(CodeType.Code_128_C, "1234567890", Nothing)
- drawBarcode(CodeType.Code_128auto, "DsPdf-2023", Nothing)
- drawBarcode(CodeType.Code_2_of_5, "1234567890", Nothing)
- drawBarcode(CodeType.DataMatrix, "DsBarcode+DsPdf", Nothing)
- drawBarcode(CodeType.QRCode, "DsBarcode+DsPdf", Nothing)
- drawBarcode(CodeType.EAN_8, "1234567", Nothing)
- drawBarcode(CodeType.EAN_13, "469" + "87654" + "3210", Nothing)
- drawBarcode(CodeType.EAN128FNC1, $"GcBarcode{vbLf}DsPdf", Nothing)
- drawBarcode(CodeType.IntelligentMail, "00300999999000000001", Nothing)
- drawBarcode(CodeType.JapanesePostal, "TOKYO-10CC-09-1978", Nothing)
- drawBarcode(CodeType.PostNet, "152063949", Nothing)
- drawBarcode(CodeType.RM4SCC, "SE17PB9Z", Nothing)
- drawBarcode(CodeType.Matrix_2_of_5, "1234567890", Nothing)
- drawBarcode(CodeType.MSI, "1234567890", Nothing)
- drawBarcode(CodeType.MicroPDF417, "DsPdf", Nothing)
- drawBarcode(CodeType.Pdf417, "DsPdf", Nothing)
- drawBarcode(CodeType.RSS14, "1234567890", Nothing)
- drawBarcode(CodeType.RSS14Stacked, "1234567890", Nothing)
- drawBarcode(CodeType.RSS14Stacked, "1234567890", "12345")
- drawBarcode(CodeType.RSS14StackedOmnidirectional, "1234567890", Nothing)
- drawBarcode(CodeType.RSS14Truncated, "1234567890", Nothing)
- drawBarcode(CodeType.RSSExpanded, "12345678901234", Nothing)
- drawBarcode(CodeType.RSSExpandedStacked, "12345678901234", Nothing)
- drawBarcode(CodeType.RSSLimited, "1234567890", Nothing)
- drawBarcode(CodeType.RSSLimited, "1234567890", "12345")
- drawBarcode(CodeType.UCCEAN128, "DsBarcode+DsPdf", Nothing)
- drawBarcode(CodeType.UPC_A, "123456789012", Nothing)
- drawBarcode(CodeType.UPC_E0, "123456789012", Nothing)
- drawBarcode(CodeType.UPC_E1, "123456789012", Nothing)
- ''
- '' Done:
- doc.Save(stream)
- Return doc.Pages.Count
- End Function
- End Class
-