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

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

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

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

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

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

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 = "DOCXToJPG.docx";
String outputFile = "DOCXToJPG.jpg";
String outputFormat = "jpg";
//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 को JPG में बदलने में सक्षम बनाता है। आपको केवल जावा के लिए Aspose.Words REST API SDK की मदद से DOCX फ़ाइल प्रदान करनी होगी और Aspose रूपांतरण API का ऑनलाइन उपयोग करके इसे स्थानीय रूप से सहेजने के लिए आउटपुट JPG फ़ाइल डाउनलोड करनी होगी।

इस DOCX से JPG रूपांतरण सुविधा का उपयोग किसी भी डिवाइस या कंप्यूटर पर बिना कोड वाले या कम कोड वाले ऐप्स के साथ किया जा सकता है।

एक समान सुविधा निम्नलिखित विषय में पाई जा सकती है: Java REST API के साथ DOCX को PDF में कैसे बदलें

 हिन्दी