Print Page | Close Window

Rotate a Stamp

Printed From: Foxit's Planet PDF Forum
Category: Lets Talk PDF
Forum Name: JavaScript
Forum Description: Discussions relating to the use of JavaScript within PDF.
URL: http://forums.planetpdf.com/forum_posts.asp?TID=2174
Printed Date: 17 Oct 2019 at 1:27am
Software Version: Web Wiz Forums 11.10 - http://www.webwizforums.com


Topic: Rotate a Stamp
Posted By: pmcnulty
Subject: Rotate a Stamp
Date Posted: 24 May 2017 at 11:42pm
Hi I'm trying to create a stamp where when the user drags the stamp onto the document it runs JavaScript to create a popup dialog asking the user for an angle to rotate the stamp and the stamp is placed on the document with that rotation. I have created and can run the dialog but can't work out how to access the properties or get the stamp to rotate
the code I have is :

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);
//change stamp rotation
   }

}





Replies:
Posted By: try67
Date Posted: 28 May 2017 at 11:09pm
You can't do that, because when the code is executed the stamp object doesn't exist yet.
One possible workaround is to add a time-out that executes a code to rotate the last annotation added to the file some time after the dialog is closed, maybe after 500ms or so.


-------------
- Acrobat Expert - Contact me personally at try6767@gmail.com
Check out my custom-made scripts website: http://try67.blogspot.com


Posted By: pmcnulty
Date Posted: 29 May 2017 at 1:22am
Thanks try67
was hoping I would be able to access the underlying stamp object that was being place will have a look at a different approach



Print Page | Close Window

Forum Software by Web Wiz Forums® version 11.10 - http://www.webwizforums.com
Copyright ©2001-2017 Web Wiz Ltd. - https://www.webwiz.net