Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: Form Button with Javascript  (Read 2725 times)

gailwilk59

  • Newbie
  • *
  • Karma: +0/-0
  • Posts: 2
Form Button with Javascript
« on: October 30, 2018, 07:51:41 am »

I have created a form template that needs to be flattened, saved and emailed.  At the bottom I inserted a form button to do this, assigned an action (mouse down) and inserted the script.  However, the button changes briefly when pressed, but it does not appear to run the javascript.  The same script works fine when assigned an icon and placed on the toolbar.  I've never used the "button" before or the javascript feature.  And, yes, I have JavaScript enabled in my preferences. Any ideas?
The script is as follows:

Flatten(false,65536)
SaveAs("pdf")
Email()
Logged

Steve

  • Administrator
  • Sr. Member
  • *****
  • Karma: +5/-0
  • Posts: 353
    • RevuHelp
Re: Form Button with Javascript
« Reply #1 on: October 30, 2018, 08:34:54 am »

I'm not a JS person at all, but pulling waaaaayyyy back from my HyperCard programming days, you almost always wanted buttons to act on the MOUSE UP command.  Not MOUSE DOWN.   What happens if you switch to on MOUSE UP?
Logged
Steve Jones
RevuHelp Forum Admin
steve@revuhelp.com
www.revuhelp.com
www.facebook.com/RevuHelp

gailwilk59

  • Newbie
  • *
  • Karma: +0/-0
  • Posts: 2
Re: Form Button with Javascript
« Reply #2 on: November 01, 2018, 08:11:29 am »

Same result. :(
Logged

Maxime.Vezeau

  • Newbie
  • *
  • Karma: +0/-0
  • Posts: 9
Re: Form Button with Javascript
« Reply #3 on: December 11, 2018, 04:57:33 pm »

I have created a form template that needs to be flattened, saved and emailed.  At the bottom I inserted a form button to do this, assigned an action (mouse down) and inserted the script.  However, the button changes briefly when pressed, but it does not appear to run the javascript.  The same script works fine when assigned an icon and placed on the toolbar.  I've never used the "button" before or the javascript feature.  And, yes, I have JavaScript enabled in my preferences. Any ideas?
The script is as follows:

Flatten(false,65536)
SaveAs("pdf")
Email()

Your commands are not in JavaScript, they are built-in commands in Bluebeam and won't work where you put them.

I'll split this into two parts: 1.What you can do in JavaScript 2.What you can do with BlueBeam

If you absolutely want a button on your PDF, go with #1. If it's you and your team, and you don't mind adding another button on your toolbar, go with #2.

1.
Here is what I found with some success. Keep in mind I'm relatively new to this coding language.

For your Flatten:
Code: [Select]
this.flattenPages();
Note that you will not be able to unflatten.
Also if you want a specified range of pages, add something like:

Code: [Select]
this.flattenPages({
    nStart: 0,
    nEnd: this.numPages - 1,
    );}

Flatten always worked for me.

For the e-mail:
Code: [Select]
this.mailDoc({
    bUI: true,
    cTo: "me@myself.ca",
    cCc: "",
    cSubject: "I am the one who e-mails",
    cMsg: "This is a message \n",
});

It worked, but not all the time. Something in the background is blocking it, I'll check this at some other time. Otherwise, It should work fine.

Saving..... is another matter...

Code: [Select]
this.SaveAs("/C/Users/User_name/MyDocuments/" + "apple_juice.pdf");
Should have worked but it didn't  ???

2.
In the Document or Batch menu select Script.

Click on the Plus Sign " + " of the Script Manager.

Name the script however you like and choose the icon you want.

Copy and paste your functions in the script box.

Code: [Select]
Flatten(false,65536)
SaveAs("pdf")
Email()

Press "Ok" select it under Scripts and press Run.

It should work as intended.

You can get your script onto your toolbar. It is under the Script Category in the Customize Toolbar menu.

If you have any questions, let me know. I assume you are on the latest version of the software.
« Last Edit: December 13, 2018, 08:50:08 am by Maxime.Vezeau »
Logged

GRonkette

  • Newbie
  • *
  • Karma: +0/-0
  • Posts: 1
Re: Form Button with Javascript
« Reply #4 on: April 16, 2020, 02:50:36 pm »

Has anyone come up with a solution for this?  I have the button and it will open an email and populate the To:, CC:, Subject and Body with information from my form but I can't get it to save as.  Does Revu just not have the API to Save As like Adobe's this.SaveAs?  They list a save feature on the help forum but it doesn't work, see link below.  I have the latest version of Revu 2019.1.16 and JavaScript is turned on.

https://support.bluebeam.com/wp-content/uploads/2020/01/Bluebeam-Script-Reference-2019.pdf

This would be very useful for a couple forms that we have created for my business. Thanks,
Logged