Page 1 of 1

Can't create a button because IconStreamFromIcon

Posted: Sat Dec 07, 2024 4:19 pm
by Nimrod_189
Hello folks,

I've now managed to add two buttons to the "Home" tab. However, I have problems with a custom icon.

When I load a utitl.iconStreamFromIcon no buttons are created for me.
However, if I use the icon ID, everything works.

I saved my icon in the .../Icon/icostubIcon.png directory.

Does anyone have an idea what I'm doing wrong here?

Here my code:

Code: Select all


//Fullpath: C:\Users\ama\AppData\Roaming\Tracker Software\PDFXEditor\3.0\JavaScripts\Icon\icostubIcon.png

 var myDoc = app.newDoc();
 myDoc.importIcon("stubIcon", "/Icon/icostubIcon.png", 0);
 var oIcon = util.iconStreamFromIcon(myDoc.getIcon("stubIcon"));
 myDoc.closeDoc(true);

//var cIconID = "ico.pencil";

app.addSubMenu({ cName: "myRbTools", cUser: "My Ribbon Tools", cParent: "-", cRbParent: "Home", bNewRbGroup: true, nRbGroupStyle: 2 });


	var id = "1";
	app.addMenuItem( {
		cName: "feature" + id,
		cUser: "alle Stempel drucken",
		cParent: "myMenu",
		cRbParent: "myRbTools",
		oIcon: oIcon,
		//cIconID: cIconID,
		cExec: "SetAllPrintableStamp()" }
	  	);

	var id = "2";
	app.addMenuItem( {
		cName: "feature" + id,
		cUser: "markierte Stempel drucken",
		cParent: "myMenu",
		cRbParent: "myRbTools",
		oIcon: oIcon,
		//cIconID: cIconID,
		cExec: "SetSelectPrintableStamp()" }
		);

function SetAllPrintableStamp() {
this.syncAnnotScan();
var annots = this.getAnnots();
if (annots!=null && annots.length!=0)
for (var i in annots) 
if (annots[i].print) {annots[i].print=false} else { annots[i].print=true};
}

function SetSelectPrintableStamp () {
var annots = this.selectedAnnots;
for (var i=0; i < annots.length; i++)
if (annots[i].print) {annots[i].print=false} else { annots[i].print=true};
}
 
Thank you.

Re: Can't create a button because IconStreamFromIcon  SOLVED

Posted: Sun Dec 08, 2024 9:32 am
by Nimrod_189
Now here is now my solution:

Code: Select all


var Icon = util.iconStreamFromImage("/C/Users/ama/AppData/Roaming/Tracker Software/PDFXEditor/3.0/JavaScripts/Icon/switch.png");

app.addSubMenu({ cName: "myRbTools", cUser: "My Ribbon Tools", cParent: "-", cRbParent: "Home", bNewRbGroup: true, nRbGroupStyle: 2 });

	var id = "1";
	app.addMenuItem( {
		cName: "feature" + id,
		cUser: "alle Stempel nicht drucken",
		cParent: "myMenu",
		cRbParent: "myRbTools",
		oIcon: Icon,
		//cIconID: cIconID,
		cExec: "SetAllPrintableStamp()" }
	  	);

	var id = "2";
	app.addMenuItem( {
		cName: "feature" + id,
		cUser: "markierte Stempel nicht drucken",
		cParent: "myMenu",
		cRbParent: "myRbTools",
		oIcon: Icon,
		//cIconID: cIconID,
		cExec: "SetSelectPrintableStamp()" }
		);

function SetAllPrintableStamp() {
this.syncAnnotScan();
var annots = this.getAnnots();
if (annots!=null && annots.length!=0)
for (var i in annots) 
if (annots[i].print) {annots[i].print=false} else { annots[i].print=true};
}


function SetSelectPrintableStamp () {
var annots = this.selectedAnnots;
for (var i=0; i < annots.length; i++)
if (annots[i].print) {annots[i].print=false} else { annots[i].print=true};
}

The secret was that the complete path only consists of /. Then that works too.
see also: viewtopic.php?t=28855

Nimrod_189

Re: Can't create a button because IconStreamFromIcon

Posted: Mon Dec 09, 2024 11:43 pm
by Daniel - PDF-XChange
Hello, Nimrod_189

I am glad to hear you have found a solution! Did you have any other item you are still looking for a solution on?

Kind regards,

Re: Can't create a button because IconStreamFromIcon

Posted: Tue Dec 10, 2024 12:23 am
by Mathew
[Edit] Oops, @Nimrod_189 I saw that you found the PXE method. Sorry to repeat. :roll:

By the way: PDFX-Change has a custom util method to load icons from files directly that works better than importing into a new document first:

Code: Select all

var Icon = util.iconStreamFromImage( cDIPath, nPage, nFitSize);
image.png

Can't create a button because IconStreamFromIcon

Posted: Tue Dec 10, 2024 12:07 pm
by Stefan - PDF-XChange
:)

Re: Can't create a button because IconStreamFromIcon

Posted: Wed Dec 11, 2024 11:50 am
by Nimrod_189
Hello Daniel,

Thank you very much for the query.
But I've solved pretty much all of my problems. The only problem is the tooltips, but that's not so bad since I only use two buttons. :roll:

Nimrod_189

Can't create a button because IconStreamFromIcon

Posted: Wed Dec 11, 2024 2:43 pm
by Dimitar - PDF-XChange
:)