在Javascript中分割PDF文件

时间:2022-01-24 01:15:46

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

我有一个很大的pdf文件,我想把它分成不同的pdf文件,每个页面都放在不同的文件中。

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

可以用node模块在JS中实现这一点。

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

我搜索,但是在npm中,我只有将html转换成pdf的模块

2 个解决方案

#1


2  

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

PDF格式太复杂,无法通过javascript处理。找不到任何js libs,做得好吗

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

使用其他pdf解析软件并从node.js中运行它很容易

use pdftk for splitting pdf

使用pdftk分割pdf

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

pdftk输入。pdf输出output_ % 02 d.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

pdftk分割pdf与多页

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

也许您可以找到使用pdftk的节点模块,但是自己运行它太容易了

#2


1  

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

经过大量的搜索和几乎放弃,我最终发现,HummusJS库会做我想做的事情!由于@Taxilian

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

如何用node.js创建现有pdf文件的定制版本?

#1


2  

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

PDF格式太复杂,无法通过javascript处理。找不到任何js libs,做得好吗

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

使用其他pdf解析软件并从node.js中运行它很容易

use pdftk for splitting pdf

使用pdftk分割pdf

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

pdftk输入。pdf输出output_ % 02 d.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

pdftk分割pdf与多页

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

也许您可以找到使用pdftk的节点模块,但是自己运行它太容易了

#2


1  

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

经过大量的搜索和几乎放弃,我最终发现,HummusJS库会做我想做的事情!由于@Taxilian

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

如何用node.js创建现有pdf文件的定制版本?