Commit 350d5df4 authored by Fred Chasen's avatar Fred Chasen

Added remaining files

parent 12124c88
{
"presets": ["es2015"],
"plugins": [
"add-module-exports"
]
}
\ No newline at end of file
.DS_Store
*.log
src
test
\ No newline at end of file
#!/usr/bin/env node
var Renderer = require("./lib/index.js");
var program = require('commander');
var path = require('path');
program
.version('0.0.1')
.arguments('[inputPath]')
.option('-i, --inputs [inputs]', 'Inputs')
.option('-o, --output [output]', 'Output')
// .option('-d, --debug', 'Debug')
.option('-l, --landscape', 'Landscape priting', false)
.option('-s, --page-size [size]', 'Print to Page Size [size]')
.option('-w, --width [size]', 'Print to Page Width [width]')
.option('-h --height [size]', 'Print to Page Height [weight]')
.option('-m, --page-margin [margin]', 'Print with margin [margin]')
.parse(process.argv);
var input = program.inputs || program.args[0];
var output = program.output || './' + path.basename(input).replace('.xhtml', '.pdf').replace('.html', '.pdf');
var renderer = new Renderer(input, output, {
pageSize: program.pageSize,
margin: program.pageMargin,
landscape: program.landscape,
width: program.width,
height: program.height
});
const gulp = require('gulp');
const babel = require('gulp-babel');
gulp.task('build', () => {
return gulp.src('src/*.js')
.pipe(babel({
presets: ['es2015'],
"plugins": [
"add-module-exports"
]
}))
.on('error', console.error.bind(console))
.pipe(gulp.dest('lib'));
});
gulp.task('watch', () => {
gulp.watch('src/*.js', ['build']);
});
gulp.task('default', ['build']);
\ No newline at end of file
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
var _electronHtmlTo = require('electron-html-to');
var _electronHtmlTo2 = _interopRequireDefault(_electronHtmlTo);
var _fs = require('fs');
var _fs2 = _interopRequireDefault(_fs);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var conversion = (0, _electronHtmlTo2.default)({
converterPath: _electronHtmlTo2.default.converters.PDF,
allowLocalFilesAccess: true,
timeout: 60000 * 5, // Allow five minutes to process
strategy: 'electron-ipc' // 'electron-ipc | electron-server | dedicated-process'
});
function Renderer(inputPath, outputPath, _options, cb) {
var directoryUrl = 'file://' + __dirname.replace('lib', '');
var baseUrl = directoryUrl + 'renderer/renderer.html?url=';
var options = _options || {};
var settings = {
pageSize: options.pageSize || 'A4',
pageMargin: options.pageMargin || 0,
landscape: options.landscape || false,
width: options.width,
height: options.height
};
var url = baseUrl + encodeURIComponent(inputPath);
var size = settings.pageSize;
if (settings.width && settings.height) {
url += '&width=' + settings.width;
url += '&height=' + settings.height;
size = {
width: parseFloat(settings.width) * 25400,
height: parseFloat(settings.height) * 25400
};
console.log(size);
} else {
url += '&pageSize=' + settings.pageSize;
}
if (settings.landscape) {
url += '&landscape=' + settings.landscape;
}
console.log("Processing", inputPath, url);
conversion({
url: url,
waitForJS: true,
pdf: {
marginsType: settings.pageMargin,
pageSize: {
width: 9 * 25400,
height: 2 * 25400
},
printBackground: true,
landscape: settings.landscape
}
}, function (err, result) {
if (err) {
conversion.kill();
return console.error(err);
}
console.log("Printed", result.numberOfPages, 'pages to', outputPath);
result.stream.pipe(_fs2.default.createWriteStream(outputPath));
conversion.kill();
cb && cb();
});
}
exports.default = Renderer;
module.exports = exports['default'];
\ No newline at end of file
{
"name": "vivliostyle-electron",
"version": "0.0.1",
"description": "Render Html to PDFs using Vivliostyle.js and Electron",
"main": "lib/index.js",
"scripts": {
"clean": "rimraf lib",
"build": "babel src --out-dir lib",
"lint": "eslint src test",
"test": "mocha test/test.js --timeout 8000",
"start": "node lib/index.js"
},
"bin": {
"vivliostyle-electron": "./cli.js"
},
"author": "Coko Foundation",
"license": "MIT",
"dependencies": {
"babel": "^6.5.2",
"commander": "^2.9.0",
"debug": "^2.2.0",
"electron-html-to": "^2.1.1",
"electron-prebuilt": "^1.3.5",
"eslint": "^3.4.0",
"mocha": "^3.0.2",
"vivliostyle": "^2016.7.0"
},
"devDependencies": {
"babel-plugin-add-module-exports": "^0.2.1",
"babel-preset-es2015": "^6.14.0",
"gulp": "^3.9.1",
"gulp-babel": "^6.1.2"
}
}
@charset "UTF-8";
@font-face {
font-family: "FontAwesome";
src: url("../fonts/fontawesome-webfont.eot");
src: url("../fonts/fontawesome-webfont.eot?#iefix") format("embedded-opentype"), url("../fonts/fontawesome-webfont.woff") format("woff"), url("../fonts/fontawesome-webfont.ttf") format("truetype"), url("../fonts/fontawesome-webfont.svg#fontawesomeregular") format("svg");
font-weight: normal;
font-style: normal;
}
#vivliostyle-page-navigation-up,
#vivliostyle-page-navigation-down,
#vivliostyle-page-navigation-left,
#vivliostyle-page-navigation-right {
position: absolute;
margin: 0;
color: transparent;
background: transparent;
cursor: pointer;
z-index: 1000;
color: rgba(255, 255, 255, 0);
background: transparent;
}
#vivliostyle-page-navigation-up.vivliostyle-menu-enabled,
#vivliostyle-page-navigation-down.vivliostyle-menu-enabled,
#vivliostyle-page-navigation-left.vivliostyle-menu-enabled,
#vivliostyle-page-navigation-right.vivliostyle-menu-enabled {
color: rgba(0, 0, 0, 0.5);
background: transparent;
-moz-transition: ease-out 0.25s;
-o-transition: ease-out 0.25s;
-webkit-transition: ease-out 0.25s;
transition: ease-out 0.25s;
}
#vivliostyle-page-navigation-up[data-vivliostyle-ui-state="attention"],
#vivliostyle-page-navigation-down[data-vivliostyle-ui-state="attention"],
#vivliostyle-page-navigation-left[data-vivliostyle-ui-state="attention"],
#vivliostyle-page-navigation-right[data-vivliostyle-ui-state="attention"] {
color: rgba(255, 255, 255, 0.75);
background: rgba(0, 0, 0, 0.25);
-moz-transition: ease-in 0.25s;
-o-transition: ease-in 0.25s;
-webkit-transition: ease-in 0.25s;
transition: ease-in 0.25s;
}
#vivliostyle-page-navigation-up:hover,
#vivliostyle-page-navigation-down:hover,
#vivliostyle-page-navigation-left:hover,
#vivliostyle-page-navigation-right:hover {
color: rgba(255, 255, 255, 0.75);
background: rgba(0, 0, 0, 0.25);
-moz-transition: linear 0.1s !important;
-o-transition: linear 0.1s !important;
-webkit-transition: linear 0.1s !important;
transition: linear 0.1s !important;
}
#vivliostyle-page-navigation-up:active,
#vivliostyle-page-navigation-down:active,
#vivliostyle-page-navigation-left:active,
#vivliostyle-page-navigation-right:active {
color: white;
background: rgba(0, 0, 0, 0.5);
-moz-transition: linear 0.1s !important;
-o-transition: linear 0.1s !important;
-webkit-transition: linear 0.1s !important;
transition: linear 0.1s !important;
}
#vivliostyle-page-navigation-up:after,
#vivliostyle-page-navigation-down:after,
#vivliostyle-page-navigation-left:after,
#vivliostyle-page-navigation-right:after {
-moz-box-sizing: content-box;
-webkit-box-sizing: content-box;
box-sizing: content-box;
display: block;
position: absolute;
left: 0;
top: 0;
right: 0;
bottom: 0;
margin: auto;
border-radius: 50%;
width: 21.6px;
height: 21.6px;
font-size: 23.04px;
line-height: 1;
text-align: center;
vertical-align: middle;
font-family: "FontAwesome";
font-style: normal;
font-weight: normal;
font-variant: normal;
text-transform: none;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
speak: none;
}
#vivliostyle-page-navigation-up,
#vivliostyle-page-navigation-down {
left: 0;
right: 0;
width: 100%;
height: 36px;
}
#vivliostyle-page-navigation-up {
top: 0;
}
#vivliostyle-page-navigation-up:after {
content: "";
}
#vivliostyle-page-navigation-up:hover {
cursor: n-resize;
}
#vivliostyle-page-navigation-down {
bottom: 0;
cursor: s-resize;
}
#vivliostyle-page-navigation-down:after {
content: "";
}
#vivliostyle-page-navigation-left,
#vivliostyle-page-navigation-right {
top: 0;
bottom: 0;
width: 36px;
height: 100%;
}
#vivliostyle-page-navigation-left {
left: 0;
cursor: w-resize;
}
#vivliostyle-page-navigation-left:after {
content: "";
}
#vivliostyle-page-navigation-right {
right: 0;
cursor: e-resize;
}
#vivliostyle-page-navigation-right:after {
content: "";
text-indent: .125em;
}
This diff is collapsed.
@charset "UTF-8";
@font-face {
font-family: "FontAwesome";
src: url("../fonts/fontawesome-webfont.eot");
src: url("../fonts/fontawesome-webfont.eot?#iefix") format("embedded-opentype"), url("../fonts/fontawesome-webfont.woff") format("woff"), url("../fonts/fontawesome-webfont.ttf") format("truetype"), url("../fonts/fontawesome-webfont.svg#fontawesomeregular") format("svg");
font-weight: normal;
font-style: normal;
}
#vivliostyle-message-dialog {
box-sizing: border-box;
overflow: auto;
overflow-x: hidden;
overflow-y: auto;
position: fixed;
z-index: 7777777;
top: -100%;
left: 0;
right: 0;
margin: auto;
padding: calc(0.375em + 36px) 18px 0.25em;
border-radius: 0 0 4px 4px;
max-width: 800px;
width: calc(100vw - (36px * 0.5));
max-height: calc(100vh - (36px * 0.25));
font-size: 14px;
background: white;
opacity: 0;
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
transition: 1s ease;
}
#vivliostyle-message-dialog.vivliostyle-message-dialog-shown {
top: 0;
opacity: 1;
}
#vivliostyle-message-dialog .vivliostyle-message {
padding: .75em 0;
border-top: solid 1px #e8e8e8;
}
#vivliostyle-message-dialog .vivliostyle-message:first-child {
border-top: none 0;
}
#vivliostyle-message-dialog .vivliostyle-message p {
position: relative;
margin: 0;
padding-left: 1.5em;
font-family: "游ゴシック", "Yu Gothic", "YuGothic", "ヒラギノ角ゴ ProN W3", "HiraKakuProN-W3", "ヒラギノ角ゴ Pro W3", "HiraKakuPro-W3", "メイリオ", "Meiryo", "MS ゴシック", "MS Gothic", sans-serif;
line-height: 1.25;
color: #202020;
}
#vivliostyle-message-dialog .vivliostyle-message p:before {
font-family: "FontAwesome";
font-style: normal;
font-weight: normal;
font-variant: normal;
text-transform: none;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
speak: none;
display: inline-block;
position: absolute;
left: .25em;
top: 0;
}
#vivliostyle-message-dialog .vivliostyle-message p.error {
color: #d82000;
}
#vivliostyle-message-dialog .vivliostyle-message p.error:before {
content: "";
}
#vivliostyle-message-dialog .vivliostyle-message p.warn {
color: #c08000;
}
#vivliostyle-message-dialog .vivliostyle-message p.warn:before {
content: "";
}
#vivliostyle-message-dialog .vivliostyle-message p.info {
color: #0060c0;
}
#vivliostyle-message-dialog .vivliostyle-message p.info:before {
content: "";
}
#vivliostyle-message-dialog .vivliostyle-message p.debug {
color: #404040;
}
#vivliostyle-message-dialog .vivliostyle-message p.debug:before {
content: "";
}
/*
* Copyright 2015 Vivliostyle Inc.
*/
html[data-vivliostyle-paginated], html[data-vivliostyle-paginated] body {
margin: 0;
padding: 0;
}
@media print {
html[data-vivliostyle-paginated] {
height: 100%;
width: 100%;
}
html[data-vivliostyle-paginated] body > * {
display: none;
}
html[data-vivliostyle-paginated] [data-vivliostyle-viewer-viewport] {
display: block;
}
html[data-vivliostyle-paginated] body, html[data-vivliostyle-paginated] [data-vivliostyle-viewer-viewport] {
width: 100% !important;
height: 100% !important;
}
}
@media screen {
html[data-vivliostyle-paginated] body {
position: absolute;
top: 0;
left: 0;
}
}
<!DOCTYPE html>
<html data-vivliostyle-paginated="true">
<head>
<meta charset="utf-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<meta name="apple-mobile-web-app-capable" content="yes"/>
<meta name="google" content="notranslate">
<title>Vivliostyle.js Renderer</title>
<!-- <script src="resources/mathjax-config.js"></script>
<script src="https://cdn.mathjax.org/mathjax/2.6-latest/MathJax.js?config=TeX-MML-AM_CHTML"></script> -->
<script src="../node_modules/vivliostyle/lib/vivliostyle.min.js"></script>
<link rel="stylesheet" href="resources/vivliostyle-viewport.css"/>
<link rel="stylesheet" href="css/vivliostyle-viewer.css"/>
<style id="vivliostyle-page-rules"></style>
</head>
<body data-vivliostyle-viewer-status="loading">
<div id="vivliostyle-viewer-viewport"></div>
<script>
var viewerSettings = {
userAgentRootURL: "resources/",
viewportElement: document.getElementById("vivliostyle-viewer-viewport"),
debug: true
};
var viewerOptions = {
fontSize: 16,
profile: false,
spreadView: false,
zoom: 1
};
var documentOptions = {
userStyleSheet:[{ text: "@page { size: A4; }" }]
};
var search = window.location.search;
var settings = {};
var parameters;
// Overide options with search parameters
if(search) {
parameters = search.slice(1).split("&");
parameters.forEach(function(p){
var split = p.split("=");
var name = split[0];
var value = split[1] || '';
var parsedValue = decodeURIComponent(value);
if (parsedValue === "true") {
parsedValue = true;
}
if (parsedValue === "false") {
parsedValue = false;
}
settings[name] = parsedValue;
});
}
var viewer = new vivliostyle.viewer.Viewer(viewerSettings, viewerOptions);
viewer.addListener("loaded", function() {
console.log("Loaded");
window.ELECTRON_HTML_TO_READY = true; // this will start the conversion
});
if (settings.width && settings.height) {
documentOptions.userStyleSheet[0].text = "@page { size: "+settings.width+" "+settings.height+"; }";
} else if (settings.pageSize && settings.landscape) {
documentOptions.userStyleSheet[0].text = "@page { size: "+settings.pageSize+" landscape; }";
} else if (settings.pageSize) {
documentOptions.userStyleSheet[0].text = "@page { size: "+settings.pageSize+"; }";
}
console.log(documentOptions);
viewer.loadDocument(settings.url, documentOptions, viewerOptions);
</script>
</body>
</html>
/*
* Copyright 2015 Vivliostyle Inc.
*/
window.MathJax = {
showProcessingMessages: false,
messageStyle: "none",
skipStartupTypeset: true,
CommonHTML: {
scale: 90,
linebreaks: {
automatic: true
},
styles: {
".MJXc-display": {
margin: "0"
}
}
},
"fast-preview": {
disabled: true
},
AuthorInit: function() {
MathJax.Hub.processSectionDelay = 0;
}
};
This diff is collapsed.
@namespace html "http://www.w3.org/1999/xhtml";
@namespace fb2 "http://www.gribuser.ru/xml/fictionbook/2.0";
html|body, fb2|body {
-epub-hyphens: -epubx-expr(pref-hyphenate?"auto":"manual");
}
@-adapt-footnote-area {
-adapt-margin-before: 0.5em;
-adapt-margin-after: 0.5em;
}
@-adapt-footnote-area ::before {
display: block;
-adapt-border-before-width: 1px;
-adapt-border-before-style: solid;
-adapt-border-before-color: black;
-adapt-margin-after: 0.4em;
-adapt-margin-start: 0;
-adapt-margin-end: 60%;
}
/* default page master */
@-epubx-page-master :background-host {
@-epubx-partition :layout-host {
-epubx-flow-from: body;
top: -epubx-expr(header.margin-bottom-edge);
bottom: -epubx-expr(page-height - footer.margin-top-edge);
left: 0px;
right: 0px;
column-width: 25em;
}
@-epubx-partition footer :oeb-page-foot {
-epub-writing-mode: horizontal-tb;
-epubx-flow-from: oeb-page-foot;
bottom: 0px;
left: 0px;
right: 0px;
}
@-epubx-partition header :oeb-page-head {
-epub-writing-mode: horizontal-tb;
-epubx-flow-from: oeb-page-head;
top: 0px;
left: 0px;
right: 0px;
}
}
@page {
@top-left-corner {
text-align: right;
vertical-align: middle;
}
@top-left {
text-align: left;
vertical-align: middle;
}
@top-center {
text-align: center;
vertical-align: middle;
}
@top-right {
text-align: right;
vertical-align: middle;
}
@top-right-corner {
text-align: left;
vertical-align: middle;
}
@left-top {
text-align: center;
vertical-align: top;
}
@left-middle {
text-align: center;
vertical-align: middle;
}
@left-bottom {
text-align: center;
vertical-align: bottom;
}
@right-top {
text-align: center;
vertical-align: top;
}
@right-middle {
text-align: center;
vertical-align: middle;
}
@right-bottom {
text-align: center;
vertical-align: bottom;
}
@bottom-left-corner {
text-align: right;
vertical-align: middle;
}
@bottom-left {
text-align: left;
vertical-align: middle;
}
@bottom-center {
text-align: center;
vertical-align: middle;
}
@bottom-right {
text-align: right;
vertical-align: middle;
}
@bottom-right-corner {
text-align: left;
vertical-align: middle;
}
}
@media print {
@page {
margin: 10%;
}
}
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:s="http://www.pyroxy.com/ns/shadow">
<head>
<style><![CDATA[
.footnote-content {
float: footnote;
}
]]></style>
</head>
<body>
<s:template id="footnote"><s:content/><s:include class="footnote-content"/></s:template>
</body>
</html>
\ No newline at end of file
This diff is collapsed.
/*
* Copyright 2015 Vivliostyle Inc.
*/
[data-vivliostyle-page-container] {
position: relative;