Posted by: AHN
« on: June 28, 2017, 12:22:24 AM »You are right. Tabs appear now. Next step ..I will try. Have a nice day.Thanks.
But I can't understand.If not tedious, then use the merge tool. What's the problem of creating a new file? Just click the preview button, to execute the merge and open it in the default PDF reader. Now you just need to print it, and all the documents/pages you selected will be printed in one shot.
Without creating new file,
Select files and type pages for each document
(Or automatically all pages)
Is not so tedious.. I think so.
Coding is not so good for me. .It's already coded. You just need to use it
/****************************************************/
//http://cwestblog.com/2012/03/10/jscript-using-inputbox-and-msgbox/
(function(vbe) {
vbe.Language = "VBScript";
vbe.AllowUI = true;
var constants = "OK,Cancel,Abort,Retry,Ignore,Yes,No,OKOnly,OKCancel,AbortRetryIgnore,YesNoCancel,YesNo,RetryCancel,Critical,Question,Exclamation,Information,DefaultButton1,DefaultButton2,DefaultButton3".split(",");
for (var i = 0; constants[i]; i++) {
vbe.eval("vb" + constants[i]);
}
InputBox = function(prompt, title, msg, xpos, ypos) {
var params = [];
params.push(toVBStringParam(prompt));
if (title != null) {
params.push(toVBStringParam(title));
if (msg != null) {
params.push(toVBStringParam(msg)); {
if (xpos != null) {
params.push(xpos);
if (ypos != null) {
params.push(ypos);
}
}
}
}
}
return vbe.eval('InputBox(' + params.join(",") + ')');
}
MsgBox = function(prompt, buttons, title) {
return vbe.eval('MsgBox(' + [toVBStringParam(prompt), buttons != null ? buttons : "Empty", toVBStringParam(title)].join(",") + ')');
};
function toVBStringParam(str) {
return str != null ? 'Unescape("' + escape(str + "") + '")' : "Empty";
}
})(new ActiveXObject("ScriptControl"));
/****************************************************/
var pages = InputBox('Leave empty to print all the pages', "Specify the pages to print");
if (typeof pages != 'undefined') {
var Merger = pdfe.CreateDocumentMerger();
var ProgressBar = pdfe.ProgressBar;
ProgressBar.max = pdfe.SelectedFiles.count;
for (var i = 0; i < pdfe.SelectedFiles.count; i++) {
ProgressBar.position++;
var srcFilename = pdfe.SelectedFiles(i).filename;
pdfe.echo('Merging: ' + srcFilename);
if (Merger.MergeDocument(srcFilename, pages)) pdfe.echo(' [OK]', 0, 1)
else pdfe.echo(' [Failed]', 0xFF0000, 1);
}
//save to a temporary file
var fso = new ActiveXObject("Scripting.FileSystemObject");
var MergedFilename = fso.BuildPath(fso.GetSpecialFolder(2 /*TemporaryFolder*/ ), 'MergePrint.pdf');
if (Merger.EndAndSaveTo(MergedFilename)) {
pdfe.echo('Printing');
var objShell = new ActiveXObject("shell.application");
//print it using the default associated application.
//Only works if the default PDF application has the print verb specified.
// objShell.ShellExecute(MergedFilename, "", "", "Print", 1);
//Print with Sumatra PDF
// objShell.ShellExecute("C:\\Program Files (x86)\\SumatraPDF\\SumatraPDF.exe", '-print-dialog "'+MergedFilename+'"', "", "Open", 1);
//Open it in the default PDF reader
objShell.ShellExecute(MergedFilename, "", "", "Open", 1);
} else {
pdfe.echo('Failed', 0xFF0000);
}
pdfe.echo('Done');
} else pdfe.echo('Canceled');
This script prompts the user for the pages to print (same format as with the merge tool "pages to include" column), executes the merge and then opens, or prints, the result PDF.