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

libof-doc

v1.2.5

Published

Library for generating odt and doc documents for JavaScript

Downloads

240

Readme

Libof Doc

Library for generating odt and doc documents for JavaScript and TypeScript

Installation

You can install the library via npm:

npm install libof-doc

Usage

Create new document

import { LibofDocument } from 'libof-doc';

const document = new LibofDocument("testDocument");

Titles

import {Lh1, Lh2, Lh3, Lh4} from 'libof-doc'

document.addElement(new Lh1("1 - Title", '#7da6fd'))
document.addElement(new Lh2("1.1 - Title", '#000000', '#7da6fd', 'Serif'))
document.addElement(new Lh3("1.1.1 - Title"))
document.addElement(new Lh4("1.1.1.1 - Title"))

// #000000 => text color
// #7da6fd => background color
// Serif => font

IMPORTANT: All components have the color, background color and font properties.

Text

import {LParagraph, LTextItalic, LTextBold, LText, lWhiteSpace, lLineBreak} from 'libof-doc'

const p1 = new LParagraph()

p1.addText(new LText("Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation"))

p1.addText(new LTextBold('Text bold'))

p1.addText(new LTextItalic('Text italic'))

document.addElement(p1)

Lists

import {LOrderedList, LUnorderedList} from 'libof-doc'

//Simple list
const p2 = new LParagraph()
p2.addText(new LText("List element"))

const elementList = [
    p2, p2, p2, p2
]
document.addElement(new LOrderedList(elementList))
document.addElement(new LUnorderedList(elementList))

//Concatenated lists
const concatList = [
    p2, p2, p2, p2,
new LUnorderedList(elementList)
]
document.addElement(new LUnorderedList(concatList))

Tables

import {LTable, LTableElement, LTableRow} from 'libof-doc'

const table = new LTable()

const p3 = new LParagraph()
p3.addText(new LTextBold('Table Title'))

const p4 = new LParagraph()
p4.addText(new LText('Table Element'))
  
const tableRow1 = new LTableRow([
    new LTableElement(p3, 5, 1, null, null,'#000000', '#7da6fd'),
    new LTableElement(p3, 5, 1, null, null,'#000000', '#7da6fd'),
    new LTableElement(p3, 5, 1, null, null,'#000000', '#7da6fd'),
    new LTableElement(p3, 5, 1, null, null,'#000000', '#7da6fd'),
])

const tableRow2 = new LTableRow([
    new LTableElement(p4, 5, 2),
    new LTableElement(p4, 5, 2),
    new LTableElement(p4, 5, 2),
    //This element has rowspan
    new LTableElement(p4, 5, 2, null, 2),
])

const tableRow3 = new LTableRow([
    //This element has colspan
    new LTableElement(p4, 5, 2, 2),
    new LTableElement(p4, 5, 2),
])

table.addRow(tableRow1)
table.addRow(tableRow2)
table.addRow(tableRow3)

document.addElement(table)

Images

import {LImage} from 'libof-doc'

//Images with PageBreaks
document.addPageBreak()
document.addElement(new LImage(imageBase64, 100, 100))

Download Document

You can transform the document into a blob or download it directly:

//you can transform the document into a blob 
const blob = await document.documentToBlob() //ODT 
const docxBlob = await document.documentToDocxBlob() //DOCX

//or you cat download the document 
await document.download() //ODT
await document.downloadAsDOCX() //DOCX

Generate Indexes

You can generate indexes in your document

document.generateIndex()

Add Front Pages

const frontPage = new LFrontPage()
frontPage.addElement(new Lh1("Main title"))

document.addFrontPage(frontPage)

HTML

You can insert HTML content into your document :)

import {LHtml} from 'libof-doc'

const html = new LHtml('<p>this text is written in html using <b>Libof doc</b></p>')
document.addElement(html)

Viewing the document

Content

image

Image

image

Index

image

Front Page

image