Last active
October 30, 2025 15:48
-
-
Save aspose-com-gists/d29b44c6a75cec44b7c992faccf1a5df to your computer and use it in GitHub Desktop.
Draw an Ellipse in a PostScript File using Java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package com.example; | |
| import java.io.FileOutputStream; | |
| import java.awt.Color; | |
| import java.awt.BasicStroke; | |
| import java.awt.geom.Ellipse2D; | |
| import com.aspose.page.License; | |
| import com.aspose.eps.PsDocument; | |
| import com.aspose.eps.device.PsSaveOptions; | |
| public class main { | |
| public static void main(String[] args) { | |
| try { | |
| // Load Aspose.Page license | |
| License lic = new License(); | |
| lic.setLicense("license.lic"); | |
| // Define output file | |
| String outputFile = "AddEllipse_outPS.ps"; | |
| // Create output stream for PostScript document. | |
| FileOutputStream outPsStream = new FileOutputStream(outputFile); | |
| // Create save options with default page size (A4) | |
| PsSaveOptions options = new PsSaveOptions(); | |
| // Create new PS Document by creating an instance of the PsDocument class. | |
| PsDocument document = new PsDocument(outPsStream, options, false); | |
| // Set paint for filling ellipse. | |
| document.setPaint(Color.ORANGE); | |
| document.fill(new Ellipse2D.Float(250, 100, 150, 100)); | |
| // Set paint for stroking ellipse | |
| document.setPaint(Color.RED); | |
| document.setStroke(new BasicStroke(3)); | |
| document.draw(new Ellipse2D.Float(250, 300, 150, 100)); | |
| // Close current page. | |
| document.closePage(); | |
| // Call the save method to save the document on the disk. | |
| document.save(); | |
| System.out.println("Ellipses added successfully to PostScript file."); | |
| } catch (Exception e) { | |
| e.printStackTrace(); | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment