Java REST API के साथ DOCX को PNG में कैसे बदलें

यह ट्यूटोरियल आपको दिखाता है कि क्लाउड में Java REST API** के साथ ** DOCX को PNG में कैसे परिवर्तित करें। DOCX को PNG प्रारूप में निर्यात करने के लिए, हम Java क्लाउड SDK के लिए Aspose.Words का उपयोग कर रहे हैं। यदि आप जावा लो कोड एपीआई में DOCX से PNG रूपांतरण में रुचि रखते हैं तो इसे नीचे दिए गए कोड और चरणों की सहायता से किया जा सकता है।

पूर्वावश्यकता

Java REST API में DOCX को PNG में बदलने के चरण

  1. एपीआई के लिए क्लाइंट आईडी और क्लाइंट सीक्रेट सेट करें
  2. क्लाइंट क्रेडेंशियल्स के साथ WordsAPI क्लास का एक ऑब्जेक्ट बनाएं
  3. इनपुट और आउटपुट फ़ाइलें निर्दिष्ट करें
  4. इनपुट DOCX फ़ाइल पढ़ें और क्लाउड स्टोरेज पर अपलोड करें
  5. इनपुट और आउटपुट फ़ाइल स्वरूपों के साथ WordsAPI का एक ऑब्जेक्ट बनाएं
  6. REST API का उपयोग करके DOCX को PNG में कनवर्ट करने के लिए convertDocument विधि को कॉल करें*
  7. आउटपुट पीएनजी फ़ाइल को स्थानीय डिस्क पर सहेजें

जावा लो कोड एपीआई में DOCX से PNG रूपांतरण के लिए कोड

String ClientID = Client.getID(); //replace Client.getID() with your own client ID here
String ClientSecret = Client.getSecret(); //replace3 Client.getSecret() with your own client secret here
String APIBaseUrl="https://api.aspose.cloud";
String Local_Path = "C:/Temp/";
try {
//Create API client with credentials
ApiClient apiClient = new ApiClient(ClientID, ClientSecret, APIBaseUrl);
//Create SDK object
WordsApi wordsApi = new WordsApi(apiClient);
String inputFile = "DOCXToPNG.docx";
String outputFile = "DOCXToPNG.png";
String outputFormat = "png";
//Read input file to bytes array
byte[] inputFileData = Files.readAllBytes(Paths.get(Local_Path + inputFile).toAbsolutePath());
//create conversion request object with input and output files
ConvertDocumentRequest convertDocumentRequest = new ConvertDocumentRequest(inputFileData, outputFormat, null, null, null, null, null, null, null);
//convert the input file to output format
byte[] outputFileData = wordsApi.convertDocument(convertDocumentRequest);
//save the output file from the bytes array
FileOutputStream fileOutputStream = new FileOutputStream(Local_Path + outputFile);
fileOutputStream.write(outputFileData);
} catch (Exception e) {
System.out.println(e.getMessage());
}

ऊपर निर्दिष्ट कोड स्निपेट आपको Java REST API के साथ DOCX को PNG में बदलने का अधिकार देता है। आपको बस जावा के लिए Aspose.Words REST API SDK की मदद से DOCX फ़ाइल की आपूर्ति करनी होगी और Aspose रूपांतरण एपीआई का ऑनलाइन उपयोग करके इसे स्थानीय रूप से सहेजने के लिए आउटपुट PNG फ़ाइल डाउनलोड करनी होगी।

यह DOCX से PNG रूपांतरण किसी भी प्लेटफ़ॉर्म पर बिना कोड वाले या कम कोड वाले ऐप्स के साथ किया जा सकता है।

कृपया निम्नलिखित लिंक पर संबंधित सुविधा देखें: Java REST API के साथ DOCX को PDF में कैसे बदलें

 हिन्दी