Do you own a Debenu Quick PDF Library version 7, 8, 9, 10, 11, 12, 13 or iSEDQuickPDF license? Upgrade to Debenu Quick PDF Library 14 today!

Debenu Quick PDF Library - PDF SDK Community Forum Homepage
Forum Home Forum Home > For Users of the Library > Sample Code
  New Posts New Posts RSS Feed - Print Page Ranges with Reader
  FAQ FAQ  Forum Search   Register Register  Login Login

Print Page Ranges with Reader

 Post Reply Post Reply
Author
Message
chicks View Drop Down
Debenu Quick PDF Library Expert
Debenu Quick PDF Library Expert


Joined: 29 Oct 05
Location: United States
Status: Offline
Points: 251
Post Options Post Options   Thanks (0) Thanks(0)   Quote chicks Quote  Post ReplyReply Direct Link To This Post Topic: Print Page Ranges with Reader
    Posted: 10 Jan 06 at 1:31PM
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();"});


Edited by chicks
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 11.01
Copyright ©2001-2014 Web Wiz Ltd.

Copyright © 2017 Debenu. Debenu Quick PDF Library is a PDF SDK. All rights reserved. AboutContactBlogSupportOnline Store