npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

node-livedocx

v0.0.5

Published

Generate PDF and Word documents from template, using node.js and the livedocx webservice

Downloads

47

Readme

Generate PDF using Word templates and node.js

Node-livedocx allows developers to generate documents by combining structured data from node.js with a template, created in a word processor. The resulting document can be saved as a PDF, DOCX, DOC or RTF file. The concept is the same as with mail-merge.

This library may be used as 'middleware': just pass a callback function. Any error in the generation process will be propagated as the first argument of the callback function. See example below.

Example

var fs = require('fs'), livedocx = require('livedocx'), options;

options = {
    template: fs.readFileSync('my_template.docx').toString('base64'),
    variables: {
        foo: 'bar',
        something: 'else'
        ...
    },
    ...
}

livedocx(options, function (err,  resultBuffer) {
    if (err) {
        return console.log('Something went wrong!', err);
    }
    fs.writeFile('result.pdf', resultBuffer);
});

Usage

Step 1: Sign up for an account

Before you can start using LiveDocx, you must first sign up for an account, see:

https://www.livedocx.com/user/account_registration.aspx

(250 free documents per day, see http://www.livedocx.com/pub/pricing for additional plans)

Step 2: Install node-livedocx.

run npm install node-livedocx

Step 3: Assign your options (username, password, template and variables) and your callback function.

The callback function receives any errors and a Buffer-object for the resulting document.

See example/index.js for a full example on how to set these variables properly

Step 4: Learn more

For more information on template options, see http://www.livedocx.com/pub/documentation/templates.aspx

For more information on the used web service, see http://www.livedocx.com/pub/documentation/api.aspx

Options

{
    username: 'my_username', // REQUIRED: your username @ http://www.livedocx.com/
    password: 'my_password', // REQUIRED: your password @ http://www.livedocx.com/
    template: 'SGVsbG8gV29ybGQ=......', // REQUIRED:  A base64 encoded string version of a binary file, see example/index.js for an example
    templateFormat: 'DOCX', // Default: DOCX. Describe the type of template used. May be one of DOCX, DOC, RTF
    resultFormat: 'PDF', // Default: PDF. Describe the type of result document. May be one of DOCX, DOC, RTF and PDF
    variables: {
        foo: 'bar', //all your document variables
        ...
    }
}

DISCLAIMER

The author is not in any way related to the Livedocx service or the company behind that service.