Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

super-pdfkit

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

super-pdfkit

Enhanced pdfkit with some useful methods (thx to: pdfkit and pdfkit-table authors)

  • 0.0.2
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

super-pdfkit

Enhanced pdfkit with some useful methods (thx to: pdfkit and pdfkit-table authors)

Easy usage:

const PDF = require( 'super-pdfkit' );

const doc = new PDF( {
    margin: 50,

    // THIS ADDS PAGE NUMBER (ex.: 1/5)
    pageNum: true,
    // THIS ADDS A TEXT BEFORE PAGE NUMBER
    pageNumText: 'Page ',
    
    // THIS ADDS HEADER AND FOOTER
    header( thisDoc ) {
        thisDoc.textCenter( 'HEADER', 15 );
        thisDoc.imageCenter( 'header.png', 50 );
    },
    footer( thisDoc ) {
        thisDoc.textCenter( 'FOOTER', thisDoc.page.height - 40 );
    }
} );


// YOU CAN USE

doc.textCenter(                 // TO ADD A LEFT ALIGNED TEXT
    'LEFT ALIGNED TEXT',        // the text
    200                         // the y position
);
doc.textCenter(                 // TO ADD A CENTERED TEXT
    'CENTERED TEXT',            // the text
    200                         // the y position
);
doc.textRight(                  // TO ADD A RIGHT ALIGNED TEXT
    'RIGHT ALIGNED TEXT',       // the text
    200                         // the y position
);

doc.imageCenter(                // TO ADD A CENTERED IMAGE
    'image.png',                // the image
    100,                        // the image width
    230                         // the y position
);

doc.end();                      // TO END THE DOCUMENT

// OR

doc.end( thisDoc => {           // TO ADD SOME NOT PAGE-DIVISIBLE CONTENT BEFORE ENDING THE DOCUMENT (useful for signatures)

    thisDoc.text( 'ANY EDIT ON THE DOCUMENT' );
} );

// OR

doc.complete()                  // TO END THE DOCUMENT AND GET IT AS A BUFFER
.then( bufferData => console.log( bufferData ) );

// YOU CAN PASS THE SAME FINAL FUNCTION TO end() OR complete() METHODS REGARDLESS

Keywords

FAQs

Package last updated on 18 Aug 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc