GroupDocs.Watermark for Node.js via Java 24.3 Release Notes

We are thrilled to announce the groundbreaking first release of our product, now featuring seamless integration with Node.js via Java. This marks a significant milestone in our commitment to enhancing the versatility and performance of our platform. With the introduction of Node.js via Java, we are empowering Node.js developers to leverage the robust capabilities of our product, combining the strengths of both technologies for a more enriched and efficient development experience.

Full list of changes in this release

KeyCategorySummary
WATERMARKNODEJS-1★ FeatureIntroduced support for adding a text watermark to a document
WATERMARKNODEJS-2★ FeatureIntroduced support for adding an image watermark to a document
WATERMARKNODEJS-3★ FeatureIntroduce support for searching watermarks in the document
WATERMARKNODEJS-4★ FeatureAbility to get document information

Introduced support for adding a text watermark to a document

🌐 Node.js via Java api supports adding text watermarks to documents. Enhance your documents with customizable text overlays, providing a unique touch to your content.

const groupdocsWatermark = require('@groupdocs/groupdocs.watermark')

function addATextWatermark() {
  const documentPath = Constants.InDocumentPdf; // NOTE: Put the actual path for your document

  const watermarker = new groupdocsWatermark.Watermarker(documentPath);

  const watermark = new groupdocsWatermark.TextWatermark('top secret', new groupdocsWatermark.Font('Arial', 36));
  watermark.setForegroundColor(groupdocsWatermark.Color.getRed());
  watermark.setHorizontalAlignment(groupdocsWatermark.HorizontalAlignment.Center);
  watermark.setVerticalAlignment(groupdocsWatermark.VerticalAlignment.Center);

  watermarker.add(watermark);
  watermarker.save(outputFilePath);
  watermarker.close();
}

Introduced support for adding an image watermark to a document

🌐 Now, with Node.js, you can easily enhance your documents by adding image watermarks using our new feature

const groupdocsWatermark = require('@groupdocs/groupdocs.watermark')

function spreadsheetAddImageWatermarkIntoHeaderFooter() {
  const documentPath = Constants.InSpreadsheetXlsx; // NOTE: Put the actual path for your document

  // Create an instance of SpreadsheetLoadOptions
  const loadOptions = new groupdocsWatermark.SpreadsheetLoadOptions();

  // Create an instance of Watermarker
  const watermarker = new groupdocsWatermark.Watermarker(documentPath, loadOptions);

  // Create an instance of ImageWatermark
  const watermark = new groupdocsWatermark.ImageWatermark(Constants.LogoPng); // NOTE: Put the actual path for your image

  watermark.setVerticalAlignment(groupdocsWatermark.VerticalAlignment.Top);
  watermark.setHorizontalAlignment(groupdocsWatermark.HorizontalAlignment.Center);
  watermark.setSizingType(groupdocsWatermark.SizingType.ScaleToParentDimensions);
  watermark.setScaleFactor(1);

  // Create an instance of SpreadsheetWatermarkHeaderFooterOptions
  const options = new groupdocsWatermark.SpreadsheetWatermarkHeaderFooterOptions();
  options.setWorksheetIndex(0);

  // Add watermark to worksheet's header or footer
  watermarker.add(watermark, options);

  // Save changes
  watermarker.save(outputFilePath);

  // Close watermarker
  watermarker.close();
}

Introduce support for searching watermarks in the document

🌐 We’ve introduced support for searching watermarks within the document, making it easier for users to locate and manage their unique marks effortlessly.

const groupdocsWatermark = require('@groupdocs/groupdocs.watermark')

function searchWatermarkWithCombinedSearch() {
  const documentPath = Constants.InDocumentPdf; // NOTE: Put the actual path for your document

  // Create watermarker
  const watermarker = new groupdocsWatermark.Watermarker(documentPath);

  // Define image search criteria
  const imageSearchCriteria = new groupdocsWatermark.ImageDctHashSearchCriteria(Constants.LogoPng);
  imageSearchCriteria.setMaxDifference(0.9);

  // Define text search criteria
  const textSearchCriteria = new groupdocsWatermark.TextSearchCriteria("Company Name");

  // Define rotate angle search criteria
  const rotateAngleSearchCriteria = new groupdocsWatermark.RotateAngleSearchCriteria(30, 60);

  // Combine search criteria
  const combinedSearchCriteria = imageSearchCriteria.or(textSearchCriteria).and(rotateAngleSearchCriteria);

  // Search for possible watermarks
  const possibleWatermarks = watermarker.search(combinedSearchCriteria);

  // Output the results
  console.log(`Found ${possibleWatermarks.getCount()} possible watermark(s).`);

  // Close the watermarker
  watermarker.close();
}

Ability to get document information

const groupdocsWatermark = require('@groupdocs/groupdocs.watermark')

function getDocumentInfoForLocalFile() {
  const documentPath = Constants.InSourceDocx; // NOTE: Put the actual path for your document
  const watermarker = new groupdocsWatermark.Watermarker(documentPath);

  const documentInfo = watermarker.getDocumentInfo();
  console.log('File type:', documentInfo.getFileType().toString());
  console.log('Number of pages:', documentInfo.getPageCount());
  console.log('Document size:', documentInfo.getSize(), 'bytes');

  watermarker.close();
}