Hi - I want to create a custom toolbar button with an image. I can do it fine, but I can't get it to display without having to manually turn on the add-on toolbar.
the issue is that when I create the toolbar item, I do it in a folder level javascript.
There is no presently open document when that loads (I don't think) and so I am forced to go through the work around described in the api book of creating a new temporary document, importing the icon, and then getting the icon stream from that document, and finally building the icon.
The problems - 1. This is a long process (even though it is a small image) and 2. Because I do it on a temp doc (I guess) and then close that doc - the add-on toolbar is not turned on when I get to my real document.
So I was wondering two things -
1. Can I store that icon stream in the file as the hex-encoded string and then just load that - to save time.
2 (and more importantly) - How do I turn on the add-on toolbar by default or at least have it on for when my document opens.
Any help would be greatly appreciated.
Below is my script - it is essentially a copy of what is in the api. It is being loaded from the program JS folder:
var buildToolBar = app.trustedFunction(function(){
app.beginPriv();
var doc = app.newDoc();
doc.importIcon("formtool","/C/Program Files/Adobe/Acrobat 8.0/Acrobat/Javascripts/formtool.png",0)
var oIcon = util.iconStreamFromIcon(doc.getIcon("formtool"))
doc.closeDoc(true);
app.addToolButton({
cName: "formtool",
oIcon: oIcon,
cExec:"execToolMenu(this)",
cEnable:true,
nPos:0,
cLabel: "My Form Tool"
})
app.endPriv();
})
buildToolBar();
Please take a look at this tool for creating Acrobat toolbar buttons. It's basically a tool for generating the icon stream data from any image type, and created the structue for a tool. It has a 10 free trial so you can try it out and then look at the code it generates. It should give you an idea of what you need to do in your code.
http://www.windjack.com/products/acrobuttons.php
You might also want to take a look at the free automation tools at www.pdfscripting.com, these are all folder level JavaScript files with the icon stream data built into the folder level script.
Thom Parker
The source for PDF Scripting Info
[url=http://www.pdfScripting.com]pdfscripting.com[/url]
The Acrobat JavaScript Reference, Use it Early and Often
[url=http://www.adobe.com/devnet/acrobat/]http://www.adobe.com/devnet/acrobat/[/url]
Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script