Set Print/Unprint-Property for Stamps

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

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

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

Set Print/Unprint-Property for Stamps

Post by Nimrod_189 »

Hello folks,

can I insert my own menu buttons with Javascript code in the XChange viewer?
I have developed the following solutions to my problem with stamps to set not printing:

1. Swicht Print-/Unprint-Property for selected Stamps

var aAnnots = this.selectedAnnots;
for (var i=0; i < aAnnots.length; i++)
if (aAnnots.print) {aAnnots.print=false} else { aAnnots.print=true};


2. Switch Print-/Unprint-Property for all Stamps

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



I would now like to add these two options to the toolbar with my own commands.

Is this possible with the XChange viewer?

Thank you.

Nimrod_189
User avatar
Stefan - PDF-XChange
Site Admin
Posts: 19306
Joined: Mon Jan 12, 2009 8:07 am
Contact:

Re: Set Print/Unprint-Property for Stamps

Post by Stefan - PDF-XChange »

Hello Nimrod_189,

The Viewer has been discontinued for 10+ years now, so I am no longer sure if it was possible to have custom scripts in it.
It is however possible to add custom toolbar buttons to the Editor:
How do I add a custom tool to the toolbar, using JavaScript, in the Editor?

Kind regards,
Stefan
Nimrod_189
User
Posts: 49
Joined: Wed Sep 23, 2009 8:39 am

Re: Set Print/Unprint-Property for Stamps

Post by Nimrod_189 »

Hello Stefan,

Thank you for the info.
I tried to add the button after online help, but unfortunately nothing happens here.

Code: Select all


Function SetPrintableStamp()
{
this.syncAnnotScan();
var aAnnots = this.getAnnots();
if (aAnnots!=null && aAnnots.length!=0)
for (var i in aAnnots)
if (aAnnots.print) {aAnnots.print=false} else { aAnnots.print=true};
}


// This adds a button to the Add-on Tools toolbar
app.addToolButton({
	cName: "SetPrintableStamp",
	cLabel: "Switch Stempel Printable",
	//oIcon: "lightning.png",
	cExec: "SetPrintableStamp()"
	cTooltext: "Switch alle Stamps druckbar/nicht druckbar",
	cEnable: True,
	nPos: -1
});

How can that be?
Do you have any idea?

Thank you
Nimrod_189
User
Posts: 49
Joined: Wed Sep 23, 2009 8:39 am

Re: Set Print/Unprint-Property for Stamps

Post by Nimrod_189 »

So I found a script example “js_addRbMenuExample” from you, which works perfectly. I'm just going to work my way towards it slowly now.

I also found the PDF file "PXCE menu-toolbar methods.pdf" in the forum. All parameters are explained in detail here.

But maybe someone can tell me the exact name for the first tab, as I would like to insert my tool collection into it. In German the tab is called “Start”.

Thank you.

I'll just try my luck now.

Nimrod_189
User avatar
Stefan - PDF-XChange
Site Admin
Posts: 19306
Joined: Mon Jan 12, 2009 8:07 am
Contact:

Re: Set Print/Unprint-Property for Stamps

Post by Stefan - PDF-XChange »

Hello Nimrod_189,

It is called "Home" in English, however I believe that the code uses the IDs of the menus, to allow for language independent access and placement of your custom buttons in the menus.

Kind regards,
Stefan
Post Reply