Last active
June 9, 2025 15:38
-
-
Save aspose-com-gists/0e02767cd86c8d5d98c329db15ec4a4e to your computer and use it in GitHub Desktop.
CMX to PNG 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 com.aspose.imaging.Image; | |
import com.aspose.imaging.SmoothingMode; | |
import com.aspose.imaging.imageoptions.CmxRasterizationOptions; | |
import com.aspose.imaging.imageoptions.PngOptions; | |
import com.aspose.imaging.imageoptions.PositioningTypes; | |
public class main { | |
public static void main(String[] args) { | |
// The path to the documents directory. | |
String dataDir = "data"; | |
String[] fileNames = new String[] { | |
"Ellipse+fill.cmx", | |
}; | |
// Loop through all the input files. | |
for (String fileName: fileNames) { | |
// Invoke the Image.load method to load the source file. | |
try (Image image = Image.load(dataDir + fileName)) | |
{ | |
// Create an instance of the CmxRasterizationOptions class. | |
CmxRasterizationOptions cmxRasterizationOptions = new CmxRasterizationOptions(); | |
// Set the positioning by calling the setPositioning method. | |
cmxRasterizationOptions.setPositioning(PositioningTypes.DefinedByDocument); | |
// Set the smoothing mode by calling the setSmoothingMode method. | |
cmxRasterizationOptions.setSmoothingMode(SmoothingMode.AntiAlias); | |
// Instantiate an object of the PngOptions class. | |
PngOptions options = new PngOptions(); | |
// Call the setVectorRasterizationOptions method to set the vector rasterization options. | |
options.setVectorRasterizationOptions(cmxRasterizationOptions); | |
// Invoke the save method to save the file on disk. | |
image.save( dataDir + fileName + ".docpage.png", options); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment