JavaScript में DOCX को संपीड़ित करने के लिए कोड

उच्च-प्रदर्शन Node.js लाइब्रेरी, जो DOCX फ़ाइलों के आकार और सामग्री को अनुकूलित करती है, साथ ही उनकी मूल गुणवत्ता को बनाए रखती है

DOCX Optimization API का उपयोग करके Node.js में DOCX प्रोसेसिंग सॉफ़्टवेयर विकसित करें। यह शक्तिशाली Node.js समाधान आपको आसानी से DOCX फ़ाइलों के आकार को अनुकूलित और कम करने में मदद करता है। ऑनलाइन DOCX कंप्रेसिंग क्षमताओं का निःशुल्क परीक्षण करें!

कोड स्निपेट देखें

JavaScript. में JavaScript DOCX फ़ाइल को कंप्रेस करें

गुणवत्ता की हानि के बिना बड़ी DOCX फ़ाइलों को छोटा करें। अनावश्यक और अप्रयुक्त डेटा हटाएं। कोड में DOCX फ़ाइल का आकार सिकोड़ें। JavaScript लाइब्रेरी डेवलपर्स को DOCX सामग्री को अनुकूलित करने के लिए एक एकीकृत एपीआई प्रदान करती है।

JavaScript. का उपयोग करके JavaScript DOCX फ़ाइलों का आकार कम करें

JavaScript पुस्तकालय एक अकेला समाधान है और इसके लिए किसी तृतीय पक्ष सॉफ़्टवेयर को स्थापित करने की आवश्यकता नहीं है।

दोषरहित संपीड़न और गहरी सामग्री अनुकूलन 'Aspose.Words for Node.js via .NET' साथ आसान बना दिया। निम्न उदाहरण दर्शाता है कि JavaScript में JavaScript DOCX फ़ाइल की सामग्री को कैसे अनुकूलित किया जाए:

कोड उदाहरण JavaScript में DOCX फ़ाइलों को संपीड़ित करने के लिए
एक फ़ाइल अपलोड करें जिसे आप अनुकूलित/संपीड़ित करना चाहते हैं
कोड चलाएँ
सूची से लक्ष्य प्रारूप का चयन करें
npm install @aspose/words
प्रतिलिपि
const aw = require('@aspose/words');

var doc = new aw.Document("Input.docx");
doc.cleanup();

var shapes = doc.getChildNodes(aw.NodeType.Shape, true)
for (var shape of shapes) {
    if (shape.hasImage()) {
        // छवि संपीड़न के लिए लाइब्रेरी चुनना डेवलपर पर निर्भर है ।.
        const imageData = shape.getImageData().toStream();

        // ...
        // छवि को संपीड़ित करें और इसे वापस आकार में सेट करें ।.
        shape.getImageData().setImage(compressedImageBuffer);
    }
}

var saveOptions = new aw.Saving.OoxmlSaveOptions()
saveOptions.compressionLevel = aw.Saving.CompressionLevel.Maximum

doc.save("Output.docx", saveOptions)
const aw = require('@aspose/words'); var doc = new aw.Document("Input.docx"); doc.cleanup(); var shapes = doc.getChildNodes(aw.NodeType.Shape, true) for (var shape of shapes) { if (shape.hasImage()) { // छवि संपीड़न के लिए लाइब्रेरी चुनना डेवलपर पर निर्भर है ।. const imageData = shape.getImageData().toStream(); // ... // छवि को संपीड़ित करें और इसे वापस आकार में सेट करें ।. shape.getImageData().setImage(compressedImageBuffer); } } var saveOptions = new aw.Saving.PdfSaveOptions() saveOptions.cacheBackgroundGraphics = true doc.save("Output.docx", saveOptions) const aw = require('@aspose/words'); var doc = new aw.Document("Input.docx"); doc.cleanup(); var shapes = doc.getChildNodes(aw.NodeType.Shape, true) for (var shape of shapes) { if (shape.hasImage()) { // छवि संपीड़न के लिए लाइब्रेरी चुनना डेवलपर पर निर्भर है ।. const imageData = shape.getImageData().toStream(); // ... // छवि को संपीड़ित करें और इसे वापस आकार में सेट करें ।. shape.getImageData().setImage(compressedImageBuffer); } } doc.save("Output.docx") const aw = require('@aspose/words'); var doc = new aw.Document("Input.docx"); doc.cleanup(); var shapes = doc.getChildNodes(aw.NodeType.Shape, true) for (var shape of shapes) { if (shape.hasImage()) { // छवि संपीड़न के लिए लाइब्रेरी चुनना डेवलपर पर निर्भर है ।. const imageData = shape.getImageData().toStream(); // ... // छवि को संपीड़ित करें और इसे वापस आकार में सेट करें ।. shape.getImageData().setImage(compressedImageBuffer); } } var saveOptions = new aw.Saving.OoxmlSaveOptions() saveOptions.compressionLevel = aw.Saving.CompressionLevel.Maximum doc.save("Output.docx", saveOptions) const aw = require('@aspose/words'); var doc = new aw.Document() var builder = new aw.DocumentBuilder(doc) shape = builder.insertImage("Input.docx") var saveOptions = new aw.Saving.ImageSaveOptions(aw.SaveFormat.Docx) shape.getShapeRenderer().save("Output.docx", saveOptions)
कोड चलाएँ

DOCX को JavaScript में कैसे संपीड़ित करें

  1. Aspose.Words for Node.js via .NET करें।
  2. अपने JavaScript प्रोजेक्ट में लाइब्रेरी संदर्भ (लाइब्रेरी आयात करें) जोड़ें।
  3. स्रोत DOCX फ़ाइल को JavaScript में खोलें।
  4. गुणवत्ता खोए बिना DOCX को संपीड़ित करें।
  5. Document.cleanup() विधि को कॉल करें। परिणामी कोड आउटपुट फ़ाइल स्वरूप के आधार पर भिन्न हो सकता है।
  6. संपीड़ित परिणाम को DOCX फ़ाइल के रूप में प्राप्त करें।

JavaScript लाइब्रेरी को अनुकूलित करने और DOCX फ़ाइलों को संपीड़ित करने के लिए

We host our Node.js via .Net packages in NPM repositories. Please follow the step-by-step instructions on how to install "Aspose.Words for Node.js via .NET" to your developer environment.

System Requirements

This package is compatible with Node.js 14.17.0 or higher.

अन्य समर्थित फ़ाइल स्वरूप अनुकूलन

आप कई अन्य फ़ाइल स्वरूपों में फ़ाइलों को अनुकूलित कर सकते हैं:

5%

उत्पाद अपडेट के लिए सदस्यता लें

मासिक न्यूज़लेटर और ऑफ़र सीधे आपके मेलबॉक्स में प्राप्त करें।

© Aspose Pty Ltd 2001-2025. सर्वाधिकार सुरक्षित।