Have opinions about JavaScript? We want to hear them. Take the 2018 JavaScript Ecosystem Survey »

vivliostyle-print

0.1.3 • Public • Published

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. Make sure you serve the node_modules/vivliostyle/resources/ folder to the web.

  2. Use it within your project like this:

import {vivliostylePrint} 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>`,
    title = 'my printed page',
    resourcesUrl = '/node_modules/vivliostyle/resources/'
 
vivliostylePrint(htmlDoc, title, resourcesUrl)
 

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?

Vivliostyle is somewhat complex to get to work but it gives many more options. Vivliostyle-print only gives you what is essential to print within a browser, and it's easier to use. Also, Vivliostyle-print only works until the print dialog has executed and leaves no artifacts behind. You don't need to worry about cleaning up.

What implications does the AGPL license have?

To be entirely sure, check with a lawyer. In just about all cases, you need to share any modifications you have done to Vivliostyle or Vivliostyle-print itself.

Given that it is only initiated from your other program and you are nor processing the output from Vivliostyle-print, my reading of the AGPL is that it is not part of your program and you are not obliged to fulfill the terms of the AGPL when it comes to the code of your own program. But I am not a lawyer. If you know a lawyer who can check this further, please do so and let me know what you arrived at.

install

npm i vivliostyle-print

Downloadsweekly downloads

32

version

0.1.3

license

AGPL-3.0

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
Report a vulnerability