GroupDocs.Assembly for Java

Generate barcodes for PDF files with our Java API

GroupDocs.Assembly for Java provides comprehensive tools to dynamically create, customize, and embed barcodes into PDF files.

How to embed a barcode in a PDF document

GroupDocs.Assembly lets you insert barcodes into popular formats like PDF templates. Supports over 60 types, including 1D and 2D barcodes.

  1. Prepare a template with placeholders for barcodes (PDF templates are not supported).
  2. Fetch data from a supported source.
  3. Adjust barcode settings such as size and resolution.
  4. Save the document with the added barcode as a PDF file.
// Use this tag in your template to create a barcode in the output document
// <<barcode [barcode_expression] -barcode_type>>

// Set the file path for the template
// PDF templates are currently not supported.
String template = "barcode_template.docx";

// Fetch data from your source
DataSourceInfo data 
    = new DataSourceInfo(GetData(), "label");

// Save the document with the added barcode as a PDF file.
DocumentAssembler asm = new DocumentAssembler();
asm.assembleDocument(template, "result.pdf", data);
Maven XML
click to copy
copied
More examples Documentation

Build documents using data-powered templates

GroupDocs.Assembly for Java simplifies document creation across popular file types. Use templates to add charts, tables, lists, links, images, and barcodes seamlessly.

Features of GroupDocs.Assembly

Generate reports using business data

The API populates documents with data from formats like JSON, XML, and CSV efficiently and accurately.

Visualize data with built-in elements

GroupDocs.Assembly supports native elements like tables, charts, and lists, along with text, links, images, and real-time barcode generation.

Insert data where you need it

With LINQ-based templates, you can place data precisely, use loops to add arrays, and customize formatting such as color programmatically.

Wide compatibility with file types

Handle files like MS Office documents, PDFs, HTML, OpenOffice, and emails. You can also merge one document into another.

How to create a barcode dynamically

This example shows how to dynamically generate and add a barcode to a PDF document.

Java

// Prepare a template with a barcode placeholder
// <<barcode [barcode_expression] -barcode_type>>

// Set the path to your template file
// PDF templates are currently not supported.
String template = "barcode_template.docx";

// Load data from a specific source
CsvDataSource data_csv =
    new CsvDataSource("Barcode Labels.csv", 
    new CsvDataLoadOptions(true));

// Build a data source object with the necessary data
DataSourceInfo data 
    = new DataSourceInfo(data_csv, "label");

// Create an instance of DocumentAssembler
DocumentAssembler asm = new DocumentAssembler();

// Customize barcode settings
asm.getBarcodeSettings().setResolution(1200);
asm.getBarcodeSettings().setBaseYDimension(5f);

// Save the updated document with the barcode
asm.assembleDocument(template, "result.pdf", data);
Maven XML
click to copy
copied
More examples Documentation

What is GroupDocs.Assembly for Java?

GroupDocs.Assembly for Java helps you generate and customize documents by adding data from multiple sources. Easily insert text, numbers, charts, tables, lists, images, and barcodes. Use advanced templates to ensure the data appears exactly where you want it. Supports over 50 formats, including PDF, Office files, and emails.
Learn more
About illustration

Ready to get started?

Download GroupDocs.Assembly for free or get a trial license for full access!

Useful resources

Explore documentation, code samples, and community support to enhance your experience.

Discover key features

Our platform simplifies handling business documents with powerful tools and automation.

Create reports in various formats

Java supports over 50 file types, enabling effortless data merging and template processing for professional results.

Temporary license tips

1
Sign up with your work email.
Free mail services are not allowed.
2
Use Get a temporary license button on the second step.
 English