Skip to content

Commit

Permalink
fix(index): optional outputfiles to send to stdout
Browse files Browse the repository at this point in the history
  • Loading branch information
Frazer Smith committed Jul 20, 2020
1 parent 680aa14 commit de50f06
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -512,8 +512,11 @@ class Poppler {
try {
const args = await parseOptions(options, acceptedOptions);
args.push(file);
args.push(outputFile);

if (outputFile) {
args.push(outputFile);
} else {
args.push('-');
}
const { stdout } = await execa(
path.join(this.popplerPath, 'pdftocairo'),
args
Expand Down Expand Up @@ -798,7 +801,7 @@ class Poppler {
* inch of image files (or rasterized regions in vector output). The default is 300 PPI.
* @param {string=} options.userPassword - User password (for encrypted files).
* @param {string} file - Filepath of the PDF file to read.
* @param {string} outputFile - Filepath of the file to output the results to.
* @param {string=} outputFile - Filepath of the file to output the results to.
* @returns {Promise<string|Error>} Promise of stdout string on resolve, or Error object on rejection.
*/
async pdfToPs(options = {}, file, outputFile) {
Expand Down Expand Up @@ -849,7 +852,11 @@ class Poppler {
try {
const args = await parseOptions(options, acceptedOptions);
args.push(file);
args.push(outputFile);
if (outputFile) {
args.push(outputFile);
} else {
args.push('-');
}

const { stdout } = await execa(
path.join(this.popplerPath, 'pdftops'),
Expand Down Expand Up @@ -939,6 +946,8 @@ class Poppler {
args.push(file);
if (outputFile) {
args.push(outputFile);
} else {
args.push('-');
}

const { stdout } = await execa(
Expand All @@ -960,7 +969,7 @@ class Poppler {
* @param {boolean=} options.printVersionInfo - Print copyright and version information.
* @param {Array} files - Filepaths of the PDF files to merge.
* An entire directory of PDF files can be merged like so: 'path/to/directory/*.pdf'.
* @param {string=} outputFile - Filepath of the file to output the resulting merged PDF to.
* @param {string} outputFile - Filepath of the file to output the resulting merged PDF to.
* @returns {Promise<string|Error>} Promise of stdout string on resolve, or Error object on rejection.
*/
async pdfUnite(options = {}, files, outputFile) {
Expand All @@ -973,9 +982,7 @@ class Poppler {
files.forEach((element) => {
args.push(element);
});
if (outputFile) {
args.push(outputFile);
}
args.push(outputFile);

const { stdout } = await execa(
path.join(this.popplerPath, 'pdfunite'),
Expand Down

0 comments on commit de50f06

Please sign in to comment.