GroupDocs.Viewer for Node.js via Java 23.10 Release Notes

There are 2 new improvements in this release.

Full list of changes in this release

KeyCategorySummary
VIEWERNODEJS‑56ImprovementSimplify public API to process documents from a stream.
VIEWERNODEJS‑57ImprovementSimplify public API to avoid manual Java classes instantiation.

Major features

Processing documents from stream simplified

Product public API provides the readDataFromStream method to process documents from a stream.

The following code snippet shows the method implementation and usage example:

exports.readDataFromStream = function (readStream) {

  return new Promise((resolve, reject) => {
    const inputStreamBuffer = new exports.StreamBuffer()
    readStream.on('data', chunk => {
      inputStreamBuffer.write(chunk)
    })
    readStream.on('end', () => {
      try {
        resolve(inputStreamBuffer.toInputStream())
      } catch (err) {
        reject(err);
      }
    });
  });
}

The following code snippet shows how to set the product license provided as a stream:

const fs = require('fs')
async function setLicenseFromStream(groupdocs, licensePath) {
    const license = new groupdocs.viewer.License()
    const licenseStream = fs.createReadStream(licensePath)

    const stream = await groupdocs.viewer.readDataFromStream(licenseStream)    
    await license.setLicense(stream);
}
module.exports = setLicenseFromStream

The following code snippet shows how to view a source file provided as a stream:

const fs = require("fs");
async function loadDocumentFromStream(groupdocs, inputFilePath) {
  
    const outputPath = `page_{0}.html`;

    const readStream = fs.createReadStream(inputFilePath)
    const stream = await groupdocs.viewer.readDataFromStream(readStream)

    const viewer = new groupdocs.viewer.Viewer(stream);    
    const viewOptions = groupdocs.viewer.HtmlViewOptions.forEmbeddedResources(`page_{0}.html`);

    return viewer.view(viewOptions)
}

module.exports = loadDocumentFromStream;

Public API and backward incompatible changes

None