Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Fred Chasen
vivliostyle-electron
Commits
e927d9b4
Commit
e927d9b4
authored
Sep 16, 2016
by
Fred Chasen
Browse files
Added a max timeout option
parent
9cfe48eb
Pipeline
#619
skipped
Changes
5
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
README.md
View file @
e927d9b4
...
...
@@ -28,6 +28,7 @@ vivliostyle-electron ./path/to/index.html -o result.pdf
-h --height [size] Print to Page Height [weight]
-m, --page-margin [margin] Print with margin [margin]
-n, --hyphenate [lang] Hyphenate with language [language] such as "en-us"
-t, --timeout [ms] Set a max timeout of [ms]
```
## Hyphenation
...
...
cli.js
View file @
e927d9b4
...
...
@@ -18,9 +18,15 @@ program
.
option
(
'
-h --height [size]
'
,
'
Print to Page Height [weight]
'
)
.
option
(
'
-m, --page-margin [margin]
'
,
'
Print with margin [margin]
'
)
.
option
(
'
-n, --hyphenate [lang]
'
,
'
Hyphenate with language [language] such as "en-us"
'
)
.
option
(
'
-t, --timeout [ms]
'
,
'
Set a max timeout of [ms]
'
)
.
parse
(
process
.
argv
);
var
input
=
program
.
inputs
||
program
.
args
[
0
];
if
(
!
input
)
{
return
console
.
error
(
"
You must include an input path
"
);
}
var
dir
=
process
.
cwd
();
var
relativePath
=
path
.
resolve
(
dir
,
input
);
...
...
@@ -49,7 +55,8 @@ renderer = new Renderer(tmpPath || input, output, {
landscape
:
program
.
landscape
,
width
:
program
.
width
,
height
:
program
.
height
,
debug
:
program
.
debug
debug
:
program
.
debug
,
timeout
:
program
.
timeout
}).
then
(
function
(
result
)
{
if
(
tmpPath
&&
tmpPath
!=
relativePath
)
{
fs
.
unlinkSync
(
tmpPath
);
...
...
lib/index.js
View file @
e927d9b4
...
...
@@ -38,7 +38,8 @@ function Renderer(inputPath, outputPath, _options) {
landscape
:
options
.
landscape
||
false
,
width
:
options
.
width
,
height
:
options
.
height
,
debug
:
options
.
debug
||
false
debug
:
options
.
debug
||
false
,
timeout
:
options
.
timeout
||
undefined
};
var
url
=
'
file://
'
+
basePath
+
"
renderer.html?url=
"
+
encodeURIComponent
(
relativePath
);
...
...
@@ -65,6 +66,10 @@ function Renderer(inputPath, outputPath, _options) {
url
+=
'
&debug=
'
+
settings
.
debug
;
}
if
(
settings
.
timeout
)
{
conversion
.
timeout
=
parseInt
(
settings
.
timeout
);
}
console
.
log
(
"
Processing
"
,
inputPath
,
url
);
return
new
Promise
(
function
(
resolve
,
reject
)
{
...
...
package.json
View file @
e927d9b4
{
"name"
:
"vivliostyle-electron"
,
"version"
:
"0.0.
1
"
,
"version"
:
"0.0.
2
"
,
"description"
:
"Render Html to PDFs using Vivliostyle.js and Electron"
,
"repository"
:
{
"type"
:
"git"
,
...
...
src/index.js
View file @
e927d9b4
...
...
@@ -23,7 +23,8 @@ function Renderer(inputPath, outputPath, _options) {
landscape
:
options
.
landscape
||
false
,
width
:
options
.
width
,
height
:
options
.
height
,
debug
:
options
.
debug
||
false
debug
:
options
.
debug
||
false
,
timeout
:
options
.
timeout
||
undefined
};
var
url
=
'
file://
'
+
basePath
+
"
renderer.html?url=
"
+
encodeURIComponent
(
relativePath
);
...
...
@@ -50,6 +51,10 @@ function Renderer(inputPath, outputPath, _options) {
url
+=
'
&debug=
'
+
settings
.
debug
;
}
if
(
settings
.
timeout
)
{
conversion
.
timeout
=
parseInt
(
settings
.
timeout
);
}
console
.
log
(
"
Processing
"
,
inputPath
,
url
);
return
new
Promise
(
function
(
resolve
,
reject
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment