简体   繁体   English

如何使用Adobe XI Pro删除基于PDF短语的页面?

[英]How to delete pages based on phrases in PDF using Adobe XI Pro?

This is my first time using Actions in Adobe Pro. 这是我第一次在Adobe Pro中使用动作。 I would like to.. 我想要..

  1. Remove all pages in a PDF that contain any of the following strings (Total, Word Document, Excel Spreadsheet) for a PDF in Adobe Pro. 在Adobe Pro中,删除包含以下任何字符串(总计,Word文档,Excel电子表格)的PDF中的所有页面。
  2. Remove common strings (CSI, Export, Import) from all pages throughout the PDF. 从整个PDF的所有页面中删除通用字符串(CSI,导出,导入)。

The following code was found online and addresses #1 but extracts pages based on 1 string, I was not able to get it to work and I would also prefer to run through multiple strings and delete the pages. 以下代码是在网上找到的,地址为#1,但是基于1个字符串提取页面,我无法使其正常工作,并且我也希望遍历多个字符串并删除页面。

// 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 stringToSearchFor = "Total";



for (var p = 0; p < this.numPages; p++) {

// iterate over all words

for (var n = 0; n < this.getPageNumWords(p); n++) {

if (this.getPageNthWord(p, n) == stringToSearchFor) {

pageArray.push(p);

break;

}

}

}



if (pageArray.length > 0) {

// extract all pages that contain the string into a new document

var d = app.newDoc(); // this will add a blank page - we need to remove that once we are done

for (var n = 0; n < pageArray.length; n++) {

d.insertPages( {

nPage: d.numPages-1,

cPath: this.path,

nStart: pageArray[n],

nEnd: pageArray[n],

} );

}



  // remove the first page

  d.deletePages(0);



}
  1. One word and two word phrase options. 一个单词和两个单词的短语选项。

one-word: 一个词:

for (var p=this.numPages-1; p>=0; p--) {  
    if (this.numPages==1) break;  
    for (var n=0; n<this.getPageNumWords(p)-1; n++) {  
        if (this.getPageNthWord(p, n) == "one-word") {  
            this.deletePages(p);  
            break;  
        }  
    }  
}  

two-word: 两个词:

for (var p=this.numPages-1; p>=0; p--) {  
    if (this.numPages==1) break;  
    for (var n=0; n<this.getPageNumWords(p)-1; n++) {  
        if (this.getPageNthWord(p, n) == "1st-word" && this.getPageNthWord(p, n+1) == "2nd-word") {  
            this.deletePages(p);  
            break;  
        }  
    }  
}  
  1. Within Adobe XI Pro, Tools--> Protection-->Search & Remove Text 在Adobe XI Pro中,工具->保护->搜索和删除文本

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

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