简体   繁体   English

使用 Javascript 在 Acrobat Reader 中从 PDF 中提取特定页面

[英]Extract specific pages from PDF in Acrobat Reader using Javascript

I have a PDF composed of multiple pages which the user can choose to print.我有一个 PDF 由用户可以选择打印的多个页面组成。 The user chooses using a set of tick boxes on the first page (ie theMRI, theEEG, etc).用户使用第一页上的一组复选框进行选择(即,MRI、EEG 等)。

There is a PRINT button that then sends whichever pages were ticked to the nearest printer.有一个 PRINT 按钮,然后将勾选的页面发送到最近的打印机。 I'm wondering whether it would be possible to adapt this script to extract those same pages instead to a PDF saved locally on the users computer.我想知道是否可以调整此脚本以将相同的页面提取到用户计算机上本地保存的 PDF 中。

Is that possible?那可能吗?

var theMRI = this.getField("MRI").value;
var theEEG = this.getField("EEG").value;
var theMGL = this.getField("MGL").value;
var theCyto = this.getField("Cytogen").value;
var theMito = this.getField("Mitogen").value;
var theOutpt = this.getField("Outpt_Lab").value;

if (theMRI != "Off") this.print({bUI: false, bSilent: true, bShrinkToFit: true, nStart: 1, nEnd: 3});
if (theEEG != "Off") this.print({bUI: false, bSilent: true, bShrinkToFit: true, nStart: 4, nEnd: 4});
if (theMGL != "Off") this.print({bUI: false, bSilent: true, bShrinkToFit: true, nStart: 5, nEnd: 5});
if (theCyto != "Off") this.print({bUI: false, bSilent: true, bShrinkToFit: true, nStart: 6, nEnd: 7});
if (theMito != "Off") this.print({bUI: false, bSilent: true, bShrinkToFit: true, nStart: 8, nEnd: 9});
if (theOutpt != "Off") this.print({bUI: false, bSilent: true, bShrinkToFit: true, nStart: 10});

Using Adobe Reader?使用 Adobe 阅读器? No. Adobe Reader can't modify the pages or page content of a PDF.不可以。Adobe Reader 无法修改 PDF 的页面或页面内容。 However.然而。 If the user has Adobe Acrobat Standard or Pro, a JavaScript can extract pages to a new PDF using something like the code below.如果用户有 Adobe Acrobat Standard 或 Pro,则 JavaScript 可以使用类似于下面的代码将页面提取到新的 PDF。 PDF page numbers are zero-based so the first page is 0. The third parameter is the file name for the extracted pages. PDF 页码从零开始,因此第一页为 0。第三个参数是提取页面的文件名。

 this.extractPages(startPageNum, endPageNum, "extractedPages.pdf")

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

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