简体   繁体   English

在Javascript中将PDF拆分为单独的文件

[英]Split PDF in separate file in Javascript

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. 可以在带有节点模块的JS中执行此操作。

I search but in npm i just have modules that convert html to pdf 我搜索但在npm我只有模块将html转换为pdf

After a lot of searching and nearly giving up, I did eventually find that the HummusJS library will do what I want to do! 经过大量的搜索和几乎放弃,我最终发现HummusJS库将做我想做的事! thanks to @Taxilian 感谢@Taxilian

See this post How can I create a customized version of an existing pdf file with node.js? 请参阅此文章如何使用node.js创建现有pdf文件的自定义版本?

PDF format too complex for handling it via javascript. PDF格式太复杂,无法通过javascript处理它。 Can't find any js libs, that doing it well 找不到任何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

and run it via child-process 并通过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的节点模块,但是你自己运行它太容易了

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM