Create Custom Commands in Adobe Acrobat DC Pro


In Acrobat XI and older, when you wanted to run e.g. a custom JavaScript, you had to create a folder level script and find the correct directory to install it, or create a custom Action using the Action Wizard, and then deal with the overhead of running an Action. In Acrobat DC Pro, this got a lot easier with the introduction of “Custom Commands”. A custom command is a user defined command that can be used just like the built-in commands. This means it can e.g. be added to the toolbar, or be used in an Action.

Let’s see how we can create and use custom commands.

Creating Custom Commands

Let’s assume we want to create a custom command that counts bookmarks in a document. Not very creative, but I already have a script for that in one of my old blog posts. This also demonstrates how much easier this is compared to using a JavaScript menu item.

In Acrobat DC, we need to switch to the “Tools” view and then access the “Action Wizard” tool:

2015 04 17 15 53 04

Once selected, the Action Wizard allows us to create, manage and execute Actions (just like the Action Wizard in Acrobat X Pro or XI Pro), but is also has functionality to create and manage custom commands:

2015 04 17 15 53 52

Just like the name implies, the function “New Custom Command” creates a new custom command. When we execute this function, we get a dialog that lets us select what command we want to use as part of our custom command. This can for example be a preflight profile with specific settings, so that the user does not have to configure the preflight tool manually. When executed, the custom command would configure preflight, select the correct profile and run it. We are trying to execute some JavaScript, we therefore select the “Execute JavaScript” option from the “Customizable Commands” list:

2015 04 17 15 59 38

On this dialog, we first select which customizable command we want to run (1), then we provide a name and a tooltip for our custom command (2) (3). The custom command gets configured by clicking on the “Command Options…” button (4). As the last step, we need to make sure that the custom command does not prompt the user for information that we’ve already specified as “Command Options” (5). For some custom commands, it may be necessary to display the Command Options dialog, but for what we are going to do with JavaScript, it would just get in the way of a smooth user experience.

When we click on “Command Options”, we get to the JavaScript editor. Here is the code that we are using to count bookmarks:

