Skip to content

Latest commit

 

History

History
49 lines (36 loc) · 896 Bytes

README.md

File metadata and controls

49 lines (36 loc) · 896 Bytes

rv-test

Usage

  • In a Node.js REPL, start a websocket:
const WebSocket = require('ws');
let url = 'file:///path/to/built/glimmer/index.html'
let socket = new WebSocket.Server({
  perMessageDeflate: false,
  port: 8080
});
  • Load up a renderer:
const { Renderer } = require('render-vendor');
Renderer.load(url);
  • Find & render your page's HTML:
let page = Renderer.find(url);

page.render().then((data) => console.log(data));
  • Set a name & render to PDF:
socket.clients.forEach((ws) => ws.send(JSON.stringify({
  name: 'Ember Night'
})));

page.render({ filename: './rv-with-name.pdf' });
  • Set all data & render to PNG:
socket.clients.forEach((ws) => ws.send({
  name: 'Ember Night',
  body: '<img src="http://lorempixel.com/400/200">'
}));

page.render({ filename: './rv-with-img.png' });