Hello all: OK, I'm a complete javacript idiot, but... I need to create a
javascript from a javascript I've found that will allow me to select
specific page ranges in Adobe reader to print. Below are the links and
text of the recommended procedure, Problem is, I don't know what
application to use to paste this code into but I'm guessing it needs to
be done in html thus I'd use mozilla composer- so if someone could tell
me how to create the .js file or point me to a link that explains it,
I'd very much appreciate it. TIA
Here's the proceedure recommended:
( http://www.quickpdf.org/forum/forum_posts.asp?TID=250&PN=1)
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
The Javascript:
/*
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();"});
murman - 31 Aug 2006 20:14 GMT
I figured it out! Pasted into MS word and saved as a text file and put
.js as extension. Hope that maybe you all will be able to use this
script anyway. Best
> Hello all: OK, I'm a complete javacript idiot, but... I need to create a
> javascript from a javascript I've found that will allow me to select
[quoted text clipped - 134 lines]
> app.addMenuItem({cName:"Print Page
> Ranges",cParent:"File",cExec:"PrintPageRanges();"});