Commit 7611dd39 authored by Fred Chasen's avatar Fred Chasen

Add debug option

parent 350d5df4
......@@ -9,7 +9,7 @@ program
.arguments('[inputPath]')
.option('-i, --inputs [inputs]', 'Inputs')
.option('-o, --output [output]', 'Output')
// .option('-d, --debug', 'Debug')
.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]')
......@@ -25,5 +25,6 @@ var renderer = new Renderer(input, output, {
margin: program.pageMargin,
landscape: program.landscape,
width: program.width,
height: program.height
height: program.height,
debug: program.debug
});
......@@ -32,7 +32,8 @@ function Renderer(inputPath, outputPath, _options, cb) {
pageMargin: options.pageMargin || 0,
landscape: options.landscape || false,
width: options.width,
height: options.height
height: options.height,
debug: options.debug || false
};
var url = baseUrl + encodeURIComponent(inputPath);
......@@ -47,8 +48,6 @@ function Renderer(inputPath, outputPath, _options, cb) {
width: parseFloat(settings.width) * 25400,
height: parseFloat(settings.height) * 25400
};
console.log(size);
} else {
url += '&pageSize=' + settings.pageSize;
}
......@@ -57,6 +56,10 @@ function Renderer(inputPath, outputPath, _options, cb) {
url += '&landscape=' + settings.landscape;
}
if (settings.debug) {
url += '&debug=' + settings.debug;
}
console.log("Processing", inputPath, url);
conversion({
......
......@@ -20,67 +20,8 @@
<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; }" }]
};
<script src="renderer.js"></script>
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>
var viewer;
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;
});
}
if (settings.debug) {
viewerSettings.debug = settings.debug;
}
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+"; }";
}
viewer.loadDocument(settings.url, documentOptions, viewerOptions);
......@@ -20,7 +20,8 @@ function Renderer(inputPath, outputPath, _options, cb) {
pageMargin: options.pageMargin || 0,
landscape: options.landscape || false,
width: options.width,
height: options.height
height: options.height,
debug: options.debug || false
};
var url = baseUrl + encodeURIComponent(inputPath);
......@@ -35,8 +36,6 @@ function Renderer(inputPath, outputPath, _options, cb) {
width: parseFloat(settings.width) * 25400,
height: parseFloat(settings.height) * 25400
};
console.log(size);
} else {
url += '&pageSize=' + settings.pageSize;
}
......@@ -45,6 +44,10 @@ function Renderer(inputPath, outputPath, _options, cb) {
url += '&landscape=' + settings.landscape;
}
if (settings.debug) {
url += '&debug=' + settings.debug;
}
console.log("Processing", inputPath, url);
conversion({
......@@ -77,5 +80,3 @@ function Renderer(inputPath, outputPath, _options, cb) {
}
export default Renderer;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment