javascript 用Javascript将PDF拆分为单独的文件
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/33039152/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Split PDF in separate file in Javascript
提问by shmoolki
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 的模块
采纳答案by shmoolki
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?
回答by vmkcom
PDF format too complex for handling it via javascript. Can't find any js libs, that doing it well
PDF 格式太复杂,无法通过 javascript 处理。找不到任何js库,做得很好
It's easy to use other pdf parsing software and run it from node.js
很容易使用其他pdf解析软件,从node.js运行
use pdftkfor splitting pdf
使用pdftk拆分 pdf
pdftk input.pdf burst output output_%02d.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
maybe you can find node module for using pdftk, but it's too easy to run it by yourself
也许你可以找到使用pdftk的node模块,但是自己运行它太容易了