品質を損なうことなく、大きな DOC ファイルを小さくします。不要な未使用のデータを削除します。コード内の DOC ファイルのサイズを縮小します。 JavaScript ライブラリは、 DOC コンテンツを最適化するための統合APIを開発者に提供します。
JavaScript ライブラリはスタンドアロンソリューションであり、サードパーティのソフトウェアをインストールする必要はありません。
'Aspose.Words for Node.js via .NET' 使用すると、ロスレス圧縮と詳細なコンテンツの最適化が簡単になります。次の例は、JavaScript の JavaScript DOC ファイルのコンテンツを最適化する方法を示しています。
npm install @aspose/words
コピー
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()) {
// 画像圧縮用のライブラリを選択するのは開発者次第です。
const imageData = shape.getImageData().toStream();
// ...
// 画像を圧縮し、形状に戻します。
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()) {
// 画像圧縮用のライブラリを選択するのは開発者次第です。
const imageData = shape.getImageData().toStream();
// ...
// 画像を圧縮し、形状に戻します。
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()) {
// 画像圧縮用のライブラリを選択するのは開発者次第です。
const imageData = shape.getImageData().toStream();
// ...
// 画像を圧縮し、形状に戻します。
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()) {
// 画像圧縮用のライブラリを選択するのは開発者次第です。
const imageData = shape.getImageData().toStream();
// ...
// 画像を圧縮し、形状に戻します。
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)
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.