VintaSoft Barcode .NET SDK v10.0
Vintasoft.WpfBarcode.SymbologySubsets Namespace / BarcodeSymbologySubsets Class / PPN Property
Example




In This Topic
    PPN Property (BarcodeSymbologySubsets)
    In This Topic
    Gets the PPN (IFA PPN-Code, Pharmacy Product Number) barcode symbology.
    Syntax
    'Declaration
     
    Public Shared ReadOnly Property PPN As PpnBarcodeSymbology
    'Usage
     
    Dim value As PpnBarcodeSymbology
     
    value = BarcodeSymbologySubsets.PPN
    public static PpnBarcodeSymbology PPN {get;}
    public: __property static PpnBarcodeSymbology* get_PPN();
    public:
    static property PpnBarcodeSymbology^ PPN {
       PpnBarcodeSymbology^ get();
    }
    Remarks
    Subset of Data Matrix barcode symbology.
    Example
    This example shows how to generate and recognize PPN barcode.
    Imports System.Windows.Media.Imaging   
       
    Imports Vintasoft.WpfBarcode   
    Imports Vintasoft.WpfBarcode.BarcodeInfo   
    Imports Vintasoft.WpfBarcode.SymbologySubsets   
       
    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   
    		Dim barcodeImage As BitmapSource = 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 Sub   
       
    	''' <summary>   
    	''' Generates the PPN barcode image.   
    	''' </summary>   
    	''' <param name="barcodeValue">The barcode value.</param>   
    	Private Shared Function Generate(barcodeValue As PpnBarcodeValue) As BitmapSource   
    		' create barcode writer   
    		Dim writer As New BarcodeWriter()   
       
    		' encode PPN barcode to writer settings   
    		BarcodeSymbologySubsets.PPN.Encode(barcodeValue, writer.Settings)   
       
    		' generate barcode image   
    		Return writer.GetBarcodeAsBitmapSource()   
    	End Function   
       
    	''' <summary>   
    	''' Recognizes the PPN barcode from image.   
    	''' </summary>   
    	''' <param name="barcodeImage">The barcode image.</param>   
    	Private Shared Function Recognize(barcodeImage As BitmapSource) 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 System.Windows.Media.Imaging;
                
    using Vintasoft.WpfBarcode;
    using Vintasoft.WpfBarcode.BarcodeInfo;
    using Vintasoft.WpfBarcode.SymbologySubsets;
                
    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
            BitmapSource 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 BitmapSource Generate(PpnBarcodeValue barcodeValue)
        {
            // create barcode writer
            BarcodeWriter writer = new BarcodeWriter();
                
            // encode PPN barcode to writer settings
            BarcodeSymbologySubsets.PPN.Encode(barcodeValue, writer.Settings);
            
            // generate barcode image
            return writer.GetBarcodeAsBitmapSource();
        }
                
        /// <summary>
        /// Recognizes the PPN barcode from image.
        /// </summary>
        /// <param name="barcodeImage">The barcode image.</param>
        private static PpnBarcodeValue Recognize(BitmapSource 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;
            }
        }    
    }
    Requirements

    Target Platforms: Windows 8, Windows 7, Windows Vista, Windows XP, Windows Server 2012, Windows Server 2008, Windows Server 2003

    See Also