Rotating a stamp from the stamp pallet

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

Post Reply
pmcnulty
User
Posts: 20
Joined: Wed Apr 06, 2016 11:39 pm

Rotating a stamp from the stamp pallet

Post by pmcnulty »

Not sure if this is possible
I want to provide the user with a stamp which asks them for an angle in degrees and rotates the stamp when they use it from the stamp pallet
here is the code I've got so far

Code: Select all

var Consentdialog = 
{
	degrees:"",
	//this function is fired on pressing ok
	commit: function(dialog) 
	{
		var data = dialog.store();
		console.println("commit");
		
		this.degrees=data["stxt"];
	},


	description:
	{
		name:"Containment Diagram",
		elements:
		[
			{
				type: "static_text",
				bold: true,
				name: "Enter angle from north (degrees): "
			},
			{
				item_id: "stxt",
				width: 300,
            		type: "edit_text",
           		multiline: false,
			},
			{
				type: "gap",    //Add a small vertical gap between
				height: 10      //..radio fields and buttons
			},
			{
				type: "ok_cancel",
				ok_name: "Ok",
				cancel_Name: "Cancel"
			}
		]
	}
}

if(event.source.forReal &&
   ((event.source.stampName == "h2yaK916D7gKH6wiDDHfe0")))
{
	app.execDialog(Consentdialog)

	if(Consentdialog.degrees !="")
	{
		console.println(Consentdialog.degrees);

	}

}
Attachments
4eb73abe-eea3-4e72-b79373e539a7acef.pdf
(267.05 KiB) Downloaded 104 times
User avatar
Will - Tracker Supp
Site Admin
Posts: 6815
Joined: Mon Oct 15, 2012 9:21 pm
Location: London, UK
Contact:

Re: Rotating a stamp from the stamp pallet

Post by Will - Tracker Supp »

Hi pmcnulty,

Thanks for the post - Typically we don't write users code for them unless it's something really simple and working with dialogs via JS is not trivial. Is there something specific that we can guide you on?

Thanks,
If posting files to this forum, you must archive the files to a ZIP, RAR or 7z file or they will not be uploaded.
Thank you.

Best regards

Will Travaglini
Tracker Support (Europe)
Tracker Software Products Ltd.
http://www.tracker-software.com
User avatar
yogi108
User
Posts: 74
Joined: Thu Mar 09, 2017 9:13 am
Location: Austria, Theiß
Contact:

Re: Rotating a stamp from the stamp pallet

Post by yogi108 »

Hi,

If you have the name you can set the property rotate:

Code: Select all

var annots = this.getAnnot(0, "h2yaK916D7gKH6wiDDHfe0");
annots.rotate=Consentdialog.degrees;
for the above running you need the correct pagenumber where the stamp is put on - at the moment the first page ("0") -
or you have the object already ...

regards,
"You cannot know the meaning of your life until you are connected to the power that created you.”
Shri Mataji Nirmala Devi, founder of Sahaja Yoga
User avatar
Will - Tracker Supp
Site Admin
Posts: 6815
Joined: Mon Oct 15, 2012 9:21 pm
Location: London, UK
Contact:

Re: Rotating a stamp from the stamp pallet

Post by Will - Tracker Supp »

Thanks Yogi :)
If posting files to this forum, you must archive the files to a ZIP, RAR or 7z file or they will not be uploaded.
Thank you.

Best regards

Will Travaglini
Tracker Support (Europe)
Tracker Software Products Ltd.
http://www.tracker-software.com
pmcnulty
User
Posts: 20
Joined: Wed Apr 06, 2016 11:39 pm

Re: Rotating a stamp from the stamp pallet

Post by pmcnulty »

Thanks Yogi for the response

I believe the code you've given below would work from the console windows after the stamp has been placed

basically I'm trying to set the rotate as the stamp is being pulled from the stamp pallet.
really I'm asking if we can access properties such as rotate as we are stamping not after the stamp is there
User avatar
yogi108
User
Posts: 74
Joined: Thu Mar 09, 2017 9:13 am
Location: Austria, Theiß
Contact:

Re: Rotating a stamp from the stamp pallet

Post by yogi108 »

Hi,

you have to find out how to get the stamp object, as I have no idea about the events you
sucessfully implented - just realized that the pdf is the stamp.

The object maybe is given through the event.source.xxxx
if not hopefully the pagenumber, so you can use the code

Code: Select all

if(event.source.forReal &&
   ((event.source.stampName == "h2yaK916D7gKH6wiDDHfe0")))
{
   app.execDialog(Consentdialog)

   if(Consentdialog.degrees !="")
   {
      // here you have to get the object, maybe already there 
      // or getting like this
      var page=0; // first page in the doc
      var annots = this.getAnnot(page, "h2yaK916D7gKH6wiDDHfe0");
      annots.rotate=Consentdialog.degrees;

   }

}
If the object is found it will work as you like....

I cannot test it, as I am limited to PDF-XChange without dynamic stamps,
regards,
"You cannot know the meaning of your life until you are connected to the power that created you.”
Shri Mataji Nirmala Devi, founder of Sahaja Yoga
User avatar
Tracker Supp-Stefan
Site Admin
Posts: 17910
Joined: Mon Jan 12, 2009 8:07 am
Location: London
Contact:

Re: Rotating a stamp from the stamp pallet

Post by Tracker Supp-Stefan »

Thanks for the help yogi108!

@pmcnulty - please do let us know if the above code works for you!

Cheers,
Stefan
Post Reply