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.10
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

super-pdfkit

Enhanced pdfkit with some useful methods (thx to: pdfkit, pdfkit-table and textbox-for-pdfkit 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', { width: 50 } );
    },
    footer( thisDoc ) {
        thisDoc.textCenter( 'FOOTER', thisDoc.page.height - 40 );
    }
} );


// YOU CAN USE

doc.textLeft(                           // TO ADD A LEFT ALIGNED TEXT
    'LEFT ALIGNED TEXT',                // the text
    200,                                // the y position OR options
    { width: 100 }                      // the options
)
.marginRight( 70 )
.textRight( 'RIGHT ALIGNED TEXT' );
.textCenter( 'CENTERED TEXT' )
.marginRight( 50 )
.textBox(
    [
        'My favourite color is ',
        { text: 'red', color: 'red' }
    ],
    { align: 'right' }
)
.imageCenter(                        // TO ADD A CENTERED IMAGE
    'image.png',                        // the image
    300,                                // the y position OR options
    100                                 // the image width OR options
);

doc.marginedWidth();                    // TO GET doc.page.width - ( doc.page.margins.left + doc.page.margins.right )

const marginLeft = doc.marginLeft();    // TO GET doc.page.margins.left VALUE

doc.marginLeft( marginLeft );           // TO SET doc.page.margins.left VALUE (it returns doc)

// TO FINISH YOU CAN USE...

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

// OR

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

    // A TOO LONG CONTENT FOR THE REST OF CURRENT PAGE

    for ( let i = 0; i < 40; i++ ) {
        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

Show the example!

Keywords

FAQs

Package last updated on 21 Sep 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