Spire.Doc for JavaScript 13.4.0 supports a range of new features

Spire.Doc for JavaScript 13.4.0 supports a range of new features

2025-04-23 07:45:00

We are excited to announce the release of Spire.Doc for JavaScript 13.4.0. The latest version introduces a range of new features, including adding various types of charts to Word documents. More details are listed below.

Here is a list of changes made in this release

Category ID Description
New feature Supports adding various types of charts, such as bar charts, line charts, and pie charts.
// Load word document
let document = wasmModule.Document.Create();

// Add a section to the document
let section = document.AddSection();

// Add a paragraph to the section and append text to it
section.AddParagraph().AppendText("Bar chart.");

// Add a new paragraph to the section
let newPara = section.AddParagraph();

// Append a bar chart shape to the paragraph with specified width and height
let chartShape = newPara.AppendChart(wasmModule.ChartType.Bar, 400.0, 300.0);

let chart = chartShape.Chart;

// Get the title of the chart
let title = chart.Title;

// Set the text of the chart title
title.Text = "My Chart";

// Show the chart title
title.Show = true;

// Overlay the chart title on top of the chart
title.Overlay = true;

// Save the document to the specified path
const outputFileName = "AppendBarChart.docx";
document.SaveToFile({
  fileName: outputFileName,
  fileFormat: wasmModule.FileFormat.Docx2013,
});
New feature Supports adding SVG images to a Word document.
//Open a Word document
let document = wasmModule.Document.Create();
let section = document.AddSection();
//Add a new paragraph
let para = section.AddParagraph();

//add a svg file to the paragraph
let svgPicture = para.AppendPicture({imgFile: inputSVGFileName});

//Set svg's width
svgPicture.Width = 200;

//Set svg's height
svgPicture.Height = 200;

// Save the document
const outputFileName = "AddSvg.docx";
document.SaveToFile({ fileName: outputFileName, fileFormat: wasmModule.FileFormat.Docx });
New feature Supports extracting images from Word documents.
//open document
let document = wasmModule.Document.Create();
document.LoadFromFile(inputFileName);

//embedded images list.
let images = [];

for (let i = 0; i < document.Sections.Count; i++) {
  let section = document.Sections.get(i);
  for (let j = 0; j < section.Body.ChildObjects.Count; j++) {
    let objInSec = section.Body.ChildObjects.get(j);
    if (objInSec.DocumentObjectType == wasmModule.DocumentObjectType.Paragraph) {
      for (let k = 0; k < objInSec.ChildObjects.Count; k++) {
        let objInPara = objInSec.ChildObjects.get(k);
        if (objInPara.DocumentObjectType == wasmModule.DocumentObjectType.Picture) {
          images.push(objInPara.ImageBytes)
        }
      }
    } else if (objInSec.DocumentObjectType == wasmModule.DocumentObjectType.Table) {
      let table = objInSec;
      for (let i = 0; i < table.Rows.Count; i++) {
        let row = table.Rows.get(i);
        for (let j = 0; j < row.Cells.Count; j++) {
          let cell = row.Cells.get(j);
          for (let k = 0; k < cell.Paragraphs.Count; k++) {
            let paragraph = cell.Paragraphs.get_Item(k);
            for (let a = 0; a < paragraph.ChildObjects.Count; a++) {
              let para = paragraph.ChildObjects.get(a);
              if (para.DocumentObjectType == wasmModule.DocumentObjectType.Picture) {
                images.push(para.ImageBytes)
              }
            }
          }
        }
      }
    }
  }
}
//save images
for (let i = 0; i < images.length; i++) {
  let outFile = "Image-" + i + ".png";
  const modifiedFile = new Blob([images[i]], { type: 'image/png'});
  downloadItems.value.push({
    name: outFile,
    url: URL.createObjectURL(modifiedFile)
  });
}

// Dispose of the document object to free resources
document.Dispose();
New feature Supports removing picture watermarks from Word documents.
//Create Word document.
let document = wasmModule.Document.Create();

//Load the file from disk.
document.LoadFromFile(inputFileName);

//Set the watermark as null to remove the text and image watermark.
document.Watermark = null;

// Save the document to the specified path
const outputFileName = "RemoveImageWatermark.docx";
document.SaveToFile({fileName: outputFileName,fileFormat: wasmModule.FileFormat.Docx2013});
New feature Supports removing text watermarks from Word documents.
//Create Word document.
let document = wasmModule.Document.Create();

//Load the file from disk.
document.LoadFromFile(inputFileName);

//Set the watermark as null to remove the text and image watermark.
document.Watermark = null;

// Save the document to the specified path
const outputFileName = "RemoveTextWatermark.docx";
document.SaveToFile({fileName: outputFileName,fileFormat: wasmModule.FileFormat.Docx2013});
New feature Supports setting document properties in Word documents.
//Create a document
let document = wasmModule.Document.Create();

//Load the document from disk.
document.LoadFromFile(inputFileName);

//Set the build-in Properties.
document.BuiltinDocumentProperties.Title = "Document Demo Document";
document.BuiltinDocumentProperties.Author = "James";
document.BuiltinDocumentProperties.Company = "e-iceblue";
document.BuiltinDocumentProperties.Keywords = "Document, Property, Demo";
document.BuiltinDocumentProperties.Comments = "This document is just a demo.";

//Set the custom properties.
let custom = document.CustomDocumentProperties;
custom.Add("e-iceblue", true);
custom.Add("Authorized By", "John Smith");
custom.Add("Authorized Date", wasmModule.DateTime.get_Today());
custom.Add("Age", 13);
custom.Add("price", 25.4);

// Save the document to the specified path
const outputFileName = "SetDocumentProperties.docx";
document.SaveToFile({ fileName: outputFileName, fileFormat: wasmModule.FileFormat.Docx2013 });
New feature Supports setting the gutter position in Word documents.
//Create Word document.
let document = wasmModule.Document.Create();

//Load the file from disk.
document.LoadFromFile(inputFileName);

//Create a new section
let section = document.Sections.get(0);

// Set the top gutter option to true for the section's page setup.
section.PageSetup.IsTopGutter = true;

// Set the width of the gutter in points (100f).
section.PageSetup.Gutter = 100;

// Save the document to the specified path
const outputFileName = "SetGutterPosition.docx";
document.SaveToFile({ fileName: outputFileName, fileFormat: wasmModule.FileFormat.Docx2013 });
Click the link below to download Spire.Doc for JavaScript 13.4.0: