Acrobat X – Bulk Printing and Custom Header

Every year we need to print off hundreds of enrolment forms to verify details of new students and current students. Each of these forms is pre-filled with students details and there is a separate PDF for each student.

Previously I used Multiple PDF Printer but this no longer works with Acrobat X. Instead I created an Action Wizard that allows you to select the folder with all the PDFs and it will print them all to your default printer with the default settings.

I then added another step to the action that uses Javascript to extract the student’s name from the file name and added it as a header to each page of that file. Finally this was modified so that the name is always on the outer edge, when it is printed back to back and stapled on the left.

To create this you can follow the following directions or import the attached action.

  Print Ghost Enrolment Forms with Header (960 bytes, 3,572 hits)

Acrobat X - Edit Action

In Acrobat X:

  1. File -> Action Wizard -> Create New Action
  2. Click More Tools and then click Execute JavaScript and then click Print.
  3. Change Start with to Ask when Action is Started
  4. Click on the Options button for JavaScript and paste in the following:
var strFilename = this.documentFileName;
// A regular expression to acquire the base name of the file
// Removes everything before last underscore for Ghosted_EnrolmentForm_
var re = /.*\/|.*_|\.pdf$/ig;
// Get student name by stripping path and everything to left of underscore
var strFilename = strFilename.replace(re,"").replace(",",", ");
var pageAmount = this.numPages; // Finds the length of the PDF

for (i = 0; i 	{
	if (i % 2 == 0) {
		// Odd
		this.addWatermarkFromText({
			cText: strFilename,
			nStart: i,
			nEnd: i,
			nFontSize: 11,
			nTextAlign: app.constants.align.right,
			nHorizAlign: app.constants.align.right,
			nVertAlign: app.constants.align.top,
			nHorizValue: -28, nVertValue: -10
		});
	}	else  {
		// Even
		this.addWatermarkFromText({
			cText: strFilename,
			nStart: i,
			nEnd: i,
			nFontSize: 11,
			nTextAlign: app.constants.align.left,
			nHorizAlign: app.constants.align.left,
			nVertAlign: app.constants.align.top,
			nHorizValue: 28, nVertValue: -10
		});
	}
}
  1. Click OK. Then click Saveand type in a name for the action and a description.

    Add Folders or Files

  2. Set your default printer and printer settings to how you want your documents to print (e.g. Double sided, Stapled).
  3. File -> Action Wizard -> <Your new action>
  4. Click Next on summary screen. You may tick Don’t show again box if you wish.
  5. Click Add Files… drop down and choose Add Folders… and select the folder holding the PDFs.
  6. Click Next and it will start adding the header and printing the files.

Useful Links:

  • Base for the JavaScript header is from Steve Wareham’s block post on Adding a Dynamic Stamp to a PDF.
  • The code to extract file name is from Adobe JavaScript Reference

About James Rudd

Network Administrator at Sydney Boys High School
This entry was posted in Windows and tagged , , , , , , . Bookmark the permalink.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.