Ngembangake piranti lunak pangolahan dokumen ing Node.js nggunakake Optimasi Dokumen API. Solusi Node.js sing kuat iki mbantu sampeyan ngoptimalake lan nyuda ukuran dokumen lan gambar kanthi gampang. Test kapabilitas compressing online kanggo free!
Nggawe file gedhe luwih cilik tanpa mundhut kualitas. Mbusak data sing ora perlu lan ora digunakake. Nyilikake ukuran Word file lan HTML ing JavaScript. JavaScript nyedhiyakake pangembang API terpadu kanggo ngoptimalake dokumen ing macem-macem format.
JavaScript iki minangka solusi mandiri lan ora mbutuhake piranti lunak pihak katelu sing diinstal.
Efek maksimal bisa dipikolehi kanthi ngoptimalake gambar kanthi resolusi dhuwur, uga dokumen sing ngemot gambar kasebut. JavaScript bakal mbantu sampeyan ngompres file DOCX, DOC, RTF, ODT, EPUB, HTML, JPG, PNG.
Optimization saka dokumen tanpa mundhut saka kualitas digawe gampang karo 'Aspose.Words for Node.js via .NET'. Conto ing ngisor iki nuduhake carane nyilikake ukuran Word dokumen ing JavaScript:
npm install @aspose/words
Nyalin
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()) {
// 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.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()) {
// 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.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()) {
// 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.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()) {
// 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.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)
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.
This package is compatible with Node.js 14.17.0 or higher.