Sunting teks ing Node SDK

Gunakake REST API kanggo nyunting teks ing JavaScript kanthi terprogram

Nalika pangembang ngowahi teks dokumen nganggo perpustakaan JavaScript iki, sing lagi diowahi yaiku Model Obyek Dokumen (DOM). Dadi, meh kabeh owah-owahan bisa ditindakake kanggo teks 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 teks, gawe owah-owahan sing dibutuhake kanthi program lan ekspor asil menyang format nyimpen sing padha utawa sing didhukung.

Ndeleng potongan kode

Sunting teks ing JavaScript nggunakake REST API

Pustaka Node kita menehi pangembang kemampuan kanggo ngowahi teks dokumen kanthi langsung kanthi nyunting Document Object Model (DOM), tegese ora ana piranti lunak tambahan sing kudu diinstal.

Sunting teks ing teks file nggunakake JavaScript

Kasus sing paling populer kanggo nyunting teks 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 teks file nggunakake JavaScript

Pilihan editing teks 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 teks file nggunakake JavaScript

Saliyane nyunting teks lan tabel ing teks, ana pilihan umum liyane: nambahake gambar menyang dokumen ing JavaScript. Pangembang Node uga bisa nambah gambar menyang teks file nggunakake DOM.

Sunting teks kanthi terprogram

Coba Node SDK sing kuat iki lan evaluasi sawetara opsi ing panyuntingan teks dokumen. Nggunakake conto ing ngisor iki, muat teks dokumen lan gawe sawetara owah-owahan: nambah teks, nambah tabel lan sel tabel kanthi teks utawa lebokake gambar menyang teks 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.txt");
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: "txt"
    });

    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.txt");
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: "txt"
    });

    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.txt");
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.txt");
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: "txt"
    });

    wordsApi.convertDocument(convertDocument)
    .then((convertDocumentResult) => {
        console.log("Result of ConvertDocument: ", convertDocumentResult);
    });
});
Kode roto
  
Nyalin kode JavaScript menyang clipboard

Cara Ngowahi teks ing JavaScript

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

Pustaka JavaScript kanggo nggunakake panyuntingan TXT.

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.