Sign document with Royal Mail Mailmark 2D Barcode signature

View as MarkdownMarkdown

Set up your AI agent

Give your coding agent live access to the GroupDocs documentation and API reference through the GroupDocs Docs MCP server — no install, no API key. Learn more

claude mcp add --transport http groupdocs-docs https://docs.groupdocs.com/mcp

Also process documents locally

The GroupDocs.Signature MCP server lets your agent work with files on your machine; they are never uploaded. It needs the .NET 10 SDK or Docker.

claude mcp add groupdocs-signature -- dnx GroupDocs.Signature.Mcp --yes
Folders, licensing and more →

GroupDocs.Signature provides Mailmark2D class to create Royal Mail Mailmark 2D barcode. These barcodes can store various data, including information about the sender, recipient, postage, and destination. The use of Mailmark 2D barcodes allows for more accurate and detailed tracking of mail items throughout their journey in the postal system.

Here are the steps how to add Mailmark2D Barcode signature into document with GroupDocs.Signature:

  • Create new instance of Signature class and pass source document path as a constructor parameter.
  • Instantiate the  Mailmark2D object with all required additional options.
  • Instantiate the  QrCodeSignOptions object with all required additional options and set Mailmark2D object into Data property.
  • Call Sign method of Signature class instance and pass QrCodeSignOptions to it.
  • Analyze SignResult result to check newly created signatures if needed.

This example shows how to add Mailmark2D signature to document. We use enum Mailmark2DType to specify 2D barcode type, on which depends barcode form:

Types

using (Signature signature = new Signature(filePath))
{
    // create Mailmark2D data object
    Mailmark2D mailmark2D = new Mailmark2D()
    {
        UPUCountryID = "JGB ",
        InformationTypeID = "0",
        Class = "1",
        SupplyChainID = 123,
        ItemID = 1234,
        DestinationPostCodeAndDPS = "QWE1",
        RTSFlag = "0",
        ReturnToSenderPostCode = "QWE2",
        DataMatrixType = Mailmark2DType.Type_7,
        CustomerContentEncodeMode = DataMatrixEncodeMode.C40,
        CustomerContent = "CUSTOM"
    };

    // create options
    QrCodeSignOptions options = new QrCodeSignOptions
    {
        EncodeType = QrCodeTypes.QR,
        Left = 100,
        Top = 100,
        // setup Data property to Mailmark2D instance
        Data = mailmark2D
    };

    // sign document to file
    var signResult = signature.Sign(outputFilePath, options);
            
    // analyzing result
    Console.WriteLine("List of newly created signatures:");
    int number = 1;
    foreach (BaseSignature temp in signResult.Succeeded)
    {
        Console.WriteLine($"Signature #{number++}: Type: {temp.SignatureType} Id:{temp.SignatureId}, Location: {temp.Left}x{temp.Top}. Size: {temp.Width}x{temp.Height}");
    }
 }

More resources

GitHub Examples

You may easily run the code above and see the feature in action in our GitHub examples:

Free Online Apps

Along with the full-featured .NET library, we provide simple but powerful free online apps.

To generate barcodes and/or sign your files with barcodes for free, you can use the Barcode Generator online app.

To sign PDF, Word, Excel, PowerPoint, and other documents you can use the other online apps from the GroupDocs.Signature App Product Family.