Circle Graph Maker - How to Make a Graph in PDF using Java

Circle Graph Maker

This Java API tutorial will teach us how to make a graph in PDF using Java programmatically. You can generate multiple types of graphs using this enterprise-level library. However, in this guide, we will write steps and the code snippet to build a circle graph maker in a Java application. Once you are done with the code snippet, you can automate the graph creation easily. In addition, we will explore some advanced methods exposed by the API we will use in this article.

We will cover the following topics:

Circle Graph Maker - API installation

We are going to use this power PDF API for Java. There is a wide range of methods available to meet your business requirements. In fact, you can either download the API or install it using the following Maven configurations.

 <repository>
    <id>AsposeJavaAPI</id>
    <name>Aspose Java API</name>
    <url>https://repository.aspose.com/repo/</url>
</repository>
<dependency>
    <groupId>com.aspose</groupId>
    <artifactId>aspose-pdf</artifactId>
    <classifier>jdk17</classifier>
</dependency>

How to make a Graph in PDF using Java

You may follow the steps and the code snippets mentioned below:

  1. Create an object of the Document class.
  2. Invoke the getPages().add() method to add a page to pages collection of PDF file.
  3. Initializes a new instance of the Graph class with certain dimensions.
  4. Initialize a new instance of the BorderInfo class.
  5. Invoke the setBorder method to set the border of the graph.
  6. Create an instance of the Circle class and specify the parameters.
  7. Now, call the getGraphInfo().setColor method to set the graph color.
  8. Add Graph object to paragraphs collection of page by calling the getParagraphs().add(graph) method.
  9. Invoke the save method to save the PDF file.

Copy & paste the following code into your main file:

You may see the output in the image below:

Circle Graph Make

Generate a filled Circle graph

The following code snippet is to generate a filled circle graph programmatically:

Copy & paste the following code into your main file:

You may see the output in the image below:

How to Make a Graph in PDF using Java

Get a Free License

You can avail a free temporary license to try the API without evaluation limitations.

Summing up

There are many other methods and provisions offered by this PDF API for Java. We suggest you visit the documentation to know further about this library. So, we have gone through how to make a graph in PDF using Java programmatically. Moreover, this article will really help you if you are looking to build a circle graph maker for your business software.

Moreover, we suggest you follow our Getting Started guide.

Finally, conholdate.com is writing new blog posts. Therefore, please stay in touch for regular updates.

Ask a question

You can let us know about your questions or queries on our forum.

FAQs

How do I make graphs in PDF?

Please follow this link to know about the steps and the code snippet to learn how to make a graph in a PDF programmatically.

See Also