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)
{
if(e.get_FieldName().equals("barcode_data"))
{
// 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) == ' ')
{
e.set_ImageFileName(blankImageName);
return;
}

BarCodeBuilder bb = new BarCodeBuilder();

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

// Set the symbology type to Code128
bb.set_SymbologyType(Symbology.Code128);

// Pass the image to the document merge
e.set_Image(bb.get_BarCodeImage());
}//if(e.get_FieldName().equals("barcode_data"))
}

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";
builder.InsertImage(bb.BarCodeImage);

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: