2.1.1 • Published 6 years ago

print-splitter v2.1.1

Weekly downloads
1
License
ISC
Repository
github
Last release
6 years ago

print-splitter

Splits up a DOM node into a set of pages for printing

Why

Printing DOM Sucks, page breaks don't work half the time print-splitter chunks a target DOM node into page-sized bits.

Example

https://korynunn.github.io/print-splitter/test/

Usage

    var splitter = require('print-splitter');

    var pageHeight = 1102; // "paper" height, 1082px is around A4 height.
    var minimumSplitHight = 200; // Don't split elements smaller than 200px, push them to the next page.

    // Function to detect elements that should cause a page-break
    // Return an array of optionally `['before', 'after']`
    var shouldPageBrake = function(element){
        return (element.getAttribute('pageBreak') || '').split(' ');
    };

    var pages = splitter(
        document.querySelector('.page'),
        pageHeight,
        minimumSplitHight,
        {
            shouldPageBrake: shouldPageBrake
        }
    );

    // `pages` will be in the DOM before the targeted node.
2.1.1

6 years ago

2.1.0

6 years ago

2.0.0

6 years ago

1.1.0

6 years ago

1.0.0

6 years ago