VintaSoft Barcode .NET SDK 15.1: Руководство для .NET разработчика
Vintasoft.Barcode.SymbologySubsets Namespace / BarcodeSymbologySubsets Class / PPN Property
Синтаксис Ремарки Example Требования Смотрите также
В этом разделе
    PPN Свойство (BarcodeSymbologySubsets)
    В этом разделе
    Возвращает символику штрих-кода PPN (IPN-код IFA, номер продукта в аптеке).
    Синтаксис
    'Declaration
    
    Public Shared ReadOnly Property PPN As PpnBarcodeSymbology
    
    
    public static PpnBarcodeSymbology PPN { get; }
    
    
    public: __property static PpnBarcodeSymbology* get_PPN();
    
    
    
    public:
    static property PpnBarcodeSymbology^ PPN { PpnBarcodeSymbology^ get(); }
    Ремарки

    Подмножество символов штрих-кода Data Matrix.

    Пример

    Вот C#/VB.NET код, который демонстрирует, как сгенерировать и распознать штрих-код PPN.

       
       
    Imports Vintasoft.Barcode   
    Imports Vintasoft.Barcode.BarcodeInfo   
    Imports Vintasoft.Barcode.SymbologySubsets   
    Imports Vintasoft.Imaging   
       
    Class PPNExample   
        ''' <summary>
        ''' Generates and recognizes PPN barcode.
        ''' </summary>
        Public Shared Sub Test()   
            ' create PPN barcode value
            Dim barcodeValue As New PpnBarcodeValue()   
            ' PPN
            barcodeValue.PharmacyProductNumber = "110375286414"   
            ' Batch
            barcodeValue.BatchNumber = "12345ABCD"   
            ' Expiry Date (YYMMDD)
            barcodeValue.ExpiryDate = "150617"   
            ' Serial Number
            barcodeValue.SerialNumber = "12345ABCDEF98765"   
       
            ' generate barcode image
            Using barcodeImage As VintasoftBitmap = Generate(barcodeValue)   
                ' recognize barcode value
                Dim recognizedValue As PpnBarcodeValue = Recognize(barcodeImage)   
       
                ' check value
                If barcodeValue.ToString() <> recognizedValue.ToString() Then   
                    Throw New ApplicationException()   
                End If   
       
                Console.WriteLine()   
                Console.WriteLine("PPN Decoded Value:")   
                If recognizedValue.PharmacyProductNumber IsNot Nothing Then   
                    Console.WriteLine(String.Format("PPN:                 {0}", recognizedValue.PharmacyProductNumber))   
                End If   
                If recognizedValue.BatchNumber IsNot Nothing Then   
                    Console.WriteLine(String.Format("Batch:               {0}", recognizedValue.BatchNumber))   
                End If   
                If recognizedValue.ExpiryDate IsNot Nothing Then   
                    Console.WriteLine(String.Format("Expiry Date:         {0}", recognizedValue.ExpiryDate))   
                End If   
                If recognizedValue.SerialNumber IsNot Nothing Then   
                    Console.WriteLine(String.Format("Serial Number:       {0}", recognizedValue.SerialNumber))   
                End If   
                If recognizedValue.DateOfManufacture IsNot Nothing Then   
                    Console.WriteLine(String.Format("Date of Manufacture: {0}", recognizedValue.DateOfManufacture))   
                End If   
                If recognizedValue.GTIN IsNot Nothing Then   
                    Console.WriteLine(String.Format("GTIN:                {0}", recognizedValue.GTIN))   
                End If   
                Console.WriteLine(String.Format("Is German PPN:       {0}", recognizedValue.IsGermanMarketPpn))   
            End Using   
        End Sub   
       
        ''' <summary>
        ''' Generates the PPN barcode image.
        ''' </summary>
        ''' <param name="barcodeValue">The barcode value.</param>
        Private Shared Function Generate(barcodeValue As PpnBarcodeValue) As VintasoftBitmap   
            ' create barcode writer
            Using writer As New BarcodeWriter()   
                ' encode PPN barcode to writer settings
                BarcodeSymbologySubsets.PPN.Encode(barcodeValue, writer.Settings)   
       
                ' generate barcode image
                Return writer.GetBarcodeAsVintasoftBitmap()   
            End Using   
        End Function   
       
        ''' <summary>
        ''' Recognizes the PPN barcode from image.
        ''' </summary>
        ''' <param name="barcodeImage">The barcode image.</param>
        Private Shared Function Recognize(barcodeImage As VintasoftBitmap) As PpnBarcodeValue   
            ' create barcode reader
            Using reader As New BarcodeReader()   
                ' specify that PPN barcode must be recognizeds
                reader.Settings.ScanBarcodeSubsets.Add(BarcodeSymbologySubsets.PPN)   
       
                ' recognize barcodes
                Dim info As IBarcodeInfo = reader.ReadBarcodes(barcodeImage)(0)   
       
                Console.WriteLine(String.Format("Encoded PPN value        : {0}", info.Value))   
                Console.WriteLine(String.Format("Encoded Data Matrix value: {0}", DirectCast(info, BarcodeSubsetInfo).BaseBarcodeInfo.Value))   
       
                ' return PPN value
                Return DirectCast(info, PpnBarcodeInfo).PpnValue   
            End Using   
        End Function   
    End Class
    
    
    
    using System;
    
    using Vintasoft.Barcode;
    using Vintasoft.Barcode.BarcodeInfo;
    using Vintasoft.Barcode.SymbologySubsets;
    using Vintasoft.Imaging;
    
    class PPNExample
    {
        /// <summary>
        /// Generates and recognizes PPN barcode.
        /// </summary>
        public static void Test()
        {
            // create PPN barcode value
            PpnBarcodeValue barcodeValue = new PpnBarcodeValue();
            // PPN
            barcodeValue.PharmacyProductNumber = "110375286414";
            // Batch
            barcodeValue.BatchNumber = "12345ABCD";
            // Expiry Date (YYMMDD)
            barcodeValue.ExpiryDate = "150617";
            // Serial Number
            barcodeValue.SerialNumber = "12345ABCDEF98765";
    
            // generate barcode image
            using (VintasoftBitmap barcodeImage = Generate(barcodeValue))
            {
                // recognize barcode value
                PpnBarcodeValue recognizedValue = Recognize(barcodeImage);
    
                // check value
                if (barcodeValue.ToString() != recognizedValue.ToString())
                    throw new ApplicationException();
    
                Console.WriteLine();
                Console.WriteLine("PPN Decoded Value:");
                if (recognizedValue.PharmacyProductNumber != null)
                    Console.WriteLine(string.Format("PPN:                 {0}", recognizedValue.PharmacyProductNumber));
                if (recognizedValue.BatchNumber != null)
                    Console.WriteLine(string.Format("Batch:               {0}", recognizedValue.BatchNumber));
                if (recognizedValue.ExpiryDate != null)
                    Console.WriteLine(string.Format("Expiry Date:         {0}", recognizedValue.ExpiryDate));
                if (recognizedValue.SerialNumber != null)
                    Console.WriteLine(string.Format("Serial Number:       {0}", recognizedValue.SerialNumber));
                if (recognizedValue.DateOfManufacture != null)
                    Console.WriteLine(string.Format("Date of Manufacture: {0}", recognizedValue.DateOfManufacture));
                if (recognizedValue.GTIN != null)
                    Console.WriteLine(string.Format("GTIN:                {0}", recognizedValue.GTIN));
                Console.WriteLine(string.Format("Is German PPN:       {0}", recognizedValue.IsGermanMarketPpn));
            }
        }
    
        /// <summary>
        /// Generates the PPN barcode image.
        /// </summary>
        /// <param name="barcodeValue">The barcode value.</param>
        private static VintasoftBitmap Generate(PpnBarcodeValue barcodeValue)
        {
            // create barcode writer
            using (BarcodeWriter writer = new BarcodeWriter())
            {
                // encode PPN barcode to writer settings
                BarcodeSymbologySubsets.PPN.Encode(barcodeValue, writer.Settings);
    
                // generate barcode image
                return writer.GetBarcodeAsVintasoftBitmap();
            }
        }
    
        /// <summary>
        /// Recognizes the PPN barcode from image.
        /// </summary>
        /// <param name="barcodeImage">The barcode image.</param>
        private static PpnBarcodeValue Recognize(VintasoftBitmap barcodeImage)
        {
            // create barcode reader
            using (BarcodeReader reader = new BarcodeReader())
            {
                // specify that PPN barcode must be recognizeds
                reader.Settings.ScanBarcodeSubsets.Add(BarcodeSymbologySubsets.PPN);
    
                // recognize barcodes
                IBarcodeInfo info = reader.ReadBarcodes(barcodeImage)[0];
    
                Console.WriteLine(string.Format("Encoded PPN value        : {0}",
                    info.Value));
                Console.WriteLine(string.Format("Encoded Data Matrix value: {0}",
                    ((BarcodeSubsetInfo)info).BaseBarcodeInfo.Value));
    
                // return PPN value
                return ((PpnBarcodeInfo)info).PpnValue;
            }
        }    
    }
    
    

    Требования

    Целевые платформы: .NET 8; .NET 7; .NET 6; .NET Framework 4.8, 4.7, 4.6, 4.5, 4.0, 3.5

    Смотрите также