1.0.4 • Published 8 years ago
guess-paper-size v1.0.4
Paper size detector
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
orportrait
When not found, return null
Known paper sizes
- ISO formats:
A0
...A10
;B0
...B10
;C0
...C10
- US formats: Letter, Legal, Tabloid
Links
- ISO 216 - Wikipedia
- Paper size - Wikipedia
- https://www.npmjs.com/package/paper-size - get paper dimensions by name