Insert a variable on many pages in Adobe InDesign to fill in when printing PDF
Insert a variable on many pages in Adobe InDesign to fill in when printing PDF
Question
I have a "Name" field on many worksheet pages which I want automatically filled in with a particular student's name when printing. I know in InDesign I can just create a master page that those worksheet pages use and fill in the name of the student there.
I'd like to have a PDF of the worksheet pages where I just enter the name in the PDF viewer instead of having to do this through InDesign. Is this possible?
Accepted Answer
You could just add a header with the student's name. That would automatically appear on every page. I can't think of a faster way to do this in Acrobat offhand, if you're dealing with lots of pages.
You can set up a header Action (Tools > Action Wizard
) ahead of time with everything but the student's name, then add the name for each print run.
Popular Answer
You can do it with scripting. I've tried an tested this script in InDesign CS5 on a Mac, What you need to do is
- Select which text box you want the students' name to go in
- Then under the 'layers' panel, expand the layer it is in, and change the name of the text box by slow double clicking it, and enter "NAME"
- Copy and paste the script below in notepad or textedit
- Edit the first line to
var students = ["First Student", "Second Student"];
etc. (Hopefully this doesn't take longer than if you were not to use the script) - Save as MakePdfForEachStudent.jsx and save it in
/Applications/Adobe InDesign CS5.5/Scripts/Scripts Panel/Samples/Javascript
if you're on Mac (I can't remember where it is on Windows) - Go to Window > Utilities > Scripts and select MakePdfForEachStudent.jsx
- Follow the process
Hope this helps/works. I may improve this answer later.
// An InDesign CS5 javascript macro for exporting PDFs with different student names.
var students = ["Peter", "Lois", "Meg", "Chris", "Brian"];
var studentsNameTextLayer = "NAME";
// DON'T EDIT BELOW THIS LINE
// Display a "choose folder" dialog box.
if (app.documents.length != 0) {
var myFolder = Folder.selectDialog ("Choose a Folder");
if (myFolder != null) {
myExportPages(myFolder);
}
} else {
alert("Please open a document and try again.");
}
function myExportPages(myFolder)
{
var studentName, myFilePath, myFile;
var myDocument = app.activeDocument;
var myDocumentName = myDocument.name;
var theDialog = app.dialogs.add();
var myPageName = myDocument.pages.item(0).name;
var textBoxName = myDocument.pages.item(0).textFrames.item(whichTextBox);
with (theDialog.dialogColumns.add().dialogRows.add()) {
staticTexts.add({
staticLabel: "Base name:"
});
var myBaseNameField = textEditboxes.add({
editContents : myDocumentName,
minWidth : 160
});
}
var myResult = myDialog.show({
name : "ExportPages"
});
if (myResult == true) {
var myBaseName = myBaseNameField.editContents;
// Remove the dialog box from memory.
theDialog.destroy();
for (var loopCounter = 0; loopCounter < students.length; loopCounter++) {
studentName = students[loopCounter];
studentsNameTextLayer.contents = studentName;
app.pdfExportPreferences.pageRange = myPageName;
var matchColon = new RegExp(":","gi");
myPageName = myPageName.replace(matchColon, "_");
myFilePath = myFolder + "/" + myBaseName + "_" + myPageName + "_" + studentName + ".pdf";
myFile = new File(myFilePath);
myDocument.exportFile(ExportFormat.pdfType, myFile, false);
}
} else {
theDialog.destroy();
}
}