diff --git a/index.js b/index.js index 485d434..da7a125 100644 --- a/index.js +++ b/index.js @@ -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 (element && 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 @@ -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 {