tcr / scissors

PDF manipulation in Node.js! Split, join, crop, read, extract, boil, mash, stick them in a stew.
Apache License 2.0
285 stars 45 forks source link

pdfA.page is not a function? #29

Closed mfkenson closed 6 years ago

mfkenson commented 6 years ago

Background:

Console Log:

kenson@free:~/trycode$ node scs.js 
Command {
  input: './pdf/invoice-RV-1508868016.pdf',
  stream: null,
  commands: [],
  onready: { [Function: promise] deliver: [Function], delivered: true } }
/home/kenson/trycode/scs.js:7
scissors.join(pdfA.page(1), pdfB.page(1), pdfC.pages(1)).pdfStream().pipe(fs.createWriteStream('out.pdf'))
                   ^

TypeError: pdfA.page is not a function
    at Object.<anonymous> (/home/kenson/trycode/scs.js:7:20)
    at Module._compile (module.js:570:32)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Module.runMain (module.js:604:10)
    at run (bootstrap_node.js:383:7)
    at startup (bootstrap_node.js:149:9)
    at bootstrap_node.js:496:3

Source code:

var scissors = require('scissors');
var fs = require('fs');

var pdfA = scissors('./pdf/invoice-RV-1508868016.pdf');
var pdfB = scissors('./pdf/invoice-RV-1508128890.pdf');
var pdfC = scissors('./pdf/invoice-RV-1508897549.pdf');
console.log(pdfA);
scissors.join(pdfA.page(1), pdfB.page(1), pdfC.page(1)).pdfStream().pipe(fs.createWriteStream('out.pdf'))
   .on('finish', function(){
     console.log("We're done!");
   }).on('error',function(err){
     throw err;
   });
mfkenson commented 6 years ago

Changing the page(1) to pages(1) works.


scissors.join(pdfA.pages(1), pdfB.pages(1), pdfC.pages(1)).pdfStream().pipe(fs.createWriteStream('out.pdf'))