11

i Have a big pdf file and i would like to split it in separate PDF files, each page in separate file.

It is possible to do that in JS with node module.

I search but in npm i just have modules that convert html to pdf

Cœur
  • 37,241
  • 25
  • 195
  • 267
shmoolki
  • 1,551
  • 8
  • 34
  • 57

2 Answers2

7

After a lot of searching and nearly giving up, I did eventually find that the HummusJS library will do what I want to do! thanks to @Taxilian

See this post How can I create a customized version of an existing pdf file with node.js?

Community
  • 1
  • 1
shmoolki
  • 1,551
  • 8
  • 34
  • 57
2

PDF format too complex for handling it via javascript. Can't find any js libs, that doing it well

It's easy to use other pdf parsing software and run it from node.js

use pdftk for splitting pdf

pdftk input.pdf burst output output_%02d.pdf

and run it via child-process

var exec = require('child_process').exec,
    child;

child = exec('pdftk input.pdf burst output output_%02d.pdf',
  function (error, stdout, stderr) {
    console.log('stdout: ' + stdout);
    console.log('stderr: ' + stderr);
    if (error !== null) {
      console.log('exec error: ' + error);
    }
});

pdftk split pdf with multiple pages

maybe you can find node module for using pdftk, but it's too easy to run it by yourself

Community
  • 1
  • 1
vmkcom
  • 1,630
  • 11
  • 17
  • Thanks for your answer but check what i found! – shmoolki Oct 10 '15 at 17:48
  • There's also a great library called [scissors](https://github.com/tcr/scissors) that wraps pdftk for Node.js - imo much easier to use than HummusJS but either should work. – 8eecf0d2 Feb 15 '18 at 07:04