Skip to main content
Skyzar
Known Participant
May 30, 2017
Answered

How to add a button to quick bar.

  • May 30, 2017
  • 2 replies
  • 796 views

The title is a bit confusing so let me elaborate here.

My Goal -> On opening a PDF my users are supposed to have my button on their (ideally) Quick Tools Bar.

The button will have it's own script which will create a custom stamp (I got that part figured out) but I just can't get it to have an Icon from the start when opening the PDF. I would like this to happen on a Folder-Level Script.

My code is failing on the part where it has to import an icon:

CODE:

function insertStamp(){

     this.addAnnot({

          page: 0,

          type: "Stamp",

          author: "Author",

          name: "myStamp",

          rect: [400, 400, 550, 500],

          AP: "SBConfidential",

          lock: false

     });

}

importIcon("myIcon", "/C/Users/Me/Desktop/ICON.png");

var my_oIcon = util.iconStreamFromIcon(myDoc.getIcon('myIcon'));

app.addToolButton({

     cName: "unique",

     oIcon: my_oIcon,

     cExec: "insertStamp",

     cTooltext: "Insert Stamp",

     cEnable: true,

     nPos: 0,

     cLabel: "Insert Stamp"

});

RESULT:

ReferenceError: importIcon is not defined

13:Folder-Level:App:Stamp.js

I would be thankful for any solutions, documentations, samples and knowledge you guys could pass on. Just started trying to code a bit of acrobat.

This topic has been closed for replies.
Correct answer Joel Geraci

As a folder level script, your code runs when Acrobat is loading. "importIcon" is a document method so it won't work in that context. My suggestion would be to rethink your approach and load the icon from a it's HEX string equivalent and have that string stored in your code. There are a bunch of posts in this forum on how to do that.

2 replies

Bernd Alheit
Community Expert
Community Expert
May 30, 2017
Skyzar
SkyzarAuthor
Known Participant
May 31, 2017

AcroButtons is discontinued and I would like to solve it with pure "Adobe JS"

Joel Geraci
Community Expert
Joel GeraciCommunity ExpertCorrect answer
Community Expert
May 30, 2017

As a folder level script, your code runs when Acrobat is loading. "importIcon" is a document method so it won't work in that context. My suggestion would be to rethink your approach and load the icon from a it's HEX string equivalent and have that string stored in your code. There are a bunch of posts in this forum on how to do that.

Skyzar
SkyzarAuthor
Known Participant
May 31, 2017

Thank you for that, found some solutions. I have to see which one works best.

Is there an approach you would recommend? I don't have a feel for what is a clean or dirty solution and I would prefer to do it clean. It's fine if not