function CountBookmarks(bkm, nLevel) {
	var count = 0;
	if (bkm.children != null) {
		count = bkm.children.length;
		for (var i = 0; i < bkm.children.length; i++) {
			count += CountBookmarks(bkm.children[i], nLevel + 1);

	return count;

(function() {
	var n = CountBookmarks(this.bookmarkRoot, 0);
	console.println("Number of bookmarks found: " + n);

If you are confused by the anonymous, self-executing function, take a look here for more information: I am using such an anonymous function so that any variables that get declared are local to that function, and don’t interfere with any other JavaScript in Acrobat.

Now that we’ve created our own custom command, we can execute it from the Action Wizard user interface:

2015 04 17 16 10 59

What else can we do with a custom command?

Using Custom Commands

Let’s add the custom command to our Acrobat toolbar. To do that, we right-click on the gray background of the toolbar. This brings up a menu that allows us to select the “Customize Quick Tools” function:

2015 04 17 16 21 09

After we select “Customize Quick Tools”, we can then add commands to the Quick Tools area on the toolbar. The tools we can add are built-in tools (e.g. the “Sticky Notes” tool so that it can be used with just one mouse click), but also our custom commands (and all Actions created with the Action Wizard). We need to expand the “Action Wizard” section to get to the custom commands. Once selected, we click on the “move item up” button on the right side to actually move it to the Quick Tools toolbar. Now we just have to select to “Show Quick Tools” in the right-click menu from before. If the menu item is “Hide Quick Tools”, then the Quick Tools are already shown.

Another option to use a custom command is to create a new group of tools called a Custom Tool. We create such a Custom tool by clicking on the “Create Custom Tool” icon in Acrobat’s “Tools” area:

2015 04 17 16 28 01

We can now add our tools either to the toolbar via the “Up Arrow”, or to the “Right Hand Panel” (RHP) via the “Right Arrow” button. The following shows how the toolbar and RHP look for a custom tool:

2015 04 17 16 46 25

There you have it, a very easy way to create custom commands that can be added to Acrobat’s user interface.

This entry was posted in Acrobat, JavaScript, Tutorial and tagged , , , . Bookmark the permalink.

75 Responses to Create Custom Commands in Adobe Acrobat DC Pro

  1. Denny Jansen says:

    Hello Karl-Heinz,
    I have used the ‘splitpages’ script which you provided successfully with Acrobat XI, but I cannot get it to work with DC Pro. I came across this article and tried to follow the instructions but although I have an action ‘Split Pages’ showing nothing happens.
    Any advice you can give will be gratefully received!
    Kind regards,
    Denny Jansen

  2. Karl Heinz Kremer says:

    Without seeing the code in your custom command, it’s impossible to say what’s wrong. Here is what I would do: Check the JavaScript console for error messages. If you find some, they would point you to the source of the problem. If that does not help, add debug output to your script. You can add a line like this:

    console.println(“I reached line 5, variable i is set to ” + i);

    This will tell you how far in the script you get, and you can also review the values of variables.

  3. Dan Kaufman says:

    Great article! I’m a web developer that works almost exclusively in javascript and my company recently purchased Acrobat Pro DC and (since I use Photoshop and they assume one Adobe product is identical to all others and that since I work on a computer I must know how to do everything) they figured I’d be the perfect guy to do all our form conversions… which has absolutely nothing to do with web development.

    I was hoping to add some automation to the forms and this gets me going in the direction I need to go. Thanks for this simple but ground-breakingly useful article. You just saved me a ton of research time. And, unfortunately, made sure that I will now also become the Acrobat ‘expert’ at my company….. damn it.

    Thanks again.

  4. Al says:

    I am having issues with simple calculations in a pdf doc. I am totalling two fields. Ex: field1*field2. If I make a mistake and delete the filed 2 amount moves into the total field…..any help would be appreciated. Apologies for the less than correct lingo

  5. Karl Heinz Kremer says:

    Al, unfortunately, I don’t know what you mean by “moves into the total field”. Can you please describe in more detail what exactly is happening.

  6. Fernando says:

    I’m creating a PDF fillable form and have a drop down menu with 5 options. Depending on what option is chosen, it needs to select/check (automatically) some predetermine options (between 2-6 options). How do I do this?

    Greatly appreciate it any help.


  7. Susan Brandt says:

    How to I add a time/date every time the pdf is opened?

    I know it’s a javascript but not sure where to place it.

  8. Karl Heinz Kremer says:

    Susan, you can create a document level JavaScript that gets executed every time you open the file:

    this.getField("LastOpened").value = util.printd("mm/dd/yyyy", new Date());

    This assumes that you have a field called “LastOpened” in your document. That field will get updated every time you open the PDF – but you will have to save the file in order to retain that information. If you close without saving, that date will be lost.

  9. Anne says:

    I have PDFs with speaker notes imported as a comment or sticky note. This icon appears in the upper left corner of the PDF (16:9 format in ppt/13.33 x 7.50 inches PDF). Is there a way to move it to the right side of the screen on all pages?

  10. Debra McLaren says:

    I’m trying to create a toolbar button to print the current page to the default printer. I’ve created my function as:

    /* Put script title here */

    function PrintCurrentPage() {
    this.print (false, this.pageNum, this.pageNum);

    and assigned it to a toolbar button, but nothing prints.

    Any help is appreciated.

  11. Karl Heinz Kremer says:

    Debra, are you getting any errors in the Javascript console (Ctrl-J or Cmd-J)? How exactly are you calling the function from the toolbar button?

  12. Debra McLaren says:

    I’ve created a custom command and entered the JavaScript I found elsewhere. I’m not getting any error messages. I customised the quick toolbar to put it on the toolbar. Please see screenshot below.

  13. Karl Heinz Kremer says:

    Debra, copying and pasting JavaScript you find online without a good understanding of what the script does is usually not a good idea. In this case, the problem is that you are defining a JavaScript function, but you are then never calling this function. You can fix that in two different ways: You can either call the function, or you can remove the function definition and just use the one-line script that executes the print command (which is what I would do in this case):

    this.print (false, this.pageNum, this.pageNum);

  14. Roman says:

    I am trying to use this javascript ( in Acrobat DC to save (and be able to reopen) opened tabs (for various reasons the recent open files in the acrobat DC menu does not do what I need). I followed your explanation but alas, I think I am missing something crucial as this script doesn’t work.
    Any tips?
    Thank you!

  15. Mark says:

    I have a PDF with CMYK color space. Is there a way to convert all objects using RGB JavaSript?
    Thanks Mark

  16. Karl Heinz Kremer says:

    Mark, yes, this can be done with JavaScript, using the Doc.colorConvertPage() method. There is an example in the SDK documentation that shows how to convert everything to RGB:

  17. Karl Heinz Kremer says:

    Roman, I am not familiar with this script, so would not even know where to start to debug this problem. You may want to as your question on StackOverflow, where you found the script.

  18. Michael Olausson says:

    Dear Karl Heinz
    Your article with custom command is really informative and has helped me a lot. I have the following problem that I would like to automate:
    I would like to add new pages to a pdf document, update the pagenrs and get the pages place different on even and odd pages (with the page number on the outside of each page). Since the users are medical students needing a defined order of notes I do not want them to mess with pagination. I would also like the notes to look uniform.

    Thanks Michael

  19. Karl Heinz Kremer says:

    Michael, you can certainly do that, but it would require quite a bit of JavaScript programming (and more than what I can provide in the context of this blog). If you need my professional services, feel free to contact me via email. My email address is on the “About” page (

  20. Michael Olausson says:

    Thanks Karl Heinz. I will be in touch


  21. STP says:

    It’s not possible any more to index files in folders – is that correct?
    It was in Acrobat Pro X …

  22. Karl Heinz Kremer says:

    STP, this is still available. In Acrobat DC, go to the “Tools” page, and then type “Catalog” into the search field. You will then see “Full text Index with Catalog” as one oof the search results. This is what you had back in Acrobat X.

  23. STP says:

    Hi Karl Heinz Kremer ,
    I wondered if it is possible to create a custom action using indices (e.g.: go to folder xyz, embedd index in all files, finish), as it was possible with Acrobat X

  24. Karl Heinz Kremer says:

    STP, now I understand: You want to process a folder of PDF files and embed an index in each file. This is done via the “Save” action:

    Embed Index in Action

  25. STP says:

    Thank you!

  26. Ric says:

    Hi Karl,

    Susan Brandt ask How to I add a time/date every time the pdf is opened?

    Your answer is:

    -“create a document level JavaScript that gets executed every time you open the file

    this.getField(“LastOpened”).value = util.printd(“mm/dd/yyyy”, new Date());

    This assumes that you have a field called “LastOpened” in your document. That field will get updated every time you open the PDF – but you will have to save the file in order to retain that information. If you close without saving, that date will be lost”.

    Is there any way to autosave the changes without the user knowing?
    I am making self-destruct PDF, unfortunately Javascript code “app.execMenuItem(“Save”);” is not working. Any tips?


  27. Karl Heinz Kremer says:

    Ric, no, not without the user knowing – at least not unless you can install software on every computer that this needs to run. You would need a folder level script that defines a save function and then call that function from your document. Having said that, trying to implement any document security using JavaScript is not a good idea: There are always ways around this (e.g. by disabling JavaScript). You need a full blown DRM solution (which is not cheap) to do this reliably.

  28. Matthew Hirschland says:

    I work for a civic engagement table, and we are registering 90,000 voters before October 11th. We have to redact all of the scanned versions of the forms for their SS#’s and driver’s license #’s. Both of these are contained in a box with a solid printed perimeter, and the writing cannot be recognized by OCR. Could someone help me figure out how to have Adobe automatically recognize the rectangles as a pattern and then redact them if this is possible? They are the only one’s of their size. It’s also not feasible to just repeat the redaction mark across pages because of titled scans. This would save a tremendous amount of work!

  29. Karl Heinz Kremer says:

    Matthew, I replied to you in an email.

  30. Hi, I feel i have some options to do this but i wanted to get a straight / best practice from you as you really seem to have this covered in your wheelhouse! I want to be able to drop say, Photoshop Tiff Files to Acrobat DC and depending on which Template size it is dropped to (say a 10″ x 12″ template) i would like Acrobat DC to auto size the image to the Template size, create a Footer to have a few constants like: Client, Date, Image Name and also place the specified Color Bar (AI or EPS file) all in the right type face and position. This is all for loose proofing. Again, i have had ways and there are a ton of ways to go about this but i would love to get your stance / ideas on this. Let me know when you can and thanks!

  31. Karl Heinz Kremer says:

    Nicholas, there is no method to run a JavaScript when you open a new document. You can try to determine if a new document is opened by polling every second or so, but that’s potentially unreliable. The only way to do this correctly is by creating a custom Acrobat plug-in. This is also the only way to actually determine that the file was created from a TIFF image. Chances are you don’t want to process all files opened in Acrobat the same way (there is no need to process files that are already in PDF). Developing a custom plug-in is much more complex than writing some JavaScript.

  32. Hi Karl,

    Thanks for your reply, i really appreciate it! I have looked into making some Adobe Plugins. Do you have any suggestions as i am always up for other ideas!


  33. Karl Heinz Kremer says:

    Nicholas, creating Acrobat plug-ins is a complex task, and not something you can learn in an afternoon (I would guess that it’s probably two months of climbing the learning curve to get to a point where you can be productive). If you have programming background (C/C++ in a non-managed environment), then take a look at the Acrobat SDK documentation, and the sample plug-ins to see if this is something you want to get into. If not, feel free to get in touch with me via email (my email address is on the “About” page), I do write custom Acrobat plug-ins as part of my consulting business.

  34. Laurie Straus says:

    For digital copying, I would like to make a pdf document that duplicates each page so I would have page 1, page 1, page 2, page 2, etc. that I could import into InDesign making a 2-up spread of each page, cutting impression costs by half. Is there a way to set that up in Acrobat?

  35. Jonathan Joseph says:

    Hi Karl,

    Great article :0) I am trying to add a new menu item in Acrobat DC with no joy. I want to add a button and use a JavaScript that takes page one of my PDF and then makes a copy of it and places after every page following Page 2 in the original PDF. Basically its a business card cover on page one that I want to replicate for the other pages which are the persons details for the back of the card. The best I can do is to add blank pages but I can find a way to extract and copy page one throughout any guidance would be really appreciated kind regards Jon

  36. Karl Heinz Kremer says:

    Jonathan, take a look at the Doc.insertPages() command:

    You will need to insert pages from your own document, so you need to use the ‘this.path’ property for the cPath parameter.

  37. Heresh Ariai says:

    Where is the Acrobat DC javascript folder? Does anyone know?

  38. Karl Heinz Kremer says:

    Take a look here for more information about where folder level JavaScripts need to be stored:

  39. A Bruce says:

    Good day,

    I am relatively new to Adobe Pro. I have recently figured out have to add values to radio buttons and have them summed up in a tally box below. I would now like to have these specific radio buttons multiply the score assigned in the value field.

    For instance: Question 1: Did the corporation have an examiner available?
    Field 1: Yes (Value=1) / Field 2: No (Value=0)

    [At bottom of page] Field 40: Total Compliance Score (Value=Sum of all fields)

    *How can I multiply the “Yes” field values by (2) for those compliance issues I deem more important?


  40. Percy Nunnery says:


    Read with interest your answer on how to convert a CMYK PDF to RGB with an example in the Acrobat DC SDK.

    Trying to do the same for CMYK PDF to grayscale using Acrobat DC…how different would the javascript code be, or is that possible?

    Thank you for sharing all your great insights into creating custom commands!


  41. Percy Nunnery says:


    Believe I solved it through some trial and error (a Mac solution not sure if it applies to Windows as well)

    Basically the exact same script can be used by simply changing
    toRGB.convertProfile = “Apple RGB”;
    toRGB.convertProfile = “Generic Gray Profile”;

    I’m not concerned with the resulting image quality, but only for file size when creating archives of 1000s of document with accompanying PDF indexes.

    Of course all instances of “toRGB” could be changed to “toGray” and it still works

  42. Karl Heinz Kremer says:

    Percy, that is how I would solved this as well. There are a number of profiles on your computer that you can use for color conversion routines, and among them, you will find some profiles that convert to gray scale.

  43. Karl Heinz Kremer says:

    Bruce, one option would be to use a different value for your “Yes” field – if you use the value of 2 for all the options that are more important, you don’t have to change your calculation routine.


    According your experience, it’s possible to make a Java script to start an action to compare by Acrobat DC two PDF?

  45. Karl Heinz Kremer says:

    Erbmanno – no, this is not possible.

  46. Cheryl says:

    Hello Karl Heinz
    can I make a java script to designate the number of printed copies of an Adobe DC document is allowed?
    – What would that be?
    – Do I delete the text: * Put script title here* and place the java script inside the / / ?

  47. Karl Heinz Kremer says:

    Cheryl, You cannot limit the number of prints that are allowed via JavaScript. To control things like that, you will need a DRM (Digital Rights Management) solution.

  48. Christian says:

    Dear Karl Heinz,
    Thank you for your committed support!
    I have a button on my pdf that goes to the next page by action.
    Now I would like to have a validation of all fields on the same page before this action. When the validation of the fields fails the script should exit and the next action step (to next page) should not happen.
    I am missing a way to exit/abort the execution as rc.event doesn’t seem to be available.
    Can you help me out about what I am missing?
    Thank you and best regards,

  49. Christian says:

    Dear Karl Heinz, sorry the problem above is solved. I got rid of the action steps, writing it all in JavaScript
    this.pageNum++ in an if statement did the job for me …

  50. Karl Heinz Kremer says:

    Christian, as you found out, there is no way to make Action steps conditional. It’s either all or nothing, so rewriting the whole Action in JavaScript (if possible – some Action steps cannot be expressed in JavaScript) is the correct way to handle this.

  51. Christian says:

    Dear Karl Heinz,
    thank you for your reply.

    Now another question came up …
    If I have a number field, how can I test with JavaScript if it is 0 or “” (empty).
    Does a test on empty field exist?
    I can not use the standard number field validation as I need customized alerts …


  52. Karl Heinz Kremer says:

    Christian, use the Field.valueAsString() method to get the raw string (before it gets converted to a number). You can then compare agains “” and find out if the string is empty:

  53. Christian says:

    Hi Karl Heinz,
    great stuff! Saved my day :-!

  54. Chrille says:

    Hi, I am preparing a simple PDF document, and need to know how to get a date-format value from a field (Date_1) into another field (Date_2), where the new date should be (Date_1 + 180 days).
    Anyone who can assist here?


  55. Karl Heinz Kremer says:

    Chrille, date calculations are part of the core JavaScript language, so you use the “normal” JavaScript way of doing this as the calculation script for your second date:

    var theDateString = this.getField("Date1").valueAsString;

    if (theDateString != "") {
    var theDate = util.scand("mm/dd/yyyy", theDateString);
    theDate.setDate(theDate.getDate() + 180);
    event.value = util.printd("mm/dd/yyyy", theDate);
    else {
    event.value = "";

    You may also want to look into a new Date library from Joel Geraci, which makes these types of calculations a bit easier:

  56. Christian says:

    Dear Karl Heinz,
    just running into another issue where I do not find a working solution.
    I have 2 number fields, one number each and after filling in the first one, the cursor should jump directly into the second field.
    I can not find a working solution and did not find the commands to automated move around.
    Thank you for your time and always the best,

  57. Christian says:

    Dear Karl Heinz, another annoying question from my side …
    in an old post from you I found this code of yours:
    event.value = event.value.replace(“,”, “.”);
    to change , to .
    Even so I am still confused with my current setup.
    When I enter a number with 2 decimals I have to enter 2,34 which converts to 2.34 when viewing it in the field.

    I need to enter 2.34 and it should stay like this.

    Thank you,

  58. Karl Heinz Kremer says:

    Christian, you can do this by using the Field.setFocus() method once the criteria for moving to the next field is met. See here for more information:

  59. Karl Heinz Kremer says:

    Christian, you should not have to change a decimal comma to a decimal point – this should all be handled automatically when you use the correct format options for our fields.

  60. Christian says:

    Dear Karl Heinz,
    I am able to set the focus now.
    The issue now is, if I enter a Script in Validation like this getField(“KK2”).setFocus();
    I have to hit enter to jump to the next field, where it should jump directly to the next one after inserting a single digit for a 16 digit Credit Card number …
    If I use the mouse-up action event it doesn’t let me enter anything …
    What would you suggest?
    Thank you and best regards, Christian

  61. Christian says:

    Dear Karl Heinz, concerning format options something is not handled correctly.
    If I enter 12,45 it displays 12.45 and I can’t enter a . in the field for decimal points.
    I checked all over for some settings to control the situation, but cant find anything usefull.
    In Apple System Preferences I changed regional settings to use , for decimal separation, so now I enter 12,45 and it displays as 12,45
    Just I need 12.45 for all of it 🙁
    Thanx and best regards, Christian

  62. Karl Heinz Kremer says:

    You will have to do this with a custom keystroke script. The following will test for one digit (which if you are limiting the number of characters to one per field should work) and move to the next field if you’ve entered a digit:

    var re = /\d/;
    if (re.test(event.change))

  63. Karl Heinz Kremer says:

    Christian, unfortunately, without seeing the form, it’s impossible to say what’s going on. You may need to work with somebody to fix this problem. If you are interested in my professional services, my email address is on the “About” page and at the bottom of each sidebar on the right.

  64. Kimberley Bradley says:

    Hello Karl!
    I have a collection of pdf fillable forms in which, among other things, a checkbox should have been checked off by the reviewer/filler (but some/many were not checked off by one specific individual). The prospect of opening each form and adding the checkmark is not readily feasible and I’m looking for tech options.

    It’s the same box on each form. Is there an approach using an action wizard that would:
    1. open the individual forms
    2. check the specific box (check box 6)
    3. save the updated document(s)

    Alternatively, as the dynamic forms are being processed/flattened anyhow, is there a way to apply a stamp (which I would create) to a specific area on the flattened forms, which could then be re-flattened?

    Or do you have any other suggestions? FYI: I have both Acrobat X Pro and DC Pro.

    Thanks for any help you can offer 🙂


  65. Karl Heinz Kremer says:

    Kim, yes, with both Adobe Acrobat X and DC Pro, you can create an Action (using the Action Wizard) that would process multiple files, and open each file, check the box and then save the file again (either using the same filename or a new name). Let’s assume your checkbox is called “CheckMe”, then the JavaScript code you would need to add to your Action is the following:

    this.getField("CheckMe").checkThisBox(0, true);

    The “Run a JavaScript” action step is in the “More Tools” group. With Acrobat X, you don’t have to add a separate “Save” step, that’s already part of the Action, but with Acrobat DC you will need to add a step to explicitly save the modified document.

  66. Kimberley Bradley says:

    Hi Karl,

    I really appreciate your reply. Thanks very much! However, I am not able to make it work on Acrobat X unfortunately. I’ll try it on DC tomorrow, but I’m wondering if there’s a problem with the formatting of my form. I entered the script into the execute JavaScript action wizard, exactly as you indicated (except I changed the name of the box to “Check Box6”).

  67. Karl Heinz Kremer says:

    Hi Kim, are you getting any errors in the JavaScript console?

  68. Kimberley Bradley says:

    Hi Karl,

    I’m getting the following ctrl-J message:
    Acrobat EScript Built-in Functions Version 10.0
    Acrobat SOAP 10.0

    Does that mean anything to you?

  69. Karl Heinz Kremer says:

    That’s just the initialization message of the JavaScript system and harmless (it will be displayed every time you start Acrobat). Let’s go back a couple of steps: You created an Action in Acrobat X Pro with the one line code that I provided earlier, is that correct?

  70. Kimberley Bradley says:

    Thanks for your behind-the-scenes assistance Karl – everything is working perfectly 🙂

    Will definitely recommend your services in the future!


  71. Johnie Murphy says:

    Acrobat DC – the “Create Bookmark Report.sequ” file I originally got from the Acrobat users group in 2013 does not execute properly with DC. It was written for earlier versions -or does it matter. Do you know of an updated version? I do not know JS so I can’t check it out. I’m using DC 2015 Release (Classic) Version 2015.006.30172

  72. Karl Heinz Kremer says:

    Johnie, I assume you are referring to the Action from What exactly do you mean by “does not execute properly”? You are correct, it was written for an earlier version of Acrobat (I think it was for Acrobat X), but it should work in Acrobat XI and DC. I did not write this Action – and I have not used it in a few years – so your best bet may be to get in touch with the original author.

  73. Johnie Murphy says:

    Thank you for your quick reply. I now believe it to be a security issue with JS and my company security policy.

Leave a Reply

Your email address will not be published. Required fields are marked *