GroupDocs.Assembly for Java

Add charts to PDF documents with Java API

GroupDocs.Assembly for Java simplifies the process of embedding charts into PDF documents by utilizing real-time data.

Steps to embed a chart into a PDF document

GroupDocs.Assembly simplifies the process of inserting charts into PDF templates. Choose from a variety of chart styles, including bar, pie, and line charts.

  1. Create a template with placeholders for the chart (PDF templates are not supported).
  2. Load your data from a compatible source.
  3. Set the chart options, such as type, labels, and colors.
  4. Save the document containing the chart as a PDF file.
// Add this tag to your template to include a chart
// Orders Prices by months<<y [Sum(c => c.Price)]>><<size [Count()]>>

// Provide the file path to your template
// PDF templates are not supported at this time.
String template = "chart_template.docx";

// Extract the necessary data from your source
DataSourceInfo data 
    = new DataSourceInfo(GetChartData(), "orders");

// Save the final document with the embedded chart
DocumentAssembler asm = new DocumentAssembler();
asm.assembleDocument(template, "result.pdf", data);
Maven XML
click to copy
copied
More examples Documentation

Effortlessly embed dynamic charts in your documents

GroupDocs.Assembly for Java provides an easy way to build data-rich documents in popular formats. Use templates to insert charts, tables, barcodes, lists, links, and images with dynamic updates from your data.

Key features of GroupDocs.Assembly

Easily turn data into charts

Use the API to transform data from JSON, XML, CSV, or other sources into clean, professional charts for your documents.

Create visually impactful content

GroupDocs.Assembly supports various visual formats, including bar graphs, pie charts, and line graphs, which can be combined with tables, barcodes, images, and more for enhanced reports.

Customizable chart placement and styling

With LINQ-based syntax, you can dynamically generate and position charts in the document, while easily adjusting styles, colors, and layouts to meet your design needs.

Supports multiple document formats

Generate documents in formats like MS Office, PDF, OpenOffice, and HTML. The charts integrate smoothly into any supported format for professional results.

Programmatically generate and embed charts

This example demonstrates how to create and embed a chart into a PDF document programmatically.

Java

// Prepare a template with a placeholder for the chart
// Total Contract Price<<y [m.Total_Contract_Price]>>
// <<seriesColor [color]>>

// Specify the file path to the template
// PDF templates are not supported at this time.
String template = "table_template.docx";

// Load data from your chosen source
JsonDataSource data_json = 
  new JsonDataSource("Items.json");

// Create a data object with the relevant information
DataSourceInfo data 
    = new DataSourceInfo(data_json, "items");

// Configure the chart's type and appearance
DataSourceInfo design 
    = new DataSourceInfo("red", "color");

// Initialize DocumentAssembler
DocumentAssembler asm = new DocumentAssembler();

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

Introduction to GroupDocs.Assembly for Java

GroupDocs.Assembly for Java is a versatile solution for automating the creation of documents and reports. It enables you to add charts, tables, lists, barcodes, and images directly into your files, with advanced tools for precise formatting and data integration. The platform supports over 50 formats, including PDF, Microsoft 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.

Explore powerful capabilities

This platform simplifies the process of designing data-focused, visually appealing documents tailored to your needs.

Generate comprehensive reports in diverse formats

Java lets you create documents with integrated charts across over 50 file formats, ensuring seamless merging of templates and data.

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