Nggunakake REST API ing JavaScript, pangembang bisa ngompres dokumen ing DOC, DOCX, RTF, PDF, lan format liyane. Kanthi solusi sing diwenehake, output bakal dadi file berkualitas tinggi sawise kompresi.
Nggunakake JavaScript API sing kuat, pangembang bisa ngompres file kanggo ngoptimalake konten lan ukuran file output. Ngurangi ukuran file dumadi kanthi ngresiki data lan sumber daya sing ora digunakake. Sampeyan uga bisa compress gambar kanggo nggawe ukuran file output malah luwih cilik.
Asil optimasi lan kompresi isi bisa disimpen ing format file asli utawa format nyimpen sing kasedhiya - DOCX, DOC, RTF, PDF, HTML lan liya-liyane.
Kaya sing wis kasebut, SDK Node kita ngidini sampeyan nyuda ukuran dokumen kanthi program ing format apa wae sing didhukung. Contone, sampeyan bisa nyuda ukuran PDF file, DOCX, DOC, RTF, ODT, EPUB, HTML lan format liyane. Lan saiki sampeyan bisa nyoba fungsi sing kuat lan ngevaluasi cara ngompres dokumen ing JavaScript kanthi conto ing ngisor iki:
import * as fs from "fs";
const wordsApi = new WordsApi("####-####-####-####-####", "##################");
const requestDocument = fs.createReadStream("Input.docx");
const requestCompressOptions = new model.CompressOptions({
imagesQuality: 75,
imagesReduceSizeFactor: 1
})
const compressDocumentRequest = new model.CompressDocumentOnlineRequest({
document: requestDocument,
compressOptions: requestCompressOptions
});
wordsApi.compressDocumentOnline(compressDocumentRequest)
.then((compressDocumentResult) => {
const requestDocument = compressDocumentResult.Document.Values();
const convertDocument = new model.ConvertDocumentRequest({
document: requestDocument,
format: "docx"
});
wordsApi.convertDocument(convertDocument)
.then((convertDocumentResult) => {
console.log("Result of ConvertDocument: ", convertDocumentResult);
});
});
Instal 'Aspose.Words Cloud SDK for Node.js' nggunakake manajer paket NPM. npm install asposewordscloud --save saka baris perintah kanggo nginstal SDK liwat manajer paket NPM. Minangka alternatif, sampeyan bisa kanthi manual kloning Aspose.Words Cloud SDK for Node.js saka GitHub lan nggunakake ing project. Tututi Instructions iki supaya cepet entuk kredensial keamanan sing dibutuhake lan ngakses REST API kita.
Deleng Repository Documentation kanggo ndeleng rincian liyane.