简体   繁体   English

在 Acrobat Pro 中使用 javascript 从 PDF 中提取页面

[英]Extract pages from PDF with javascript in Acrobat Pro

I am trying to create a script that will extract all pages from a pdf document and name them from the number of the pdf (say the pdfs name is 5047.pdf) and then increment the name for every page of the pdf so it produces 5048.pdf, 5049.pdf etc. However my script doesnt do anything.我正在尝试创建一个脚本,该脚本将从pdf中提取所有页面,并从Z4375BA4191210EE004E1D937494D09Z的Z4375BA4191210EE004EN11 ENPORY IT11 for 504.page for 5047.pdfff中命名,并将其命名.pdf、5049.pdf 等。但是我的脚本没有做任何事情。

var filename = 0;
for (var i = 0; i < this.numpages; i++)
this.extractpages

({
nStart: i,
cpath: filename + i + ".pdf"

});

Original link: https://forums.adobe.com/thread/969135 原始链接: https : //forums.adobe.com/thread/969135

The solution, based on an answer from Adobe's forum: 该解决方案基于Adobe论坛的答案:

/* Extract Pages to Folder */

var re = /.*\/|\.pdf$/ig;

var filename = this.path.replace(re,"");
var lastPage=this.numPages-1;
{
    for ( var i = 0;  i < this.numPages; i++ ) 
    this.extractPages
     ({
        nStart: i,
        nEnd: lastPage,
        cPath : filename + "_page_" + (i+1) + ".pdf"
    });
};

This worked for me, it was necessary to extract 2 pages in a row:这对我有用,有必要连续提取 2 页:

 /* Extract Pages to Folder */ var re = /.*\/|\.pdf$/ig; var filename = this.path.replace(re,""); var lastPage=this.numPages-1; { for ( var i = 0; i < this.numPages; i = i + 2 ) this.extractPages ({ nStart: i, nEnd: i + 1, cPath: filename + "_page_" + (i+1) + ".pdf" }); };

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

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