Copy link to clipboard
Copied
Hi,
I have an action which prints a batch of pdf files. It is important that the files are printed in a particular sequence. This all works fine. However I now want to print multiple copies of the entire batch keeping the same sequence per batch.
I have tried editing the .sequ file by copying the entire batch several times. However, the additional batches are just ignored. It seems the action recognises that it has already printed the file and does not repeat it for duplicates (Scenario A).
I have found a workaround solution to this by creating multiple copies of the same folder with the same files. Now when I edit the .sequ file by copying the entire batch several times but referring to the different folders, there is no problem (Scenario B).
Examples:
Scenario A - This will only print one copy of Doc 1, Doc 2 and Doc 3 in sequence:
<File path="/C/Folder/Doc 1.pdf"/>
<File path="/C/Folder/Doc 2.pdf"/>
<File path="/C/Folder/Doc 3.pdf"/>
<File path="/C/Folder/Doc 1.pdf"/>
<File path="/C/Folder/Doc 2.pdf"/>
<File path="/C/Folder/Doc 3.pdf"/>
<File path="/C/Folder/Doc 1.pdf"/>
<File path="/C/Folder/Doc 2.pdf"/>
<File path="/C/Folder/Doc 3.pdf"/>
</Sources>
<Group label="Untitled">
<Command name="Print" pauseBefore="false" promptUser="false"/>
</Group>
Scenario B - This will print three copies of Doc 1, Doc 2 and Doc 3 in sequence:
<File path="/C/Folder/Doc 1.pdf"/>
<File path="/C/Folder/Doc 2.pdf"/>
<File path="/C/Folder/Doc 3.pdf"/>
<File path="/C/Folder - Copy (1)/Doc 1.pdf"/>
<File path="/C/Folder - Copy (1)/Doc 2.pdf"/>
<File path="/C/Folder - Copy (1)/Doc 3.pdf"/>
<File path="/C/Folder - Copy (2)/Doc 1.pdf"/>
<File path="/C/Folder - Copy (2)/Doc 2.pdf"/>
<File path="/C/Folder - Copy (2)/Doc 3.pdf"/>
</Sources>
<Group label="Untitled">
<Command name="Print" pauseBefore="false" promptUser="false"/>
</Group>
My question is:
Is there an easier way to do Scenario B? Is it possible to just loop Scenario A the number times required? If so, how?
Any help would be appreciated. Thanks!
Copy link to clipboard
Copied
You could consider combining the files to print into one, then the order of printing becomes unimportant. Everything MIGHT get simpler.
Copy link to clipboard
Copied
Sorry, I should have added that each document is stapled separately when printed. So I can't just combine the documents into one.
Copy link to clipboard
Copied
If the file-paths are fixed and known in advance then this can be done with a script, where you would hard-code the paths of the files and then print them in order, how many times you'd like.
Copy link to clipboard
Copied
Thanks for your reply.
Yes the file-paths are fixed. Can you please give me an idea of how to go about writing a script to do this. I have never written a script in Acrobat. I'm more familiar with writing macros in Word and Excel. If you could give me something to start off with that would be great.
Copy link to clipboard
Copied
Here's the basic code for opening a file, printing it a number of times and then closing it:
var doc = app.openDoc("/C/Folder/Doc 1.pdf");
if (doc!=null) {
var pp = doc.getPrintParams();
pp.NumCopies = 3;
doc.print(pp);
doc.closeDoc(true);
}
You would need to run it from a trusted context, though, such as an Action or directly from the JS-Console.
Copy link to clipboard
Copied
Thanks!
If I understand your script correctly, this will print each document 3 times. This isn't quite what I had in mind. I need to print each file once in a particular order, then repeat the whole batch n number of times. Each document is stapled as it is printed. How can I use your code as a repeating subroutine printing each document once, which is called by another subroutine and passing the document path reference as a parameter?
Copy link to clipboard
Copied
The example above prints a single document 3 times. It can be converted to a more generic function, like this:
function printFileMultipleTimes(filePath, numCopies) {
var doc = app.openDoc(filePath);
if (doc!=null) {
var pp = doc.getPrintParams();
pp.NumCopies = numCopies;
doc.print(pp);
doc.closeDoc(true);
}
}
You can then use it like this, for example:
printFileMultipleTimes("/C/Folder/Doc 1.pdf", 1);
printFileMultipleTimes("/C/Folder/Doc 2.pdf", 1);
printFileMultipleTimes("/C/Folder/Doc 3.pdf", 1);
printFileMultipleTimes("/C/Folder/Doc 1.pdf", 1);
printFileMultipleTimes("/C/Folder/Doc 2.pdf", 1);
printFileMultipleTimes("/C/Folder/Doc 3.pdf", 1);
This will print all three files, one after another, two times (one copy each time).
Copy link to clipboard
Copied
Many Thanks!
This looks good. Let me try it out! In the meantime, is there a way to just loop the calling routines? If not, this is fine!
Copy link to clipboard
Copied
Of course. For example:
for (var i=1; i<=3; i++) {
printFileMultipleTimes("/C/Folder/Doc 1.pdf", 1);
printFileMultipleTimes("/C/Folder/Doc 2.pdf", 1);
printFileMultipleTimes("/C/Folder/Doc 3.pdf", 1);
}
That will print the set of three files three times.
Copy link to clipboard
Copied
Perfect. Let me try it out and get back to you if I have a problem.
I really appreciate your help with this. Thank you!
Copy link to clipboard
Copied
I have created the code and pasted into the JavaScript console window. Is this the right place to execute the script?
I have pasted your code and modified the file references.
I have placed the 'function' before the 'for' loop. Is this correct?
Then I selected the line with the 'for' loop and pressed Ctrl+Enter. I got this error message:
SyntaxError: missing } in compound statement
2:Console:Exec
undefined
I can't see anything wrong with the script. Please advise if I am doing anything wrong in these steps.
Copy link to clipboard
Copied
You need to select all of the code with the mouse before running it from
the Console window.
Copy link to clipboard
Copied
Almost there.
How can I turn off the print dialog box in the doc.print(pp); command so that it prints without user input?
Copy link to clipboard
Copied
Before the print command, add this line:
pp.interactive = pp.constants.interactionLevel.automatic;
Copy link to clipboard
Copied
I want to be able to change which printer I am using. Is this the right command?
pp.printerName = "myprintername";
Copy link to clipboard
Copied
Yes. To make sure you're using the correct printer name run this code from the Console to get the list of internal names:
app.printerNames.join("\n");
Copy link to clipboard
Copied
Also, once the script is finalized, can I save it as a file and execute the file, or must I always copy it into the console?
Copy link to clipboard
Copied
You can save it to a .js file and install it as a folder-level script, or as an Action file (.sequ).
Copy link to clipboard
Copied
app.printerNames.join("\n"); doesn't work. Gives "undefined" as output.
Copy link to clipboard
Copied
Are you sure you're selecting the code before running it?
Copy link to clipboard
Copied
Yes, I have entered only this one line in the console. Then selected the entire line and pressed Ctrl+Enter.
Copy link to clipboard
Copied
If there are no printers then it's not going to work... Did it work until
now?
Copy link to clipboard
Copied
Yes I have many printers installed. I can find the system name using an Excel Macro. Presumably this would be the same name to set in the javascript. Is that right?
Copy link to clipboard
Copied
I can't say for sure. The printerNames list is the only reliable way of
getting the actual values...
Find more inspiration, events, and resources on the new Adobe Community
Explore Now