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
Strange why the printerNames does't work.
I tried creating an .sequ file. It is not recognised as an action. It comes up with an error.
So I created a .js file. I read that this needs to be put in a JavaScript directory where the sequences are. So I have done that. Could you guide me how I can get this to run? I can't seem to find the command in Acrobat. It is not seeing the file.
Copy link to clipboard
Copied
Don't create an sequ file yourself. Create an Action and then export it to a file, which you can then copy and install on another machine.
The js file needs to be placed in the application's Javascripts folder and in order to be able to run the code in it you need to wrap it in a function and then add a command to it that will insert a new menu item to the application, which executes that function.
Copy link to clipboard
Copied
Okay. I think I have taken it as far as my brain will allow. I'll just stick to using the console. Many thanks for your help. I think I have achieved the main aim of all of this.
Copy link to clipboard
Copied
Here's a (somewhat outdated but still relevant) tutorial about folder-level scripts: https://acrobatusers.com/tutorials/folder_level_scripts
Copy link to clipboard
Copied
I figured out how to create an action. All is now working!
Thank you!
As a non-programmer, I have figured out two ways to implement the javascript code developed above:
Method 1
1. First create a dummy folder containing a single dummy pdf file.
2. Create an action which applies to this dummy folder.
3. In the action steps include an 'Execute Javascript' step and place the required code in this step to loop the number of times required and print the 'real' pdf files.
4. When this action is run, the dummy file is loaded but is not used. The javascript code is automatically executed and then prints the real files, and will loop the number of times specified in the script.
Method 2
1. Set up as Method 1 with a dummy folder.
2. Create multiple copies of a dummy file - the same number as the number of batches of the real documents required.
3. Create an action as Method 1, but change the script to loop only once, or remove the loop altogether.
4. When the action is run, it will open each dummy file in turn. For each file it will execute the javascript code automatically and print a batch of the real files.
I hope this helps anyone else trying to do the same thing. I am sure there may be an easier way, but these methods also work.
Copy link to clipboard
Copied
Hi,
I have a problem related to the above which I hope you can help me resolve. I have the following script:
function printFileMultipleTimes(filePath, numCopies) {
var doc = app.openDoc(filePath);
if (doc!=null) {
var pp = doc.getPrintParams(); pp.NumCopies = numCopies; pp.interactive = pp.constants.interactionLevel.automatic; doc.print(pp);
doc.closeDoc(true);
}
}
for (var i=1; i<=1; i++) {
printFileMultipleTimes("File1.pdf", 1);
printFileMultipleTimes("File2.pdf", 1);
printFileMultipleTimes("File3.pdf", 1);
printFileMultipleTimes("File4.pdf", 1);
printFileMultipleTimes("File5.pdf", 1);
printFileMultipleTimes("File6.pdf", 1);
printFileMultipleTimes("File7.pdf", 1);
etc.
printFileMultipleTimes("File60.pdf", 1);
}
Copy link to clipboard
Copied
If you're running it in Acrobat DC there's a bug there where the closeDoc method doesn't work.
So you'll notice you still have all the files open when you run it, and when you reach 50 open files it errors out, as that is the maximum allowed number of files.
However, I don't quite understand why you're closing an re-opening the file each time. Is it because you have some kind of doc-level script that you want to run in each iteration? If so, consider moving that code to your function and running it from there. That way you could work on a single instance of the file and won't have to open and close it in each iteration.
Copy link to clipboard
Copied
Yes I did notice the files appeared to be open. However, when the script finishes they all close at the same time automatically.
I am opening and closing each file in order to print them in sequence. Each one is a different document. Is there a more efficient way of doing this?
So I want to print doc1, doc2, doc3....doc60 in order, then restart the sequence from doc1 again.
I want to be able to produce multiple sets of these documents.
Is there a workaround for the closeDoc method not working?
Copy link to clipboard
Copied
Sorry, I see now these are different files. I don't think there's a way around the closeDoc method not working. It's a bug in the application.
What you can do, though, if the files don't contain form fields, is to merge them to a single (temporary) PDF file, print it and then close it without saving.
Copy link to clipboard
Copied
I should have mentioned that each document is separately stapled. I don't know how to combine them and have them separately stapled. If there is a way of doing that then that would resolve everything.
Copy link to clipboard
Copied
I don't think so... You might have to do it in batches of up to 50 files, then.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now