Kode kanggo ngompres DOC ing JavaScript

Dhuwur-kinerja Node.js perpustakaan kanggo ngoptimalake ukuran lan content file DOC nalika ngramut kualitas asli

Gawea piranti lunak pangolahan DOC ing Node.js nggunakake DOC Optimization API. Solusi Node.js sing kuat iki mbantu sampeyan ngoptimalake lan nyuda ukuran file DOC kanthi gampang. Uji kemampuan kompres DOC kanthi online kanthi gratis!

Ndeleng potongan kode

Kompres file DOC ing JavaScript

Nggawe file DOC gedhe luwih cilik tanpa mundhut kualitas. Mbusak data sing ora perlu lan ora digunakake. Nyilikake ukuran file DOC ing kode. Pustaka JavaScript nyedhiyakake pangembang API terpadu kanggo ngoptimalake isi DOC.

Ngurangi ukuran file DOC nggunakake JavaScript

Perpustakaan JavaScript minangka solusi mandiri lan ora mbutuhake piranti lunak pihak katelu sing diinstal.

Kompresi lossless lan optimasi isi jero digawe gampang karo 'Aspose.Words for Node.js via .NET'. Conto ing ngisor iki nuduhake carane ngoptimalake isi file DOC ing JavaScript:

Conto kode ing JavaScript kanggo ngompres DOC file
Unggah file sing pengin dioptimalake / kompres
Kode roto
Pilih format target saka dhaptar
npm install @aspose/words
Nyalin
const aw = require('@aspose/words');

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

var shapes = doc.getChildNodes(aw.NodeType.Shape, true)
for (var shape of shapes) {
    if (shape.hasImage()) {
        // Iku nganti pangembang kanggo milih perpustakaan kanggo komprèsi gambar.
        const imageData = shape.getImageData().toStream();

        // ...
        // Ngompres gambar lan nyetel maneh menyang wangun.
        shape.getImageData().setImage(compressedImageBuffer);
    }
}

doc.save("Output.doc")
const aw = require('@aspose/words'); var doc = new aw.Document("Input.doc"); doc.cleanup(); var shapes = doc.getChildNodes(aw.NodeType.Shape, true) for (var shape of shapes) { if (shape.hasImage()) { // Iku nganti pangembang kanggo milih perpustakaan kanggo komprèsi gambar. const imageData = shape.getImageData().toStream(); // ... // Ngompres gambar lan nyetel maneh menyang wangun. shape.getImageData().setImage(compressedImageBuffer); } } var saveOptions = new aw.Saving.PdfSaveOptions() saveOptions.cacheBackgroundGraphics = true doc.save("Output.doc", saveOptions) const aw = require('@aspose/words'); var doc = new aw.Document("Input.doc"); doc.cleanup(); var shapes = doc.getChildNodes(aw.NodeType.Shape, true) for (var shape of shapes) { if (shape.hasImage()) { // Iku nganti pangembang kanggo milih perpustakaan kanggo komprèsi gambar. const imageData = shape.getImageData().toStream(); // ... // Ngompres gambar lan nyetel maneh menyang wangun. shape.getImageData().setImage(compressedImageBuffer); } } doc.save("Output.doc") const aw = require('@aspose/words'); var doc = new aw.Document("Input.doc"); doc.cleanup(); var shapes = doc.getChildNodes(aw.NodeType.Shape, true) for (var shape of shapes) { if (shape.hasImage()) { // Iku nganti pangembang kanggo milih perpustakaan kanggo komprèsi gambar. const imageData = shape.getImageData().toStream(); // ... // Ngompres gambar lan nyetel maneh menyang wangun. shape.getImageData().setImage(compressedImageBuffer); } } var saveOptions = new aw.Saving.OoxmlSaveOptions() saveOptions.compressionLevel = aw.Saving.CompressionLevel.Maximum doc.save("Output.doc", saveOptions) const aw = require('@aspose/words'); var doc = new aw.Document() var builder = new aw.DocumentBuilder(doc) shape = builder.insertImage("Input.doc") var saveOptions = new aw.Saving.ImageSaveOptions(aw.SaveFormat.Doc) shape.getShapeRenderer().save("Output.doc", saveOptions)
Kode roto

Cara ngompres DOC Ing JavaScript

  1. Pasang Aspose.Words for Node.js via .NET.
  2. Tambah referensi perpustakaan (ngimpor perpustakaan) menyang proyek JavaScript sampeyan.
  3. Bukak DOC berkas sumber ing JavaScript.
  4. Kompres DOC tanpa kelangan kualitas.
  5. Telpon metode Document.cleanup(). Kode asil bisa beda-beda gumantung saka format file output.
  6. Entuk asil sing dikompres minangka DOC file.

Pustaka JavaScript kanggo ngoptimalake lan ngompres DOC file

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.

Optimasi format file liyane sing didhukung

Sampeyan bisa ngoptimalake file ing akeh format file liyane:

5%

Langganan kanggo Aspose Update Product

Entuk buletin saben wulan lan tawaran langsung dikirim menyang kothak layang.

© Aspose Pty Ltd 2001-2024. Kabeh hak dilindhungi undhang-undhang.