I've slightly modified a JavaScript example from Sean Stewart of ARTS PDF so that it will add a menu item to Adobe Reader to allow printing page ranges, e.g. "1,5,10-19,25"
Just save the JavaScript as "PrintPageRanges.js" to the JavaScript subfolder in your Adobe Reader directory, and it will add a "Print Page Ranges" item to the "File" directory next time you start Reader.
You can also attach the original code to a button on your PDF using iSEDQuickPDF.
http://www.planetpdf.com/developer/article.asp?ContentID=6873
/*
Title: PRINT USER DEFINED PAGE RANGE
Author: ARTS PDF, Sean Stewart
Purpose: Prompt user to enter required page
range to print, e.g. 1-5,7,9-20
*/
var PrintPageRanges = app.trustedFunction(function()
{
//Get user response
var cResponse = app.response({
cQuestion: "Enter in the pages you wish to print, e.g. 1,5,10-19,25",
cTitle: "Print",
cDefault: "",
cLabel: "Pages:"
});
if ( cResponse == null) {
app.alert("No pages entered");
} else {
var strInput = cResponse;
var strChar;
var arPrint = new Array(10);
var arCount = 0;
arPrint[arCount] = "";
for (var i = 0; i < strInput.length; i++){
strChar = strInput.substr(i,1);
//Check character and form page group
if (IsInteger(strChar) == 0){
arPrint[arCount] = arPrint[arCount] + strChar;
}
if (IsDash(strChar) == 0){
arPrint[arCount] = arPrint[arCount] + strChar;
}
if (IsComma(strChar) == 0){
arCount++;
arPrint[arCount] = "";
}
}
for (i=0;i<(arCount+1);i++){
if (arPrint[i].indexOf("-") > 0){
var dashPos;
dashPos = (arPrint[i].indexOf("-"));
var pageStart = arPrint[i].substr(0,dashPos);
var pageEnd = arPrint[i].substr(arPrint[i].indexOf("-")+1,
(arPrint[i].length - dashPos+1));
this.print({
bUI: false,
nStart: pageStart - 1,
nEnd: pageEnd - 1,
bSilent: true
});
} else {
this.print({
bUI: false,
nStart: arPrint[i] - 1,
nEnd: arPrint[i] - 1,
bSilent: true
});
}
}
}
});
function IsComma(strChar){
if (strChar == ",") {
return 0;
} else {
return -1;
}
}
function IsSpace(strChar){
if (strChar == " ") {
return 0;
} else {
return -1;
}
}
function IsDash(strChar){
if (strChar == "-") {
return 0;
} else {
return -1;
}
}
function IsInteger(strChar){
if (strChar >=0 || strChar <= 9) {
return 0;
} else {
return -1;
}
}
app.addMenuItem({cName:"Print Page Ranges",cParent:"File",cExec:"PrintPageRanges();"});
|