Nalika pangembang ngowahi DOC dokumen nganggo perpustakaan JavaScript iki, sing lagi diowahi yaiku Model Obyek Dokumen (DOM). Dadi, meh kabeh owah-owahan bisa ditindakake kanggo DOC dokumen sing diwakili minangka DOM. Kanthi Node SDK sing disedhiyakake, pangembang bisa kanthi gampang nyunting dokumen: ngowahi teks, nganyari tabel, nambah gambar lan liya-liyane. Cukup mbukak DOC, gawe owah-owahan sing dibutuhake kanthi program lan ekspor asil menyang format nyimpen sing padha utawa sing didhukung.
Pustaka Node kita menehi pangembang kemampuan kanggo ngowahi DOC dokumen kanthi langsung kanthi nyunting Document Object Model (DOM), tegese ora ana piranti lunak tambahan sing kudu diinstal.
Kasus sing paling populer kanggo nyunting DOC file yaiku nyunting teks. Kanthi solusi piranti lunak sing diwenehake, sampeyan bisa nambah, ngowahi utawa mbusak teks nggunakake JavaScript ing dokumen kasebut.
Pilihan editing DOC liyane sing populer yaiku nyunting tabel. Node SDK kita ngidini sampeyan nggarap tabel lan teks ing sel tabel.
Pangembang JavaScript bisa nambah utawa mbusak sel tabel lan tabel, uga nambah, ngowahi lan mbusak teks ing njero.
Saliyane nyunting teks lan tabel ing DOC, ana pilihan umum liyane: nambahake gambar menyang dokumen ing JavaScript. Pangembang Node uga bisa nambah gambar menyang DOC file nggunakake DOM.
Coba Node SDK sing kuat iki lan evaluasi sawetara opsi ing panyuntingan DOC dokumen. Nggunakake conto ing ngisor iki, muat DOC dokumen lan gawe sawetara owah-owahan: nambah teks, nambah tabel lan sel tabel kanthi teks utawa lebokake gambar menyang DOC dokumen:
import * as fs from "fs";
const wordsApi = new WordsApi("####-####-####-####-####", "##################");
const requestDocument = fs.createReadStream("Input.doc");
const requestParagraph = new model.ParagraphInsert({
text: "Morbi enim nunc faucibus a."
})
const insertParagraphRequest = new model.InsertParagraphOnlineRequest({
document: requestDocument,
paragraph: requestParagraph
});
wordsApi.insertParagraphOnline(insertParagraphRequest)
.then((insertParagraphResult) => {
const requestDocument = insertParagraphResult.Document.Values();
const convertDocument = new model.ConvertDocumentRequest({
document: requestDocument,
format: "doc"
});
wordsApi.convertDocument(convertDocument)
.then((convertDocumentResult) => {
console.log("Result of ConvertDocument: ", convertDocumentResult);
});
});
import * as fs from "fs";
const wordsApi = new WordsApi("####-####-####-####-####", "##################");
const requestDocument = fs.createReadStream("Input.doc");
const requestTable = new model.TableInsert({
columnsCount: 1,
rowsCount: 2
})
const insertTableRequest = new model.InsertTableOnlineRequest({
document: requestDocument,
table: requestTable,
nodePath: ""
});
wordsApi.insertTableOnline(insertTableRequest)
.then((insertTableResult) => {
const requestDocument = insertTableResult.Document.Values();
const convertDocument = new model.ConvertDocumentRequest({
document: requestDocument,
format: "doc"
});
wordsApi.convertDocument(convertDocument)
.then((convertDocumentResult) => {
console.log("Result of ConvertDocument: ", convertDocumentResult);
});
});
import * as fs from "fs";
const wordsApi = new WordsApi("####-####-####-####-####", "##################");
const requestDocument = fs.createReadStream("Input1.doc");
const requestDrawingObject = new model.DrawingObjectInsert({
height: 0,
left: 0,
top: 0,
width: 0,
relativeHorizontalPosition: model.DrawingObjectInsert.RelativeHorizontalPositionEnum.Margin,
relativeVerticalPosition: model.DrawingObjectInsert.RelativeVerticalPositionEnum.Margin,
wrapType: model.DrawingObjectInsert.WrapTypeEnum.Inline
})
const requestImageFile = fs.createReadStream("Input2.doc");
const insertDrawingObjectRequest = new model.InsertDrawingObjectOnlineRequest({
document: requestDocument,
drawingObject: requestDrawingObject,
imageFile: requestImageFile,
nodePath: "sections/0"
});
wordsApi.insertDrawingObjectOnline(insertDrawingObjectRequest)
.then((insertDrawingObjectResult) => {
const requestDocument = insertDrawingObjectResult.Document.Values();
const convertDocument = new model.ConvertDocumentRequest({
document: requestDocument,
format: "doc"
});
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.
Sampeyan bisa nindakake operasi suntingan kanggo format file liyane: