如何将PDF拆分为多个文档 [英] How to split a PDF into multiple documents
本文介绍了如何将PDF拆分为多个文档的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个很大的PDF,它是由多个文档组合而成的.
I have a large PDF that has been combined from multiple documents.
如何使用关键字定界符将PDF拆分为多个文档?
推荐答案
和Adobe Reader一样,您将需要Adobe Acrobat.
As well as Adobe Reader you will need Adobe Acrobat.
使用操作向导"添加以下脚本:
Add the following script using the Action Wizard:
粘贴以下脚本,然后根据需要进行修改.请参阅//评论以获取有关自定义的帮助.
Paste in the following script and modify for your needs. See //comments for help on customisation.
/* Extract Pages into Documents by Keyword */
// Iterates over all pages and find a given string and extracts all
// pages on which that string is found to a new file.
var pageArray = [];
var pageArrayEnd = [];
var stringToSearchFor = app.response("This Action Script splits the document by a keyword on each X number of pages, please enter the keyword:");
for (var p = 0; p < this.numPages; p++) {
// iterate over all words
for (var n = 0; n < this.getPageNumWords(p); n++) {
// DEBUGGING HELP, UNCOMMENT NEXT LINE, CHANGE TO MATCH MULTIPLE WORDS OR WHAT EVER ORDER, eg if ((this.getPageNthWord(p, n) == stringToSearchFor) && (this.getPageNthWord(p, n + 1) == stringToSearchForTWO)) {..., Also add a prompt for the second search word and iterate one less for (var n = 0; n < this.getPageNumWords(p) - 1; n++) ...
//app.alert("Word is " + this.getPageNthWord(p, n));
if (this.getPageNthWord(p, n) == stringToSearchFor) {
//app.alert("Found word on page " + p + " word number " + n, 3);
if (pageArray.length > 0) {
pageArrayEnd.push(p - 1);
}
pageArray.push(p);
break;
}
}
}
pageArrayEnd.push(this.numPages - 1);
//app.alert("Number of sub documents " + pageArray.length, 3);
if (pageArray.length > 0) {
// extract all pages that contain the string into a new document
for (var n = 0; n < pageArray.length; n++) {
var d = app.newDoc(); // this will add a blank page - we need to remove that once we are done
//app.alert("New Doc using pages " + pageArray[n] + " to " + pageArrayEnd[n], 3);
d.insertPages( {
nPage: d.numPages-1,
cPath: this.path,
nStart: pageArray[n],
nEnd: pageArrayEnd[n],
} );
// remove the first page
d.deletePages(0);
d.saveAs({ cPath: this.path.replace(".pdf","") + n + ".pdf" });
d.closeDoc(true);
}
}
这篇关于如何将PDF拆分为多个文档的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文