Last active
August 8, 2023 03:41
How to Convert SVG to WMF with Java REST API: https://kb.aspose.cloud/imaging/java/how-to-convert-svg-to-wmf-with-java-rest-api/
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
String ClientID = Client.getID(); //replace Client.getID() with your own client ID here | |
String ClientSecret = Client.getSecret(); //replace Client.getSecret() with your own client secret here | |
String APIBaseUrl="https://api.aspose.cloud"; | |
String Local_Path = "C:/Temp/"; | |
ImagingApi imagingApiSdk = new ImagingApi(ClientSecret, ClientID, APIBaseUrl); | |
// Input & output file names | |
String inputFileName = "SVGtoWMF.svg"; | |
String outputFileName = "SVGtoWMF.wmf"; | |
try { | |
// Upload local image to Cloud Storage | |
File inputFile = new File(Local_Path + inputFileName); | |
FileInputStream inputFileStream = new FileInputStream(inputFile); | |
byte[] inputImageData = IOUtils.toByteArray(inputFileStream); | |
UploadFileRequest uploadFileRequest = new UploadFileRequest(inputFileName, inputImageData, null); | |
FilesUploadResult filesUploadResult = imagingApiSdk.uploadFile(uploadFileRequest); | |
String outputFormat = "wmf"; | |
String remoteFolder = null; // Input file is saved at the root of the storage | |
String remoteStorage = null; // Cloud Storage name | |
ConvertImageRequest convertImageRequest = new ConvertImageRequest(inputFileName, outputFormat, remoteFolder, remoteStorage); | |
byte[] convertedImageData = imagingApiSdk.convertImage(convertImageRequest); | |
// Save exported image to local storage | |
FileOutputStream fileOutputStream = new FileOutputStream(Local_Path + outputFileName); | |
fileOutputStream.write(convertedImageData); | |
fileOutputStream.close(); | |
} catch (Exception e) { | |
System.out.println(e.getMessage()); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment