Sunting DOC ing Node SDK

Gunakake REST API kanggo nyunting DOC ing JavaScript kanthi terprogram

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.

Ndeleng potongan kode

Sunting DOC ing JavaScript nggunakake REST API

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.

Sunting teks ing DOC file nggunakake JavaScript

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.

Sunting tabel ing DOC file nggunakake JavaScript

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.

Tambah gambar menyang DOC file nggunakake JavaScript

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.

Sunting DOC kanthi terprogram

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:

Unggah dokumen sing pengin diowahi
Kode roto
Unggah gambar sing pengin dilebokake
Pilih format target saka dhaptar
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);
    });
});
Kode roto
  
Nyalin kode JavaScript menyang clipboard

Cara Ngowahi DOC ing JavaScript

  1. Pasang 'Aspose.Words Cloud kanggo Node'
  2. Tambah referensi perpustakaan (ngimpor perpustakaan) menyang proyek JavaScript sampeyan
  3. Muat DOC kanggo nyunting ing JavaScript
  4. Lebokake isi ing wiwitan DOC
  5. Download dokumen asil saka panyimpenan maya

Pustaka JavaScript kanggo nggunakake panyuntingan DOC.

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.

Requirements Sistem

  • @types/request (version 2.48.3+)
  • lodash (version 4.17.15+)
  • lodash.template (version 4.5.0+)
  • request (version 2.88.0+)
  • request-debug (version 0.2.0+)

Deleng Repository Documentation kanggo ndeleng rincian liyane.

Format file liyane sing didhukung

Sampeyan bisa nindakake operasi suntingan kanggo 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.