When developers modify a document with the given Node solution, what is actually being edited is the Document Object Model (DOM). Thus, almost any changes can be made to the document represented as DOM. With the provided Node SDK, developers can easily edit a document: modify text, update tables, add images and so on. Just load your Word, PDF or file in a supported load format, make the necessary changes programmatically and export the result to a supported save format.
Our Node library gives developers the ability to modify a document directly by editing its Document Object Model (DOM), which means no additional software needs to be installed.
It is important to know that using this JavaScript solution, you can edit a document in any supported format. For example, it is possible to load a file in PDF, DOCX, DOC, RTF, ODT, EPUB, HTML and other formats, and then modify this file and save it in the same format or in any other supported format.
The most popular case to edit Word, PDF or any other document is text editing. With the given software solution, you can add, modify or delete text using JavaScript within the document.
Another popular document editing option is table editing. Our Node SDK allows you to work with tables and text in table cells.
JavaScript developers can add or remove table and table cells, as well as add, edit and remove text within them.
Besides editing text and tables, there is another common option: adding images to a document in JavaScript. Node developers can also add an image into a file using DOM.
Try this powerful Node SDK and evaluate some options in document editing. Using the following example, load your document and make some changes: add text, add a table and a table cell with text or insert an image into the document:
import * as fs from "fs";
const wordsApi = new WordsApi("####-####-####-####-####", "##################");
const requestDocument = fs.createReadStream("Input.docx");
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: "docx"
});
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.docx");
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: "docx"
});
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.docx");
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.docx");
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: "docx"
});
wordsApi.convertDocument(convertDocument)
.then((convertDocumentResult) => {
console.log("Result of ConvertDocument: ", convertDocumentResult);
});
});
Install 'Aspose.Words Cloud SDK for Node.js' using NPM package manager. Run npm install asposewordscloud --save from the command line to install the SDK via the NPM package manager. As an alternative, you can manually clone Aspose.Words Cloud SDK for Node.js source code from GitHub and use it in your project. Please follow these Instructions to quickly get the necessary security credentials and access our REST API.
Refer to the Repository Documentation to see more details.