// یک الگو با یک جایگزین بارکد آماده کنید
// <<barcode [barcode_expression] -barcode_type>>
// مسیر فایل الگوی خود را تنظیم کنید
String template = "barcode_template.docx";
// دادهها را از یک منبع خاص بارگذاری کنید
CsvDataSource data_csv =
new CsvDataSource("Barcode Labels.csv",
new CsvDataLoadOptions(true));
// یک شی منبع داده با دادههای لازم بسازید
DataSourceInfo data
= new DataSourceInfo(data_csv, "label");
// یک نمونه از DocumentAssembler ایجاد کنید
DocumentAssembler asm = new DocumentAssembler();
// تنظیمات بارکد را سفارشی کنید
asm.getBarcodeSettings().setResolution(1200);
asm.getBarcodeSettings().setBaseYDimension(5f);
// سند بهروز شده را با بارکد ذخیره کنید
asm.assembleDocument(template, "result.docx", data);