Skip to content
master
Go to file
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
src
 
 
 
 
 
 
 
 
 
 
 
 

README.md

vivliostyle-print

Allows page-layouting using the vivliostyle for printing within a website without destroying the original layout

How do I use it?

  1. Install vivliostyle-print like this within your browser-based JavaScript project:
npm install @vivliostyle/print --save
  1. Use it within your project like this:
import {printHTML} from '@vivliostyle/print'

const htmlDoc = `<!doctype html>
<html>
    <head>
        <style>
        ... Add your CSS code here ...
        </style>
    </head>
    <body>
        ... Add your HTML code here ...
    </body>
</html>`,
    config = {
        title: 'my printed page',
        printCallback: iframeWin => iframeWin.print() // optional: only needed if calling something other than window.print() for printing.
    }

printHTML(htmlDoc, config)

You can also take a look at the demo (sourcecode) .

How do I build and run the demo?

  1. Download the repo to your local machine, for example using::
git clone https://github.com/vivliostyle/vivliostyle-print.git
  1. Enter the folder::
cd vivliostyle-print
  1. Install and build it::
npm install
npm run build_demo
  1. Serve the demo folder, for example using the simple PHP webserver::
php -S localhost:8000 -t demo/
  1. Access the demo from a web browser by navigating to http://localhost:8000

Why would I use this rather than regular Vivliostyle?

On larger projects, it can be difficult to ensure that no developer is accidentally breaking the terms of the Vivliostyle AGPL license. Vivliostyle-print only exposes one of the functions of Vivliostyle that does not allow the sharing of complex data structures between surrounding code and Vivliostyle, which is the most important requirements to follow when using VIvliostyle in combination with a non-open source project. For more information cocnerning the license, read this.

Please report any bugs and open pull requests on the Vivliostyle main repo.

About

πŸ–¨ Use Vivliostyle for printing

Topics

Resources

License

Sponsor this project