Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 262111
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T22:29:18+00:00 2026-05-11T22:29:18+00:00

I am attempting to generate datamatrix barcodes from within itext. This works fine for

  • 0

I am attempting to generate datamatrix barcodes from within itext. This works fine for most of my codes but not for some codes. One example is:

HEnSh0701003-2V1

This produces a non square barcode for some reason. When I use encoders from other companies (such as IDAutomation) I do get a valid square barcode.

Does anyone have an idea why this is happening? I am looking for a solution so I can use the embedded iTest DataMatrix class and not have to use a third party one.

A sample of the code I am using:

BarcodeDatamatrix bar = new BarcodeDatamatrix();
 bar.setOptions(BarcodeDatamatrix.DM_AUTO);
bar.generate("HEnSh0701003-2V1");
bcd.addCell(bar.createImage());

where bcd is a PdfTable with 2 columns.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-11T22:29:18+00:00Added an answer on May 11, 2026 at 10:29 pm

    I ran into this exact issue. I ended up digging into the iText source code to figure this one out. iText is resizing the barcode to fit the text you provided.

    iText supports the following sizes for datamatrix barcodes:
    10×10, 12×12, 8×18, 14×14, 8×32, 16×16, 12×26, 18×18, 20×20, 12×36, 22×22, 16×36, 24×24, 26×26, 16×48, 32×32, 36×36, 40×40, 44×44, 48×48, 52×52, 64×64, 72×72, 80×80, 88×88, 96×96, 104×104, 120×120, 132×132, 144×144

    As you can see, there are a number of non-square sizes in there. What I did was create a list of square barcode sizes and then try each size while checking the return value of the generate() call.

    // supported square barcode dimensions
    int[] barcodeDimensions = {10, 12, 14, 16, 18, 20, 22, 24, 26, 32, 36, 40, 44, 48, 52, 64, 72, 80, 88, 96, 104, 120, 132, 144};
    
    BarcodeDatamatrix barcode = new BarcodeDatamatrix();
    barcode.setOptions(BarcodeDatamatrix.DM_AUTO);
    
    // try to generate the barcode, resizing as needed.
    for (int generateCount = 0; generateCount < barcodeDimensions.length; generateCount++) {
        barcode.setWidth(barcodeDimensions[generateCount]);
        barcode.setHeight(barcodeDimensions[generateCount]);
        int returnResult = barcode.generate(text);
        if (returnResult == BarcodeDatamatrix.DM_NO_ERROR) {
            return barcode.createImage();
        }
    }
    
    throw new Exception("Error generating barcode.");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

While attempting to generate a list of subsets that exist within two sets, I
I am attempting to generate a CSV file. Everything is fine except for blank
I'm attempting to use svcutil.exe to generate -only- the service contracts (interfaces) from a
Attempting to print out a list of values from 2 different variables that are
Attempting to deploy a MOSS solution to a UAT server from dev server for
Does attempting to develop some sort of game, even just as a hobby during
When attempting to open a project from source control on a newly formatted pc,
I'm attempting to generate artifacts for the following amazon wsdl: http://webservices.amazon.com/AWSECommerceService/AWSECommerceService.wsdl using the following
I am attempting to programmatically generate javadocs via an instance of Runtime through the
I am attempting to dynamically generate cube-maps in OpenGL using a multi-pass rendering system.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.