Add Curve Shapes to PDF in Java
Contents
[
Hide
]
Curves in Aspose.PDF for Java are defined by a float coordinate array passed to Curve.
Add a curve outline
- Create a new PDF Document.
- Add a Page to the document.
- Create a Graph container and add it to the page.
- Create the Curve shape and configure its control points.
- Add the Curve to the Graph container.
- Set the shape properties required by the example, including Color.
- Save the output PDF Document.
public static void addCurve(Path outputFile) {
try (Document document = new Document()) {
Page page = document.getPages().add();
Graph graph = new Graph(400.0, 200.0);
graph.setBorder(new BorderInfo(BorderSide.All, Color.getGreen()));
Curve curve1 = new Curve(new float[]{10, 10, 50, 60, 70, 10, 100, 120});
curve1.getGraphInfo().setColor(Color.getGreenYellow());
graph.getShapes().addItem(curve1);
page.getParagraphs().add(graph);
document.save(outputFile.toString());
}
}