node-pdftk icon indicating copy to clipboard operation
node-pdftk copied to clipboard

cat command creates empty PDF

Open hielsnoppe opened this issue 2 years ago • 0 comments

Describe the bug When I try to concatenate PDFs in an Express application, the resulting PDF is empty:

const documents = new Map();
documents.set('A', 'input1.pdf')
documents.set('B', 'input2.pdf')

const input_obj = Object.fromEntries(documents);
const cat_str = [ ... documents.keys()].join(' ');
const output = 'output.pdf';

pdftk
    .input(input_obj)
    .cat(cat_str)
    .output(output)
    .then(buffer => {
        // Do stuff with the output buffer
        documents.set('output', output)
        res.json(Object.fromEntries(documents))
    })
    .catch(err => {
        // handle errors
        res.json(err)
    });

The equivalent pdftk command on the command line succeeds:

pdftk A=input1.pdf B=input2.pdf cat A B output output.pdf

To Reproduce Steps to reproduce the behavior:

  1. Run the above code
  2. Try opening output.pdf

Expected behavior The generated file contains all input PDFs in the specified order.

Screenshots N/A

Desktop (please complete the following information):

  • OS: Ubuntu
  • Version: 20.04.4 LTS (64-bit)

Additional context N/A

hielsnoppe avatar Jun 24 '22 09:06 hielsnoppe