Code Monkey home page Code Monkey logo

doctrack's Introduction

Doctrack

Actions Status Coverage

Library for injecting tracking (spy) pixel url into Office Documents (Office Open XML).

Support formats:

  • docx
  • docm
  • dotm
  • dotx
  • xlsx
  • xlsm
  • xltm
  • xltx
npm i doctrack -S

Example

import { DocTrack, Docx, Docm, Dotm, Dotx, Xlsx, Xlsm, Xltm, Xltx } from 'doctrack';

const inputFilePath = './input.docx';
const outputFilePath = './output.docx';
const trackingPixelUrl = 'http://localhost:5001/tracking';

// xlsx - new Xlsx, docm - new Docm and etc
const doctrack = new DocTrack(new Docx(inputFilePath), trackingPixelUrl);

// Write result document to file
await doctrack.writeResultToFile(outputFilePath);

After open result document (output.docx) with office editor will be requested url: http://localhost:5001/tracking.

Input data

You can pass input file as buffer, stream or file:

import fsPromise from 'node:fs/promises';

// As file
const doctrack = new DocTrack(new Docx('./input.docx'), trackingPixelUrl);

// As Buffer
const fileBuffer = await fsPromise.readFile('./input.docx');
const doctrack = new DocTrack(new Docx(fileBuffer), trackingPixelUrl);

// As Stream
const fileStream = fs.createReadStream('./input.docx');
const doctrack = new DocTrack(new Docx(fileStream), trackingPixelUrl);

Output data

You get result file as buffer, stream or file:

// Write result document to file
await doctrack.writeResultToFile('./output.docx');

// Write result document to buffer
const buffer = await doctrack.writeResultToBuffer();

// Write result document to stream
const stream = await doctrack.writeResultToStream();

doctrack's People

Contributors

dm-kamaev avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.