VintaSoft Barcode .NET SDK v10.0
PpnBarcodeSymbology Class
Members  Example 




Vintasoft.Barcode.SymbologySubsets Namespace : PpnBarcodeSymbology Class
Defines the PPN (IFA PPN-Code, Pharmacy Product Number) barcode symbology - subset of DataMatrix barcode symbology.
Object Model
PpnBarcodeSymbology ClassBarcodeSymbologySubset Class
Syntax
'Declaration
 
Public Class PpnBarcodeSymbology 
   Inherits BarcodeSymbologySubset
'Usage
 
Dim instance As PpnBarcodeSymbology
public class PpnBarcodeSymbology : BarcodeSymbologySubset 
public __gc class PpnBarcodeSymbology : public BarcodeSymbologySubset 
public ref class PpnBarcodeSymbology : public BarcodeSymbologySubset 
Remarks
Pharmacy Product Number (PPN) is a globally unique article number for products in the area of health care in which the national article number is embedded. Depending on the type of product, the PPN-Code is made up of different elements either the PPN alone or in combination with additional data elements: Batch Number, Serial Number, Expiry Date, Date of Manufacture, and GTIN. The specification of this application is maintained at Informationsstelle für Arzneispezialitaeten GmbH (IFA).
Example
This example shows how to generate and recognize PPN barcode.
Imports System.Drawing   
   
Imports Vintasoft.Barcode   
Imports Vintasoft.Barcode.BarcodeInfo   
Imports Vintasoft.Barcode.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   
		Using barcodeImage As Image = 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 Image   
		' 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.GetBarcodeAsBitmap()   
	End Function   
   
	''' <summary>   
	''' Recognizes the PPN barcode from image.   
	''' </summary>   
	''' <param name="barcodeImage">The barcode image.</param>   
	Private Shared Function Recognize(barcodeImage As Image) 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.Drawing;
            
using Vintasoft.Barcode;
using Vintasoft.Barcode.BarcodeInfo;
using Vintasoft.Barcode.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
        using (Image 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 Image 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.GetBarcodeAsBitmap();
    }
            
    /// <summary>
    /// Recognizes the PPN barcode from image.
    /// </summary>
    /// <param name="barcodeImage">The barcode image.</param>
    private static PpnBarcodeValue Recognize(Image 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;
        }
    }    
}
Inheritance Hierarchy

System.Object
   Vintasoft.Barcode.SymbologySubsets.BarcodeSymbologySubset
      Vintasoft.Barcode.SymbologySubsets.PpnBarcodeSymbology

Requirements

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

See Also

Reference

PpnBarcodeSymbology Members
Vintasoft.Barcode.SymbologySubsets Namespace
PpnBarcodeValue Class
PpnBarcodeInfo Class