custom button with individual image

Forum for the PDF-XChange Editor - Free and Licensed Versions

Moderators: TrackerSupp-Daniel, Tracker Support, Paul - Tracker Supp, Vasyl-Tracker Dev Team, Chris - Tracker Supp, Sean - Tracker, Ivan - Tracker Software, Tracker Supp-Stefan

Peter19
User
Posts: 7
Joined: Sun Aug 06, 2023 7:41 pm

custom button with individual image

Post by Peter19 »

Hallo

Is it possible to include an image other than the "puzzle" design in a custom button?

I am working with PDF-XChange Editor plus Version 10.0.1 and the button is
created by Javascript

app.addToolButton({
cName: "Buchungsbeleg",
cExec: "Buchungsbeleg()",
cTooltext: "Beleg speichern",
cEnable: true,
cLabel: "EMR Beleg speichern",
nPos: 5
});

Thank you for your help. Peter

image.png
You do not have the required permissions to view the files attached to this post.
User avatar
Vasyl-Tracker Dev Team
Site Admin
Posts: 2353
Joined: Thu Jun 30, 2005 4:11 pm
Location: Canada

Re: custom button with individual image

Post by Vasyl-Tracker Dev Team »

Hi Peter.

The standard way is described there:

https://opensource.adobe.com/dc-acrobat ... toolbutton

- unfortunately, that Adobe's manual is organized ugly so you need to search "addToolButton" on that web-page to reach the description and see this example:

Code: Select all

// Create a document
var myDoc = app.newDoc();

// import icon (20x20 pixels) from the file specified
myDoc.importIcon("myIcon", "/C/myIcon.jpg", 0);

// convert the icon to a stream.
oIcon = util.iconStreamFromIcon(myDoc.getIcon("myIcon"));

// close the doc now that we have grabbed the icon stream
myDoc.closeDoc(true);

// add a toolbutton
app.addToolButton({
    cName: "myToolButton",
    oIcon: oIcon,
    cExec: "app.alert('Someone pressed me!')",
    cTooltext: "Push Me!",
    cEnable: true,
    nPos: 0
});

app.removeToolButton("myToolButton")
Tip: in Editor you may load the icon much easier than in Acrobat, just via:

oIcon = util.iconStreamFromImage("/C/myIcon.jpg");

HTH.
Vasyl Yaremyn
Tracker Software Products
Project Developer

Please archive any files posted to a ZIP, 7z or RAR file or they will be removed and not posted.