Skip to content

Latest commit

 

History

History
142 lines (99 loc) · 4.68 KB

README.md

File metadata and controls

142 lines (99 loc) · 4.68 KB

simple-odf

simple-odf is a library for creating Open Document Format text files using Typescript/JavaScript and Node.js.

Build Status Version codecov Dependencies Known Vulnerabilities Standard - JavaScript Style Guide

Table of Contents

Getting Started

Prerequisites

Before you begin, make sure your development environment includes Node.js and an npm package manager.

Installing

Install simple-odf using npm:

npm install --save simple-odf

Create your first document.

const simpleOdf = require('simple-odf');

const document = new simpleOdf.TextDocument();
const body = document.getBody();

const image = body.addParagraph().addImage('/home/homer/myself.png');
image.setAnchorType(simpleOdf.AnchorType.AsChar);
image.setSize(29.4, 36.5);

body.addHeading('Welcome to simple-odf');

const p1 = body.addParagraph('The quick, brown fox jumps over a lazy dog.');
p1.addText('\nThe five boxing wizards jump quickly.\n\n');
p1.addHyperlink('Visit me', 'http://example.org/');
const style1 = new simpleOdf.ParagraphStyle();
// text formatting
style1.setColor(simpleOdf.Color.fromRgb(255, 0, 0));
style1.setFontSize(20);
style1.setTextTransformation(simpleOdf.TextTransformation.Uppercase);
style1.setTypeface(simpleOdf.Typeface.Bold);
// paragraph formatting
style1.setHorizontalAlignment(simpleOdf.HorizontalAlignment.Center);
style1.setPageBreak(simpleOdf.PageBreak.Before);
style1.setKeepTogether();
p1.setStyle(style1);
// font usage
document.getFontFaceDeclarations().create('Open Sans', 'Open Sans', simpleOdf.FontPitch.Variable);
const style2 = new simpleOdf.ParagraphStyle();
style2.setFontName('Open Sans');
const p2 = body.addParagraph('It always seems impossible until it\'s done.');
p2.setStyle(style2);

body.addHeading('Credits', 2);

body.addParagraph('This was quite easy. Do you want to know why?');

const list = body.addList();
list.addItem().addParagraph('one-liner setup');
list.addItem().addParagraph('just write like you would do in a full-blown editor');

document.saveFlat('/home/homer/My_first_document.fodf');

See the examples for more details on how to use the library.

Documentation

Learn more about the OASIS Open Document Format.

Contributing

If you want to contribute to simple-odf, you are very welcome. Send issues and pull requests with your ideas.

Pull Requests

Before submitting a pull request, please make sure the following is done...

  1. Fork the repo and create your branch from master. A guide on how to fork a repository: https://help.github.com/articles/fork-a-repo/

    Open terminal and type:

    git clone https://github.com/<your_username>/simple-odf
    cd simple-odf
    git checkout -b my_branch
  2. simple-odf uses npm for running development scripts. If you haven't already done so, please install npm.

  3. Run npm install.

    npm install
  4. If you've added code, add tests. You can use watch mode that continuously observes changed files to make your life easier.

    npm test -- --watch

Versioning

We use SemVer for versioning. For the versions available, see the tags on this repository.

Credits

This project exists thanks to all the contributors who participate in this project.

License

This project is licensed under the MIT License - see the LICENSE file for details.