Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 20 additions & 7 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,25 @@ function wkhtmltopdf(input, options, callback) {
}
});

var isUrl = /^(https?|file):\/\//.test(input);

if (input) {
args.push(isUrl ? quote(input) : '-'); // stdin if HTML given directly
// Input
var isArray = Array.isArray(input);
if (isArray) {
input.forEach(function(element) {
var isUrl = /^(https?|file):\/\//.test(element);
if (isUrl) {
args.push(quote(element));
} else {
console.log('[node-wkhtmltopdf] [warn] Multi PDF only supported for URL files (http[s]:// or file://)')
}
})
} else {
var isUrl = /^(https?|file):\/\//.test(input);
if (input) {
args.push(isUrl ? quote(input) : '-'); // stdin if HTML given directly
}
}

// Output
args.push(output ? quote(output) : '-'); // stdout if no output file

// show the command that is being run if debug opion is passed
Expand Down Expand Up @@ -191,9 +204,9 @@ function wkhtmltopdf(input, options, callback) {
}

// write input to stdin if it isn't a url
if (!isUrl) {
// Handle errors on the input stream (happens when command cannot run)
child.stdin.on('error', handleError);
if (!isUrl && !isArray) {
// Handle errors on the input stream (happens when command cannot run)
child.stdin.on('error', handleError);
if (isStream(input)) {
input.pipe(child.stdin);
} else {
Expand Down