Skip to content

devsli/guess-paper-size

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Paper size detector

Build Status

Basic paper size detector.

Install

npm install guess-paper-size

Use

// import guess from 'guess-paper-size';
var guess = require('guess-paper-size');

var width = 210; // mm
var height = 297; // mm

var paper = guess(width, height);
if (paper) {
  console.log('Detected ' + paper.size + ' paper, ' + paper.layout);
}

Test me in your browser using RunKit!

Return value

When found, JavaScript object returned:

  • size - format name (e.g. Letter, A4, B3)
  • layout - landscape or portrait

When not found, return null

Known paper sizes

It's supposed to recognize all page sizes used by PDFKit:

  • International formats: 4A0; 2A0; A0...A10; B0...B10; C0...C10; RA0...RA4; SRA0...SRA4
  • US formats: Executive, Folio, Letter, Legal, Tabloid

Links