Can't create a button because IconStreamFromIcon  SOLVED

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

Moderators: Daniel - PDF-XChange, PDF-XChange Support, Vasyl - PDF-XChange, Chris - PDF-XChange, Sean - PDF-XChange, Paul - PDF-XChange, Ivan - Tracker Software, Stefan - PDF-XChange

Post Reply
Nimrod_189
User
Posts: 60
Joined: Wed Sep 23, 2009 8:39 am

Can't create a button because IconStreamFromIcon

Post 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.
Nimrod_189
User
Posts: 60
Joined: Wed Sep 23, 2009 8:39 am

Re: Can't create a button because IconStreamFromIcon  SOLVED

Post 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
User avatar
Daniel - PDF-XChange
Site Admin
Posts: 10911
Joined: Wed Jan 03, 2018 6:52 pm

Re: Can't create a button because IconStreamFromIcon

Post 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,
Dan McIntyre - Support Technician
PDF-XChange Co. LTD

+++++++++++++++++++++++++++++++++++
Our Web site domain and email address has changed as of 26/10/2023.
https://www.pdf-xchange.com
Support@pdf-xchange.com
Mathew
User
Posts: 564
Joined: Thu Jun 19, 2014 7:30 pm

Re: Can't create a button because IconStreamFromIcon

Post 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
Nimrod_189
User
Posts: 60
Joined: Wed Sep 23, 2009 8:39 am

Re: Can't create a button because IconStreamFromIcon

Post 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
User avatar
Dimitar - PDF-XChange
Site Admin
Posts: 2195
Joined: Mon Jan 15, 2018 9:01 am

Can't create a button because IconStreamFromIcon

Post by Dimitar - PDF-XChange »

:)
Post Reply