RtfGeneratorHelper.js

function createHeader() {
    return '{\\rtf1\\ansi';
}

function createFooter() {
    return '}';
}

function createLine(content) {
    return '{\\pard' + content + '\\par}';
}

function createLineBreak() {
    return '{\\pard '  + ' \\par}';
}

function setContent(content) {
    return ' ' + content + ' ';
}

function setBold(content) {
    return '\\b' + content;
}

function generate(lines) {
    var content = '';
    content += createHeader();
    lines.forEach(function (line, index) {
        content += line;
    });
    content += createFooter();

    return content;
}

module.exports = {
    createHeader: createHeader,
    createFooter: createFooter,
    createLine: createLine,
    createLineBreak: createLineBreak,
    setContent: setContent,
    setBold: setBold,
    generate: generate
};