Textual Wmf to Png conversion in Java
Contents
[
Hide
]
Support textual Wmf to Png conversion
Issue : When converting WMF file to PNG, the text position and style can change.
Tips : It is necessary to change the RenderMode property to Auto in WmfRasterizationOptions.
Example :
This file contains 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
import com.aspose.imaging.Image; | |
import com.aspose.imaging.Size; | |
import com.aspose.imaging.fileformats.wmf.WmfRenderMode; | |
import com.aspose.imaging.imageoptions.PngOptions; | |
import com.aspose.imaging.imageoptions.WmfRasterizationOptions; | |
String baseFolder = "C:\\Input\\"; | |
String FileName = "input.wmf"; | |
String inputFileName = baseFolder + FileName; | |
String outputFileName = inputFileName + ".png"; | |
try (Image image = Image.load(inputFileName)) | |
{ | |
WmfRasterizationOptions rasterizationOptions = new WmfRasterizationOptions(); | |
rasterizationOptions.setRenderMode(WmfRenderMode.Auto); | |
rasterizationOptions.setPageSize(Size.to_SizeF(image.getSize())); | |
image.save(outputFileName, new PngOptions() | |
{{ | |
setVectorRasterizationOptions(rasterizationOptions); | |
}}); | |
} |