1

By default, Sharepoint uses the Code39 barcode standard. Is there any way through the COM or otherwise to change the standard used by sharepoint? I would like to have Code 128B barcodes instead, and can find no documentation online regarding different barcode standards. I'm using SharePoint 2016

Thanks

0

Here is a Custom Barcode Provider from Planzer for your reference.

using System;
using System.Collections.Generic;
using Microsoft.Office.RecordsManagement.PolicyFeatures;
using System.Text;
using System.Drawing;

namespace PLA.SP.Core.Barcode {

  /// <summary>
  /// This Class contains the Custom Barcode Provider for Code 128B Codes <br/>  /// </summary>
  public class PlanzerBarcodeGenerator : IBarcodeGenerator {

    private int _barWeight = 2;
    /// <summary>
    /// Get or Set the Weight of the Barcode Bar
    /// </summary>
    public int BarWeight {
      get { return _barWeight; }
      set { _barWeight = value; }
    }

    /// <summary>
    /// Draws a Code 128B Barcode 
    /// </summary>
    /// <param name="id"></param>
    /// <returns></returns>
    private System.Drawing.Image DrawBarcodeImage(string id) {
      return Code128.MakeBarcodeImage(id, BarWeight, true);
    }

    /// <summary>
    /// Gets the document id to create barcode
    /// </summary>
    /// <param name="spListItem"></param>
    /// <returns>The document Id of current splistitem</returns>
    private string GetDocumentID(Microsoft.SharePoint.SPListItem spListItem) {
      if (spListItem.Properties.ContainsKey("_dlc_DocId"))
        return spListItem.Properties["_dlc_DocId"].ToString();
      else
        return "_dlc_DocID_NotFound!";
    }

    #region IBarcodeGenerator

    System.Drawing.Image IBarcodeGenerator.GetBarcodeImage(Microsoft.SharePoint.SPListItem spListItem, ref string strValue) {
      return DrawBarcodeImage(strValue);
    }

    void IBarcodeGenerator.GetBarcodeValueAndImage(Microsoft.SharePoint.SPListItem spListItem, out string strValue, out System.Drawing.Image imBarcode) {
      strValue = GetDocumentID(spListItem);
      imBarcode = DrawBarcodeImage(strValue);
    }

    System.Drawing.Image IBarcodeGenerator.GetSampleBarcodeImage(Microsoft.SharePoint.SPSite spSite) {
      return DrawBarcodeImage("TEST-12-3");
    }

    #endregion
  }
}

For Activating / Deactivating in a Feature

/// <summary>
/// Provides the Provider Manifest to activate it
/// </summary>
const string sBarcodeProviderManifest = "<PolicyResource id=\"PLA.SP.Core.Barcode.PlanzerBarcodeGenerator\" " +
  "featureId=\"Microsoft.Office.RecordsManagement.PolicyFeatures.Barcode\" " +
  "type=\"Microsoft.Office.RecordsManagement.PolicyFeatures.Barcode.Generator\" " +
  //"visible=\"true\" " + 
  " xmlns=\"urn:schemas-microsoft-com:office:server:policy\" >" +
  "<Name>Planzer Code 128B Provider</Name> " +
  "<Description>This is the Planzer 128B Barcode Provider. Default to all Planzer Group Systems</Description> " +
  "<Publisher>planzer group</Publisher> " +
  "<AssemblyName>PLA.SP.Core.RegisterBarcodeProvider, Version=1.0.0.0, Culture=neutral, PublicKeyToken=aa3f56284809e565</AssemblyName> " +
  "<ClassName>PLA.SP.Core.Barcode.PlanzerBarcodeGenerator</ClassName>" +
  "</PolicyResource>";


/// <summary>
/// Activates the Barcode 128B for the Planzer Internet Site
/// </summary>
/// <param name="properties"></param>
public override void FeatureActivated(SPFeatureReceiverProperties properties)
{
  PolicyResourceCollection.Add(sBarcodeProviderManifest);
}


/// <summary>
/// Deactivates the Barcode 128B feature
/// </summary>
/// <param name="properties"></param>
public override void FeatureDeactivating(SPFeatureReceiverProperties properties)
{
  PolicyResourceCollection.Delete("PLA.SP.Core.Barcode.PlanzerBarcodeGenerator");
}

Reference: Custom Barcode Provider

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.