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!
Print Page Ranges with Reader |
Post Reply |
Author | |
chicks
Debenu Quick PDF Library Expert Joined: 29 Oct 05 Location: United States Status: Offline Points: 251 |
Post Options
Thanks(0)
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 |
|
Post Reply | |
Tweet
|
Forum Jump | Forum Permissions You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |
Copyright © 2017 Debenu. Debenu Quick PDF Library is a PDF SDK. All rights reserved. About — Contact — Blog — Support — Online Store