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

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

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

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

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

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

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

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

एक संबंधित सुविधा भी आपके लिए उपयोगी हो सकती है: Java REST API के साथ DOCX को TIFF में कैसे बदलें

 हिन्दी