How to Add Circle in PDF using Java

In this tutorial, you will learn how to add circle in PDF using Java. It provides configuration details, the logical steps to write the program to draw circle in Adobe Acrobat using Java, and a runnable sample code to demonstrate the process. It will also discuss different options to format the circle as well and then save the resultant file on the disk.

Steps to Add a Circle to a PDF using Java

  1. Set the IDE to add Aspose.PDF for Java to add a circle
  2. Create a new PDF document and add a page to it for adding graphics object
  3. Create a circle with a specified position and radius
  4. Set circle properties like its color
  5. Create a Graph object and add the circle to it
  6. Add this graph to the paragraphs collection of the selected page and save it on the disk

These steps explain how to draw a circle in Adobe PDF using Java. First, a circle is created and its color is set that is followed by the creation of a Graph class object that is used to contain the drawing objects in a PDF. In the next steps, this circle is added to the graph object that is finally added to the paragraphs collection of the selected page before saving it on the disk.

Code to Add Circle to PDF using Java

This code demonstrates how to insert circle in PDF using Java. It uses the Circle class object to create a circle by providing position and radius and then uses the getGraphInfo() method of the Circle class to set the color. You may set other properties also like fill color, line width, rotation angle for the coordinates system, and the scaling rate for the coordinates transformation.

In this topic, we have learned how to add circle to PDF using Java. If you want to learn the process to add digital signatures to PDF, refer to the article on how to add digital signature to PDF in Java.

 English