Free Support Forum -

Re: Barcode xDimension fails

Sorry I left that out - it was 128. Here is the event handler code:

private static void HandleMergeImage(Object sender, MergeImageFieldEventArgs e)
// Find out if a barcode is needed for row and find out the row
int recordNum = e.get_RecordIndex();
// Get the requested barcode, skipping the first, label, row
String bcRequested = cells.get_Item(recordNum+1, 2).get_StringValue();
// Set blank image if there is no requested barcode
if (bcRequested.charAt(0) == ' ')

BarCodeBuilder bb = new BarCodeBuilder();

// Set the Code text for the barcode
// Drop the text from the code image
// Set size to .75 - .8 inch
bb.set_BarHeight(20.0f); //20 mm. printed
// Remove border
// Set small bar/space width to 16 mils
bb.set_xDimension(0.406f); // .406 mm. printed

// Set the symbology type to Code128

// Pass the image to the document merge

Hmm, I think it could be something about the resolution setting differences.

Could you please set the resolution of BarCodeBuilder to higher? By default the resolution is 96dpi * 96 dpi.

Like:DpiX = 600; DpiY = 600;

//Create doc with Aspose.Word
Document doc = new Document();
//Create builder for doc
DocumentBuilder builder = new DocumentBuilder(doc);
//Insert the BarCode image into doc
Aspose.BarCode.BarCodeBuilder bb = new Aspose.BarCode.BarCodeBuilder();
bb.Resolution.DpiX = 600; //set the DpiX to 600
bb.Resolution.DpiY = 600; //set the DpiY to 600
bb.SymbologyType = Aspose.BarCode.Symbology.Code128;
bb.xDimension = 0.406f;
bb.CodeText = "71040343386001192576";

Please check the attached doc, which is created with the DpiX 600/DpiY600, xDimension 0.406f

Thank you for the quick response. I am happy to report that your solution seems to have fixed the problem. There may still be something for your team to work on, of course, as even 96 dpi should resolve to a couple hundreths; but, I don’t need that fixed. :slight_smile: