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

pdf-lib-table

v1.1.7

Published

table creation add on for pdf-lib

Downloads

44

Readme

a library for creating tables using pdf-lib

currently a work in progress and subject to change.

Demo -> pdf-lib-table

Basic Usage

Define Columns:

    const columns = [
        {
            columnId:'header1',
            header: 'Header One',
        },
        {
            columnId:'header2',
            header: 'Header Two',
        },
        {
            columnId:'header3',
            header: 'Header Three',
        },
        {
            columnId:'header4',
            header: 'Header Four',
        }
    ]

build data:

    const data = [
        {
            header1: 'row1Column1',
            header2: 'row1Column2',
            header3: 'row1Column3',
            header4: 'row1Column4',
        },
        {
            header1: 'row2Column1',
            header2: 'row2Column2',
            header3: 'row2Column3',
            header4: 'row2Column4',
        },
        {
            header1: 'row3Column1',
            header2: 'row3Column2',
            header3: 'row3Column3',
            header4: 'row3Column4',
        },
        {
            header1: 'row4Column1',
            header2: 'row4Column2',
            header3: 'row4Column3',
            header4: 'row4Column4',
        },
    ]

Draw Table:

drawTable({
    data,                       // Required - No Default - data t be printed
    page,                       // Required - No Default - page provided by pdf-lib
    pdfDoc,                     // Required - No Default - pdfDoc that the table will be printed on
    columns,                    // Required - No Default - column definitions
    //TABLE SETTINGS
    startingX,                  // Default 0 - Default 0 - the starting x coordinate
    startingY,                  // Default 0 - the starting y coordinate
    tableType,                  // Default 'vertical' - Options: vertical || horizontal || 2way TODO: horizontal || 2way not suported yet
    dividedX,                   // Default true - sets if the table has x dividers
    dividedY,                   // Default true - sets if the table has y dividers
    dividedXColor,              // Default rgb(0,0,0) - can pass in any pdf-lib rgb value
    dividedYColor,              // Default rgb(0,0,0) - can pass in any pdf-lib rgb value
    dividedXThickness,          // Default 1 - sets x divider thickness
    dividedYThickness,          // Default 1 - sets y divider thickness
    maxTableWidth,              // Default false - table is defaulted to page width but a max value can be passed
    maxTableHeight,             // Default false - table is defaulted to page height but a max value can be passed
    rowHeightSizing,            // Default 'auto' //TODO: remove this.
    tableBoarder,               // Default true - tables have a boader by default but it can be removed by passing false
    tableBoarderThickness,      // Default 1 - sets the thickness of the table boarder
    tableBoarderColor,          // Default rgb(0,0,0) - can pass in any pdf-lib rgb value
    rounded,                    //TODO: add or remove this option. Currently not supported
    customContinuesOnNextPage,  // Default false - can pass a function for what to draw
    smPageFiller,               // Default false - can pass a function for what to draw TODO: Currently not supported
    mdPageFiller,               // Default false - can pass a function for what to draw TODO: Currently not supported
    lgPageFiller,               // Default false - can pass a function for what to draw TODO: Currently not supported
    //SUB HEADINGS TODO: not suported yet
    subHeadingBackgroundColor,  //TODO: Currently not supported
    subHeadingHeight,           //TODO: Currently not supported
    subHeadingFont,             //TODO: Currently not supported
    subHeadingTextColor,        //TODO: Currently not supported
    subHeadingTextSize,         //TODO: Currently not supported
    //HEADER SETTINGS
    headerFont,                 // Required -  No Default - any pdflib standard font
    headerDividedX,             // Default true - sets if the table header has x dividers
    headerDividedY,             // Default true - sets if the table header has y divider
    headerDividedXColor,        // Default rgb(0,0,0) - can pass in any pdf-lib rgb value
    headerDividedYColor,        // Default rgb(0,0,0) - can pass in any pdf-lib rgb value
    headerDividedXThickness,    // Default 1 - sets the thickness of the table header x divider
    headerDividedYThickness,    // Default 1 - sets the thickness of the table header y divider
    headerBackgroundColor,      // Default - rgb(.03, .03, .03) - can pass in any pdf-lib rgb value
    headerHeight,               // Default 10 - height of the table header
    headerTextColor,            // Default rgb(0,0,0) - can pass in any pdf-lib rgb value
    headerTextSize,             // Default 10 - table header text size
    headerTextAlignment,        // Default 'left' - left/right/center 
    headerWrapText,             // Default false - allows text in the header to wrap
    //CELL SETTINGS
    cellFont,                   // Required -  No Default - any pdflib standard font
    cellBackgroundColor,        //rgb(1, 1, 1) - can pass in any pdf-lib rgb value
    alternateRowColor,          // Default true - cell rows will alternate background color
    alternateCellColor,         //rgb(.03, .03, .03) - can pass in any pdf-lib rgb value
    cellTextSize,               // Default 10 - cell text size
    cellTextColor,              // Default rgb(0,0,0) - can pass in any pdf-lib rgb value
});